Bug 126522

Summary: Named object access properties should be configurable or don't exist at all
Product: WebKit Reporter: Derk-Jan Hartman <hartman.wiki>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal Keywords: HasReduction
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: https://github.com/ajaxorg/ace/issues/1741
Attachments:
Description Flags
Reduced testcase none

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.