Title: [205404] trunk
Revision
205404
Author
[email protected]
Date
2016-09-03 07:44:59 -0700 (Sat, 03 Sep 2016)

Log Message

Object.preventExtensions(window) should throw a TypeError
https://bugs.webkit.org/show_bug.cgi?id=161554

Reviewed by Darin Adler.

Source/WebCore:

Object.preventExtensions(window) should throw a TypeError.

[[PreventExtensions]] should return false for Window:
- https://html.spec.whatwg.org/#windowproxy-preventextensions

EcmaScript says that Object.preventExtensions() should throw a TypeError
if [[PreventExtension]] returns false:
- https://tc39.github.io/ecma262/#sec-object.preventextensions

No new tests, updated existing test.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::preventExtensions):

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205403 => 205404)


--- trunk/LayoutTests/ChangeLog	2016-09-03 14:42:18 UTC (rev 205403)
+++ trunk/LayoutTests/ChangeLog	2016-09-03 14:44:59 UTC (rev 205404)
@@ -1,3 +1,13 @@
+2016-09-03  Chris Dumez  <[email protected]>
+
+        Object.preventExtensions(window) should throw a TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=161554
+
+        Reviewed by Darin Adler.
+
+        * http/tests/security/preventExtensions-window-location-expected.txt:
+        * http/tests/security/preventExtensions-window-location.html:
+
 2016-09-03  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Address ESLint undefined variable errors

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


--- trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2016-09-03 14:42:18 UTC (rev 205403)
+++ trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt	2016-09-03 14:44:59 UTC (rev 205404)
@@ -5,7 +5,7 @@
 
 * Cross origin
 PASS Object.isExtensible(frames[0]) is true
-PASS Object.preventExtensions(frames[0]) 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]) 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..
@@ -13,7 +13,7 @@
 
 * Same origin
 PASS Object.isExtensible(window) is true
-FAIL Object.preventExtensions(window) should throw a TypeError. Did not throw.
+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.

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


--- trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html	2016-09-03 14:42:18 UTC (rev 205403)
+++ trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html	2016-09-03 14:44:59 UTC (rev 205404)
@@ -10,10 +10,11 @@
 _onload_ = function() {
     debug ("* Cross origin");
     shouldBeTrue("Object.isExtensible(frames[0])");
-    shouldThrowErrorName("Object.preventExtensions(frames[0])", "SecurityError");
+    shouldThrowErrorName("Object.preventExtensions(frames[0])", "TypeError");
     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");
     shouldBeTrue("Object.isExtensible(frames[0].location)");
 

Modified: trunk/Source/WebCore/ChangeLog (205403 => 205404)


--- trunk/Source/WebCore/ChangeLog	2016-09-03 14:42:18 UTC (rev 205403)
+++ trunk/Source/WebCore/ChangeLog	2016-09-03 14:44:59 UTC (rev 205404)
@@ -1,5 +1,26 @@
 2016-09-03  Chris Dumez  <[email protected]>
 
+        Object.preventExtensions(window) should throw a TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=161554
+
+        Reviewed by Darin Adler.
+
+        Object.preventExtensions(window) should throw a TypeError.
+
+        [[PreventExtensions]] should return false for Window:
+        - https://html.spec.whatwg.org/#windowproxy-preventextensions
+
+        EcmaScript says that Object.preventExtensions() should throw a TypeError
+        if [[PreventExtension]] returns false:
+        - https://tc39.github.io/ecma262/#sec-object.preventextensions
+
+        No new tests, updated existing test.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::preventExtensions):
+
+2016-09-03  Chris Dumez  <[email protected]>
+
         Align meta element http-equiv="refresh" parsing with the HTML specification
         https://bugs.webkit.org/show_bug.cgi?id=161543
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (205403 => 205404)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-09-03 14:42:18 UTC (rev 205403)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-09-03 14:44:59 UTC (rev 205404)
@@ -342,11 +342,11 @@
     return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
 }
 
-bool JSDOMWindow::preventExtensions(JSObject* object, ExecState* exec)
+bool JSDOMWindow::preventExtensions(JSObject*, ExecState* exec)
 {
-    JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
-    if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), ThrowSecurityError))
-        return false;
+    auto scope = DECLARE_THROW_SCOPE(exec->vm());
+
+    throwTypeError(exec, scope, ASCIILiteral("Cannot prevent extensions on this object"));
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to