Title: [270702] trunk
Revision
270702
Author
[email protected]
Date
2020-12-11 12:39:38 -0800 (Fri, 11 Dec 2020)

Log Message

Reflect.preventExtensions should not throw if called on WindowProxy or Location
https://bugs.webkit.org/show_bug.cgi?id=219270

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt: Added.
* web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html: Added.
* web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:
* web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html:
* web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt: Added.
* web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html: Added.

Source/WebCore:

Since r254626 fixed Object.preventExtensions to throw a TypeError on
`false` result, this patch makes [[PreventExtensions]] overrides pure,
aligning Reflect.preventExtensions behavior with the spec [1], Gecko,
and (only for WindowProxy [2]) Blink.

[1]: https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
[2]: https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-preventextensions

Tests: imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html
       imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
       imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::preventExtensions):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::preventExtensions):
* bindings/js/JSRemoteDOMWindowCustom.cpp:
(WebCore::JSRemoteDOMWindow::preventExtensions):

LayoutTests:

* http/tests/security/preventExtensions-window-location-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (270701 => 270702)


--- trunk/LayoutTests/ChangeLog	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/LayoutTests/ChangeLog	2020-12-11 20:39:38 UTC (rev 270702)
@@ -1,3 +1,12 @@
+2020-12-11  Alexey Shvayka  <[email protected]>
+
+        Reflect.preventExtensions should not throw if called on WindowProxy or Location
+        https://bugs.webkit.org/show_bug.cgi?id=219270
+
+        Reviewed by Darin Adler.
+
+        * http/tests/security/preventExtensions-window-location-expected.txt:
+
 2020-12-11  Fujii Hironori  <[email protected]>
 
         [WinCairo] Enable accelerated WebGL canvas

Modified: trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt (270701 => 270702)


--- trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2020-12-11 20:39:38 UTC (rev 270702)
@@ -5,18 +5,18 @@
 
 * Cross origin
 PASS Object.isExtensible(frames[0]) is true
-PASS Object.preventExtensions(frames[0]) threw exception TypeError: Cannot prevent extensions on this object.
+PASS Object.preventExtensions(frames[0]) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
 PASS Object.isExtensible(frames[0]) is true
 PASS Object.isExtensible(frames[0].location) is true
-PASS Object.preventExtensions(frames[0].location) threw exception TypeError: Cannot prevent extensions on this object.
+PASS Object.preventExtensions(frames[0].location) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
 PASS Object.isExtensible(frames[0].location) is true
 
 * Same origin
 PASS Object.isExtensible(window) is true
-PASS Object.preventExtensions(window) threw exception TypeError: Cannot prevent extensions on this object.
+PASS Object.preventExtensions(window) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
 PASS Object.isExtensible(window) is true
 PASS Object.isExtensible(window.location) is true
-PASS Object.preventExtensions(window.location) threw exception TypeError: Cannot prevent extensions on this object.
+PASS Object.preventExtensions(window.location) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
 PASS Object.isExtensible(window.location) is true
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (270701 => 270702)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-12-11 20:39:38 UTC (rev 270702)
@@ -1,3 +1,17 @@
+2020-12-11  Alexey Shvayka  <[email protected]>
+
+        Reflect.preventExtensions should not throw if called on WindowProxy or Location
+        https://bugs.webkit.org/show_bug.cgi?id=219270
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt: Added.
+        * web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html: Added.
+        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:
+        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html:
+        * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt: Added.
+        * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html: Added.
+
 2020-12-09  Sergio Villar Senin  <[email protected]>
 
         [css-flex] RenderFlexibleBox::computeMainSizeFromAspectRatioUsing() must obbey box-sizing

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt (0 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt	2020-12-11 20:39:38 UTC (rev 270702)
@@ -0,0 +1,4 @@
+
+PASS Object.preventExtensions throws a TypeError
+PASS Reflect.preventExtensions returns false
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html (0 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html	2020-12-11 20:39:38 UTC (rev 270702)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>[[PreventExtensions]] on a Location object should return false</title>
+<link rel="help" href=""
+
+<script src=""
+<script src=""
+
+<script>
+"use strict";
+
+test(() => {
+  assert_throws_js(TypeError, () => {
+    Object.preventExtensions(location);
+  });
+}, "Object.preventExtensions throws a TypeError");
+
+test(() => {
+  assert_false(Reflect.preventExtensions(location));
+}, "Reflect.preventExtensions returns false");
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt (270701 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt	2020-12-11 20:39:38 UTC (rev 270702)
@@ -60,9 +60,9 @@
 PASS [[IsExtensible]] should return true for cross-origin objects (cross-origin)
 PASS [[IsExtensible]] should return true for cross-origin objects (same-origin + document.domain)
 PASS [[IsExtensible]] should return true for cross-origin objects (cross-site)
-PASS [[PreventExtensions]] should throw for cross-origin objects (cross-origin)
-PASS [[PreventExtensions]] should throw for cross-origin objects (same-origin + document.domain)
-PASS [[PreventExtensions]] should throw for cross-origin objects (cross-site)
+PASS [[PreventExtensions]] should return false cross-origin objects (cross-origin)
+PASS [[PreventExtensions]] should return false cross-origin objects (same-origin + document.domain)
+PASS [[PreventExtensions]] should return false cross-origin objects (cross-site)
 PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (cross-origin)
 PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (same-origin + document.domain)
 PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (cross-site)

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html (270701 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html	2020-12-11 20:39:38 UTC (rev 270702)
@@ -379,7 +379,11 @@
                    "preventExtensions on cross-origin Window should throw");
   assert_throws_js(TypeError, function() { Object.preventExtensions(win.location) },
                    "preventExtensions on cross-origin Location should throw");
-}, "[[PreventExtensions]] should throw for cross-origin objects");
+  assert_false(Reflect.preventExtensions(win),
+              "Reflect.preventExtensions on cross-origin Window");
+  assert_false(Reflect.preventExtensions(win.location),
+              "Reflect.preventExtensions on cross-origin Location");
+}, "[[PreventExtensions]] should return false cross-origin objects");
 
 /*
  * [[GetOwnProperty]]

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt (0 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt	2020-12-11 20:39:38 UTC (rev 270702)
@@ -0,0 +1,4 @@
+
+PASS Object.preventExtensions throws a TypeError
+PASS Reflect.preventExtensions returns false
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html (0 => 270702)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html	2020-12-11 20:39:38 UTC (rev 270702)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>[[PreventExtensions]] on a WindowProxy object should return false</title>
+<link rel="help" href=""
+
+<script src=""
+<script src=""
+
+<script>
+"use strict";
+
+test(() => {
+  assert_throws_js(TypeError, () => {
+    Object.preventExtensions(window);
+  });
+}, "Object.preventExtensions throws a TypeError");
+
+test(() => {
+  assert_false(Reflect.preventExtensions(window));
+}, "Reflect.preventExtensions returns false");
+</script>

Modified: trunk/Source/WebCore/ChangeLog (270701 => 270702)


--- trunk/Source/WebCore/ChangeLog	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/Source/WebCore/ChangeLog	2020-12-11 20:39:38 UTC (rev 270702)
@@ -1,3 +1,29 @@
+2020-12-11  Alexey Shvayka  <[email protected]>
+
+        Reflect.preventExtensions should not throw if called on WindowProxy or Location
+        https://bugs.webkit.org/show_bug.cgi?id=219270
+
+        Reviewed by Darin Adler.
+
+        Since r254626 fixed Object.preventExtensions to throw a TypeError on
+        `false` result, this patch makes [[PreventExtensions]] overrides pure,
+        aligning Reflect.preventExtensions behavior with the spec [1], Gecko,
+        and (only for WindowProxy [2]) Blink.
+
+        [1]: https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
+        [2]: https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-preventextensions
+
+        Tests: imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html
+               imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
+               imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::preventExtensions):
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::preventExtensions):
+        * bindings/js/JSRemoteDOMWindowCustom.cpp:
+        (WebCore::JSRemoteDOMWindow::preventExtensions):
+
 2020-12-11  Fujii Hironori  <[email protected]>
 
         [WinCairo] Enable accelerated WebGL canvas

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (270701 => 270702)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2020-12-11 20:39:38 UTC (rev 270702)
@@ -495,11 +495,8 @@
     return Base::getPrototype(object, lexicalGlobalObject);
 }
 
-bool JSDOMWindow::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
+bool JSDOMWindow::preventExtensions(JSObject*, JSGlobalObject*)
 {
-    auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
-
-    throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
     return false;
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (270701 => 270702)


--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2020-12-11 20:39:38 UTC (rev 270702)
@@ -220,11 +220,8 @@
     return Base::getPrototype(object, lexicalGlobalObject);
 }
 
-bool JSLocation::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
+bool JSLocation::preventExtensions(JSObject*, JSGlobalObject*)
 {
-    auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
-
-    throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
     return false;
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp (270701 => 270702)


--- trunk/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp	2020-12-11 20:21:52 UTC (rev 270701)
+++ trunk/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp	2020-12-11 20:39:38 UTC (rev 270702)
@@ -122,10 +122,8 @@
     return jsNull();
 }
 
-bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
+bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject*)
 {
-    auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
-    throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to