[Webkit-unassigned] [Bug 267199] JavaScript function name 'top' has been taken. Caused pages already using this name to fail.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Jan 10 22:06:33 PST 2024
https://bugs.webkit.org/show_bug.cgi?id=267199
--- Comment #6 from Alexey Shvayka <ashvayka at apple.com> ---
(In reply to Richard Northcott from comment #0)
> Created attachment 469323 [details]
> Two html files with Javascript functions. Spelling only slightly different.
>
> Since iOS17.2 and now on all WebView-based browsers that I have the
> following name is defined in the JavaScript function space (where it was not
> before)
>
> "top()"
>
> eg.
>
> function top()
> {
>
> }
>
> It just needs to exist, not even called, and all the JavaScript fails
> without any feedback.
Yes, it fails to be declared, and aborts execution of the containing script with a SyntaxError.
> This causes webpages and apps using WKWebView in the wild to fail.
Yes, breaking iOS apps was a risk of introducing this SyntaxError, yet apart from this bug report, we haven't recorded any issues so far. As for breaking webpages, both Chrome and Firefox throw an error for `function top() {}` and friends, adhering to the spec (https://tc39.es/ecma262/#sec-globaldeclarationinstantiation).
(In reply to Richard Northcott from comment #1)
> The same error occurs for functions named 'location' and 'document'
> This would make it seem like it is conflicting with a 'window' property, but other property names do not throw an error.
The error occurs for non-configurable non-writable global properties, preventing them from being overridden, which is a good thing: according to Invariants of the Essential Internal Methods (https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods), for [[Get]]:
* If P was previously observed as a non-configurable, non-writable own data property of the target with value V, then [[Get]] must return the SameValue as V.
Introduction of CanDeclareGlobalFunction aligns `window` with other JS objects by enforcing immutability of non-configurable non-writable properties.
Invariants of the Essential Internal Methods were specced in ES6, and the language design committee considers that breaking them for any API designed in the future would prevent developer adoption due to non-sensible behavior.
(In reply to Richard Northcott from comment #3)
> I have been using the function name "top()" in web and app solutions for more than 10 years and with a change in WebKit they all stopped working.
> -That is why I call it a bug.
We would very much like to avoid adding per-app exception for throwing the SyntaxError, so if any way possible, please consider renaming.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240111/7dcee3bd/attachment.htm>
More information about the webkit-unassigned
mailing list