Title: [211778] trunk
Revision
211778
Author
cdu...@apple.com
Date
2017-02-07 00:51:09 -0800 (Tue, 07 Feb 2017)

Log Message

Object.preventExtensions() on a Location object should throw a TypeError
https://bugs.webkit.org/show_bug.cgi?id=167917

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline web platform test now that one more check is passing.

* web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:

Source/WebCore:

Object.preventExtensions() on a Location object should throw a TypeError:
- https://html.spec.whatwg.org/#location-preventextensions
- https://www.ecma-international.org/ecma-262/7.0/index.html#sec-object.preventextensions

Firefox already implements this.

No new tests, rebaselined existing tests.

* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::preventExtensions):

LayoutTests:

Rebaseline test now that more checks are passing.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211777 => 211778)


--- trunk/LayoutTests/ChangeLog	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/LayoutTests/ChangeLog	2017-02-07 08:51:09 UTC (rev 211778)
@@ -1,3 +1,15 @@
+2017-02-07  Chris Dumez  <cdu...@apple.com>
+
+        Object.preventExtensions() on a Location object should throw a TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=167917
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline test now that more checks are passing.
+
+        * http/tests/security/preventExtensions-window-location-expected.txt:
+        * http/tests/security/preventExtensions-window-location.html:
+
 2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
 
         Web Inspector: allow import() inside the inspector

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


--- trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2017-02-07 08:51:09 UTC (rev 211778)
@@ -8,7 +8,7 @@
 PASS Object.preventExtensions(frames[0]) threw exception TypeError: Cannot prevent extensions on this object.
 PASS Object.isExtensible(frames[0]) is true
 PASS Object.isExtensible(frames[0].location) is true
-PASS Object.preventExtensions(frames[0].location) threw exception SecurityError (DOM Exception 18): Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match..
+PASS Object.preventExtensions(frames[0].location) threw exception TypeError: Cannot prevent extensions on this object.
 PASS Object.isExtensible(frames[0].location) is true
 
 * Same origin
@@ -16,8 +16,8 @@
 PASS Object.preventExtensions(window) threw exception TypeError: Cannot prevent extensions on this object.
 PASS Object.isExtensible(window) is true
 PASS Object.isExtensible(window.location) is true
-FAIL Object.preventExtensions(window.location) should throw a TypeError. Did not throw.
-FAIL Object.isExtensible(window.location) should be true. Was false.
+PASS Object.preventExtensions(window.location) threw exception TypeError: Cannot prevent extensions on this object.
+PASS Object.isExtensible(window.location) is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html (211777 => 211778)


--- trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html	2017-02-07 08:51:09 UTC (rev 211778)
@@ -14,8 +14,7 @@
     shouldBeTrue("Object.isExtensible(frames[0])");
 
     shouldBeTrue("Object.isExtensible(frames[0].location)");
-    // FIXME: Should throw a TypeError once we start throw in the same origin case as well.
-    shouldThrowErrorName("Object.preventExtensions(frames[0].location)", "SecurityError");
+    shouldThrowErrorName("Object.preventExtensions(frames[0].location)", "TypeError");
     shouldBeTrue("Object.isExtensible(frames[0].location)");
 
     debug("");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (211777 => 211778)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-07 08:51:09 UTC (rev 211778)
@@ -1,3 +1,14 @@
+2017-02-07  Chris Dumez  <cdu...@apple.com>
+
+        Object.preventExtensions() on a Location object should throw a TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=167917
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline web platform test now that one more check is passing.
+
+        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:
+
 2017-02-06  Chris Dumez  <cdu...@apple.com>
 
         Symbols exposed on cross-origin Window / Location objects should be configurable

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt	2017-02-07 08:51:09 UTC (rev 211778)
@@ -12,7 +12,7 @@
 PASS [[IsExtensible]] should return true for cross-origin objects 
 PASS [[IsExtensible]] should return true for cross-origin objects (exception type) 
 PASS [[PreventExtensions]] should throw for cross-origin objects 
-FAIL [[PreventExtensions]] should throw for cross-origin objects (exception type) assert_throws: preventExtensions on cross-origin Location should throw function "function () { Object.preventExtensions(C.location) }" threw object "SecurityError (DOM Exception 18): Blocked a frame with or..." ("SecurityError") expected object "TypeError" ("TypeError")
+PASS [[PreventExtensions]] should throw for cross-origin objects (exception type) 
 PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| 
 PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (exception type) 
 PASS [[GetOwnProperty]] - Property descriptors for cross-origin properties should be set up correctly 

Modified: trunk/Source/WebCore/ChangeLog (211777 => 211778)


--- trunk/Source/WebCore/ChangeLog	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/Source/WebCore/ChangeLog	2017-02-07 08:51:09 UTC (rev 211778)
@@ -1,3 +1,21 @@
+2017-02-07  Chris Dumez  <cdu...@apple.com>
+
+        Object.preventExtensions() on a Location object should throw a TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=167917
+
+        Reviewed by Alex Christensen.
+
+        Object.preventExtensions() on a Location object should throw a TypeError:
+        - https://html.spec.whatwg.org/#location-preventextensions
+        - https://www.ecma-international.org/ecma-262/7.0/index.html#sec-object.preventextensions
+
+        Firefox already implements this.
+
+        No new tests, rebaselined existing tests.
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::preventExtensions):
+
 2017-02-07  Yusuke Suzuki  <utatane....@gmail.com>
 
         Web Inspector: allow import() inside the inspector

Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (211777 => 211778)


--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2017-02-07 08:17:17 UTC (rev 211777)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2017-02-07 08:51:09 UTC (rev 211778)
@@ -181,14 +181,12 @@
     return Base::getPrototype(object, exec);
 }
 
-bool JSLocation::preventExtensions(JSObject* object, ExecState* exec)
+bool JSLocation::preventExtensions(JSObject*, ExecState* exec)
 {
-    JSLocation* thisObject = jsCast<JSLocation*>(object);
-    if (!BindingSecurity::shouldAllowAccessToFrame(exec, thisObject->wrapped().frame(), ThrowSecurityError))
-        return false;
-    // FIXME: The specification says to return false in the same origin case as well but other browsers have
-    // not implemented this yet.
-    return Base::preventExtensions(object, exec);
+    auto scope = DECLARE_THROW_SCOPE(exec->vm());
+
+    throwTypeError(exec, scope, ASCIILiteral("Cannot prevent extensions on this object"));
+    return false;
 }
 
 String JSLocation::toStringName(const JSObject* object, ExecState* exec)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to