Contact emails
Spec
4.3.6. [Global] and [PrimaryGlobal]
4.5.5. Named properties object
4.7.1. Indexed and named properties
Summary
Fix Window's members' visibility.
Motivation
Blink's implementation and behavior about Window's members are unique among FF, IE and Safari. It differs from the spec. Let's fix it and align to the behavior of FF, IE, Safari and the spec.
Design doc
Proposed changes
1. Named child browsing contexts should NOT shadow Window's other members.
before: Named child browsing contexts have the highest priority when looking for a name.
after: Named child browsing contexts have the same priority as other named properties.
2. Event handlers on 'window' (window.onxxx) should be placed on "window" instance object.
before: onxxx are placed at Window.prototype.onxxx
after: onxxx are placed at window.onxxx (window.hasOwnProperty('onxxx') returns true.)
3. Operations (methods) should be placed on "window" instance object.
before: alert function is placed at Window.prototype.alert
after: alert function is placed at window.alert (window.hasOwnProperty('alert') returns true.)
4. Introduce the named properties object for Window (i.e. WindowProperties) to the prototype chain of Window.
Compatibility Risk
As expected results of the changes, users will see the following behavioral changes.
1. Named child browsing contexts
iframe = document.createElement('iframe')
document.body.appendChild(iframe)
Before: 'window.alert' returns iframe.contentWindow object.
After: 'window.alert' returns the built-in alert function.
2. Event handlers
var onclick = function() { console.log('clicked'); }
Before: A global variable 'onclick' is created. 'onclick' attribute is not changed. So, when clicked, no message appears on the console.
After: A global variable 'onclick' is NOT created because 'window' already has 'onclick' member on the instance object. 'onclick' attribute is updated. So, when clicked, "clicked" message appears on the console.
3. Operations (methods)
No notable change compared to 2. Event handlers. Technically the same thing happens, however, assignments to operations are simple assignment unlike attributes, thus users may not recognize a change unless they directly access to 'Window.prototype.methodName'.
4. WindowProperties
Before: window.__proto__.__proto__ === EventTarget.prototype
After: window.__proto__.__proto__ === the named properties object of Window (i.e. WindowProperties)
window.__proto__.__proto__.__proto__ === EventTarget.prototype
Change 1 to 3 may be seen only when web developers use conflicting global variable names with Window's members (e.g. alert, onclick, etc.)
Since FF, IE and Safari already implemented the spec correctly, no compatibility risk is expected when compared to other browsers.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
Link to entry on the feature dashboard
No entry. Because the changes do not affect developers as long as developers do not use global variables with conflicting names.