Changeset 205404 in webkit


Ignore:
Timestamp:
Sep 3, 2016 7:44:59 AM (8 years ago)
Author:
Chris Dumez
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:

EcmaScript says that Object.preventExtensions() should throw a TypeError
if PreventExtension? returns false:

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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r205402 r205404  
     12016-09-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Object.preventExtensions(window) should throw a TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=161554
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/security/preventExtensions-window-location-expected.txt:
     9        * http/tests/security/preventExtensions-window-location.html:
     10
    1112016-09-03  Joseph Pecoraro  <pecoraro@apple.com>
    212
  • trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt

    r205359 r205404  
    66* Cross origin
    77PASS Object.isExtensible(frames[0]) is true
    8 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..
     8PASS Object.preventExtensions(frames[0]) threw exception TypeError: Cannot prevent extensions on this object.
    99PASS Object.isExtensible(frames[0]) is true
    1010PASS Object.isExtensible(frames[0].location) is true
     
    1414* Same origin
    1515PASS Object.isExtensible(window) is true
    16 FAIL Object.preventExtensions(window) should throw a TypeError. Did not throw.
     16PASS Object.preventExtensions(window) threw exception TypeError: Cannot prevent extensions on this object.
    1717PASS Object.isExtensible(window) is true
    1818PASS Object.isExtensible(window.location) is true
  • trunk/LayoutTests/http/tests/security/preventExtensions-window-location.html

    r205359 r205404  
    1111    debug ("* Cross origin");
    1212    shouldBeTrue("Object.isExtensible(frames[0])");
    13     shouldThrowErrorName("Object.preventExtensions(frames[0])", "SecurityError");
     13    shouldThrowErrorName("Object.preventExtensions(frames[0])", "TypeError");
    1414    shouldBeTrue("Object.isExtensible(frames[0])");
    1515
    1616    shouldBeTrue("Object.isExtensible(frames[0].location)");
     17    // FIXME: Should throw a TypeError once we start throw in the same origin case as well.
    1718    shouldThrowErrorName("Object.preventExtensions(frames[0].location)", "SecurityError");
    1819    shouldBeTrue("Object.isExtensible(frames[0].location)");
  • trunk/Source/WebCore/ChangeLog

    r205400 r205404  
     12016-09-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Object.preventExtensions(window) should throw a TypeError
     4        https://bugs.webkit.org/show_bug.cgi?id=161554
     5
     6        Reviewed by Darin Adler.
     7
     8        Object.preventExtensions(window) should throw a TypeError.
     9
     10        [[PreventExtensions]] should return false for Window:
     11        - https://html.spec.whatwg.org/#windowproxy-preventextensions
     12
     13        EcmaScript says that Object.preventExtensions() should throw a TypeError
     14        if [[PreventExtension]] returns false:
     15        - https://tc39.github.io/ecma262/#sec-object.preventextensions
     16
     17        No new tests, updated existing test.
     18
     19        * bindings/js/JSDOMWindowCustom.cpp:
     20        (WebCore::JSDOMWindow::preventExtensions):
     21
    1222016-09-03  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r205372 r205404  
    343343}
    344344
    345 bool JSDOMWindow::preventExtensions(JSObject* object, ExecState* exec)
    346 {
    347     JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
    348     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), ThrowSecurityError))
    349         return false;
     345bool JSDOMWindow::preventExtensions(JSObject*, ExecState* exec)
     346{
     347    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     348
     349    throwTypeError(exec, scope, ASCIILiteral("Cannot prevent extensions on this object"));
    350350    return false;
    351351}
Note: See TracChangeset for help on using the changeset viewer.