Is window.chrome problematic?
caridy opened this issue · 2 comments
@jfparadis raised this issue during the SES meeting today considering that window.chrome
is not configurable.
Object.getOwnPropertyDescriptor(window, 'chrome')
{value: {…}, writable: true, enumerable: true, configurable: false}
This is not problematic because even though it is non-configurable, it is writable, therefore we can replace the value
with undefined
(in the case of SES), or with a Proxy
in the case of our use-case.
The issue I raised is a little different, and it's due to the fact that window.chrome
can't be removed, which means that:
typeof chrome === 'undefined'
fails- an accidental global can't be detected with a
ReferenceError
.
In addition, this global is unspecified API, and it's pure luck that it can be nullified. This is a great canari alerting to a problem...
The language specs should include an invariant to at least maintain status quo on the current non-configurable objects (better, make them configurable), but more importantly prevent other objects to appear as non-configurable or non-writable!