Skip to content

[Problem/Bug]: window.gc collides with page defined consts causing exceptions. #5387

@jonathanKingston

Description

@jonathanKingston

What happened?

#4378 was closed but I would like to request instead of removal a way to rename this method.

Even if this is necessary for internal WebView2 code, it would be very useful to be able to alias it to something that doesn't collide with minified code (eg: window.chrome.gc or window.__webView2Gc etc). The exception caused often stops the whole website working.

On minified pages that use:

const gc = {}

This will cause a fatal exception, additionally it's not possible to run delete window.gc in content scripts ahead of the script either as the property can't be modified.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

Win32

Operating System

Windows 11

OS Version

No response

Repro steps

Visit: https://output.jsbin.com/xasabapike
See: "expect: Hello"
Actual: Uncaught SyntaxError: Identifier 'gc' has already been declared (at xasabapike:19:9)

In case the page goes away:

Code:

const gc = "hello"
document.write(gc)

HTML:

<!DOCTYPE html>
<html>
<body>
Expect: 
<script>
</body>
</html>

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions