Bug 1178639. WindowProxy should generally claim that properties on it are configurable. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 27 Nov 2018 14:16:50 -0500
changeset 507640 95651672782a47a2031a4ea492f85053c98d5769
parent 507639 a9dac00a9eef530202050947dc2cac3ef72541ec
child 507641 e52f3a7ece193bdf93ac2c87796cad693bb1e882
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1178639
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178639. WindowProxy should generally claim that properties on it are configurable. r=peterv The one exception are properties that are: 1) Defined in the ES spec. 2) Non-configurable. 3) Readonly. 4) Have values that don't observable change on navigation.
dom/base/nsGlobalWindowOuter.cpp
dom/base/test/test_window_define_nonconfigurable.html
testing/web-platform/meta/html/browsers/the-window-object/window-properties.https.html.ini
testing/web-platform/meta/html/dom/interfaces.https.html.ini
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -531,21 +531,28 @@ nsOuterWindowProxy::getOwnPropertyDescri
     return false;
   }
   if (found) {
     FillPropertyDescriptor(desc, proxy, true);
     return true;
   }
   // else fall through to js::Wrapper
 
-
-  // When we change this to always claim the property is configurable (bug
-  // 1178639), update the comments in nsOuterWindowProxy::defineProperty
-  // accordingly.
-  return js::Wrapper::getOwnPropertyDescriptor(cx, proxy, id, desc);
+  bool ok = js::Wrapper::getOwnPropertyDescriptor(cx, proxy, id, desc);
+  if (!ok) {
+    return false;
+  }
+
+#ifndef RELEASE_OR_BETA // To be turned on in bug 1496510.
+  if (!IsNonConfigurableReadonlyPrimitiveGlobalProp(cx, id)) {
+    desc.setConfigurable(true);
+  }
+#endif
+
+  return true;
 }
 
 bool
 nsOuterWindowProxy::defineProperty(JSContext* cx,
                                    JS::Handle<JSObject*> proxy,
                                    JS::Handle<jsid> id,
                                    JS::Handle<JS::PropertyDescriptor> desc,
                                    JS::ObjectOpResult &result) const
--- a/dom/base/test/test_window_define_nonconfigurable.html
+++ b/dom/base/test/test_window_define_nonconfigurable.html
@@ -17,28 +17,28 @@ https://bugzilla.mozilla.org/show_bug.cg
    * fixed.
    */
   var retval = Object.defineProperty(window, "nosuchprop",
                                      { value: 5, configurable: false });
   is(retval, false,
      "Should return false when 'failing' to define non-configurable property via Object.defineProperty.")
   var desc = Object.getOwnPropertyDescriptor(window, "nosuchprop");
   is(typeof(desc), "object", "Should have a property 'nosuchprop' now");
-  todo_is(desc.configurable, true,
-          "Property 'nosuchprop' should be configurable");
+  is(desc.configurable, true,
+     "Property 'nosuchprop' should be configurable");
   is(desc.writable, false, "Property 'nosuchprop' should be readonly");
   is(desc.value, 5, "Property 'nosuchprop' should have the right value");
 
   retval = Object.defineProperty(window, "nosuchprop2", { value: 6 });
   is(retval, window,
      "Should return object when succesfully defining 'nosuchprop2'");
   desc = Object.getOwnPropertyDescriptor(window, "nosuchprop2");
   is(typeof(desc), "object", "Should have a property 'nosuchprop2' now");
-  todo_is(desc.configurable, true,
-          "Property 'nosuchprop2' should be configurable");
+  is(desc.configurable, true,
+     "Property 'nosuchprop2' should be configurable");
   is(desc.writable, false, "Property 'nosuchprop2' should be readonly");
   is(desc.value, 6, "Property 'nosuchprop2' should have the right value");
 
   retval = Object.defineProperty(window, "nosuchprop3",
                                  { value: 7, configurable: true });
   is(retval, window,
      "Should return object when succesfully defining 'nosuchprop3'");
   desc = Object.getOwnPropertyDescriptor(window, "nosuchprop3");
@@ -49,29 +49,29 @@ https://bugzilla.mozilla.org/show_bug.cg
   is(desc.value, 7, "Property 'nosuchprop3' should have the right value");
 
   retval = Reflect.defineProperty(window, "nosuchprop4",
                                   { value: 8, configurable: false });
   is(retval, false,
      "Should not be able to Reflect.defineProperty if non-configurable");
   desc = Object.getOwnPropertyDescriptor(window, "nosuchprop4");
   is(typeof(desc), "object", "Should have a property 'nosuchprop4' now");
-  todo_is(desc.configurable, true,
-          "Property 'nosuchprop4' should be configurable");
+  is(desc.configurable, true,
+     "Property 'nosuchprop4' should be configurable");
   is(desc.writable, false, "Property 'nosuchprop4' should be readonly");
   is(desc.value, 8, "Property 'nosuchprop4' should have the right value");
 
   retval = Reflect.defineProperty(window, "nosuchprop5",
                                   { value: 9 });
   is(retval, true,
      "Should be able to Reflect.defineProperty with default configurability");
   desc = Object.getOwnPropertyDescriptor(window, "nosuchprop5");
   is(typeof(desc), "object", "Should have a property 'nosuchprop5' now");
-  todo_is(desc.configurable, true,
-          "Property 'nosuchprop5' should be configurable");
+  is(desc.configurable, true,
+     "Property 'nosuchprop5' should be configurable");
   is(desc.writable, false, "Property 'nosuchprop5' should be readonly");
   is(desc.value, 9, "Property 'nosuchprop5' should have the right value");
 
   retval = Reflect.defineProperty(window, "nosuchprop6",
                                   { value: 10, configurable: true });
   is(retval, true,
      "Should be able to Reflect.defineProperty if configurable");
   desc = Object.getOwnPropertyDescriptor(window, "nosuchprop6");
--- a/testing/web-platform/meta/html/browsers/the-window-object/window-properties.https.html.ini
+++ b/testing/web-platform/meta/html/browsers/the-window-object/window-properties.https.html.ini
@@ -10,8 +10,23 @@
 
   [Window method: print]
     expected:
       if os == "android": FAIL
 
   [Window method: queueMicrotask]
     expected: FAIL
 
+  [Window unforgeable attribute: window]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window unforgeable attribute: document]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window unforgeable attribute: location]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window unforgeable attribute: top]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
--- a/testing/web-platform/meta/html/dom/interfaces.https.html.ini
+++ b/testing/web-platform/meta/html/dom/interfaces.https.html.ini
@@ -356,16 +356,32 @@
   [Window interface: window must inherit property "print()" with the proper type]
     expected:
       if os == "android": FAIL
 
   [Window interface: operation print()]
     expected:
       if os == "android": FAIL
 
+  [Window interface: window must have own property "window"]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window interface: window must have own property "document"]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window interface: window must have own property "location"]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
+  [Window interface: window must have own property "top"]
+    expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510437
+
 [interfaces.https.html?include=HTML.*]
   [HTMLAllCollection must be primary interface of document.all]
     expected: FAIL
 
   [Stringification of document.all]
     expected: FAIL
 
   [HTMLAllCollection interface: document.all must inherit property "length" with the proper type]