Bug 1758164 - Align the behavior of defining non-configurable properties on a WindowProxy on Nightly with Release/Beta; r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D141732
This commit is contained in:
Edgar Chen
2022-03-29 20:33:24 +00:00
parent 0130fa3f4d
commit 6ab647fc40
7 changed files with 22 additions and 163 deletions

View File

@@ -574,28 +574,6 @@ void nsOuterWindowProxy::finalize(JS::GCContext* gcx, JSObject* proxy) const {
}
}
/**
* IsNonConfigurableReadonlyPrimitiveGlobalProp returns true for
* property names that fit the following criteria:
*
* 1) The ES spec defines a property with that name on globals.
* 2) The property is non-configurable.
* 3) The property is non-writable (readonly).
* 4) The value of the property is a primitive (so doesn't change
* observably on when navigation happens).
*
* Such properties can act as actual non-configurable properties on a
* WindowProxy, because they are not affected by navigation.
*/
#ifndef RELEASE_OR_BETA
static bool IsNonConfigurableReadonlyPrimitiveGlobalProp(JSContext* cx,
JS::Handle<jsid> id) {
return id == GetJSIDByIndex(cx, XPCJSContext::IDX_NAN) ||
id == GetJSIDByIndex(cx, XPCJSContext::IDX_UNDEFINED) ||
id == GetJSIDByIndex(cx, XPCJSContext::IDX_INFINITY);
}
#endif
bool nsOuterWindowProxy::getOwnPropertyDescriptor(
JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JS::MutableHandle<Maybe<JS::PropertyDescriptor>> desc) const {
@@ -651,7 +629,8 @@ bool nsOuterWindowProxy::getOwnPropertyDescriptor(
return false;
}
#ifndef RELEASE_OR_BETA // To be turned on in bug 1496510.
#if 0
// See https://github.com/tc39/ecma262/issues/672 for more information.
if (desc.isSome() &&
!IsNonConfigurableReadonlyPrimitiveGlobalProp(cx, id)) {
(*desc).setConfigurable(true);
@@ -768,7 +747,8 @@ bool nsOuterWindowProxy::definePropertySameOrigin(
}
}
#ifndef RELEASE_OR_BETA // To be turned on in bug 1496510.
#if 0
// See https://github.com/tc39/ecma262/issues/672 for more information.
if (desc.hasConfigurable() && !desc.configurable() &&
!IsNonConfigurableReadonlyPrimitiveGlobalProp(cx, id)) {
// Give callers a way to detect that they failed to "really" define a