Bug 126522 - Named object access properties should be configurable or don't exist at all
Summary: Named object access properties should be configurable or don't exist at all
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: https://github.com/ajaxorg/ace/issues...
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2014-01-06 06:37 PST by Derk-Jan Hartman
Modified: 2018-06-04 06:02 PDT (History)
0 users

See Also:


Attachments
Reduced testcase (458 bytes, text/html)
2016-09-14 05:05 PDT, Derk-Jan Hartman
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Derk-Jan Hartman 2014-01-06 06:37:13 PST
This is about the side effects of http://www.w3.org/TR/html5/browsers.html#named-access-on-the-window-object

It seems the properties that this named access creates on the window object are non-configureable. This makes it 'randomly'/'DOM dependent' impossible to create properties on the window object. Apparently Safari is the only browser that has them unconfigurable and the only browser that has them defined as actually properties. There might be a good reason for this (security ?). However, it's annoying, especially for JS libraries that might be deployed. This impredictability of which properties on your window object are defined makes this a nuisance to developers and more so. I think this should be changed.

I ran into this problem here: https://github.com/ajaxorg/ace/issues/1741


Additionally specific to Safari, this seems to create a problem with local declared but uninitialized variables, which might be even more problematic. This problem is detailed in the console.log example in http://dertompson.com/2013/08/07/named-access-on-the-window-object-in-safari/
This might give a scripter unintentional and obscured access to these named objects causing unpredictable results.

Further background reading materials:
http://tjvantoll.com/2012/07/19/dom-element-references-as-global-variables/
https://www.w3.org/Bugs/Public/show_bug.cgi?id=11960
Comment 1 Derk-Jan Hartman 2015-06-30 13:55:49 PDT
This seems to be fixed in Safari 9 Seed 1 ?
Comment 2 Derk-Jan Hartman 2016-09-12 12:42:23 PDT
Hmm, or not, it seems that this issue still exists and I just ran into it again.

Had a header with id="addOnloadHook", then was trying to define a property on window with the key 'addOnloadHook'. This was impossible due to named access.
Comment 3 Derk-Jan Hartman 2016-09-14 05:05:31 PDT
Created attachment 288806 [details]
Reduced testcase
Comment 4 Derk-Jan Hartman 2018-06-04 06:02:57 PDT
This problem seems resolved in at least Safari 11.1

Not sure when the fix was made.