Changeset 270702 in webkit


Ignore:
Timestamp:
Dec 11, 2020 12:39:38 PM (20 months ago)
Author:
Alexey Shvayka
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:
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270699 r270702  
     12020-12-11  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Reflect.preventExtensions should not throw if called on WindowProxy or Location
     4        https://bugs.webkit.org/show_bug.cgi?id=219270
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/security/preventExtensions-window-location-expected.txt:
     9
    1102020-12-11  Fujii Hironori  <Hironori.Fujii@sony.com>
    211
  • trunk/LayoutTests/http/tests/security/preventExtensions-window-location-expected.txt

    r211778 r270702  
    66* Cross origin
    77PASS Object.isExtensible(frames[0]) is true
    8 PASS Object.preventExtensions(frames[0]) threw exception TypeError: Cannot prevent extensions on this object.
     8PASS Object.preventExtensions(frames[0]) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
    99PASS Object.isExtensible(frames[0]) is true
    1010PASS Object.isExtensible(frames[0].location) is true
    11 PASS Object.preventExtensions(frames[0].location) threw exception TypeError: Cannot prevent extensions on this object.
     11PASS Object.preventExtensions(frames[0].location) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
    1212PASS Object.isExtensible(frames[0].location) is true
    1313
    1414* Same origin
    1515PASS Object.isExtensible(window) is true
    16 PASS Object.preventExtensions(window) threw exception TypeError: Cannot prevent extensions on this object.
     16PASS Object.preventExtensions(window) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
    1717PASS Object.isExtensible(window) is true
    1818PASS Object.isExtensible(window.location) is true
    19 PASS Object.preventExtensions(window.location) threw exception TypeError: Cannot prevent extensions on this object.
     19PASS Object.preventExtensions(window.location) threw exception TypeError: Unable to prevent extension in Object.preventExtensions.
    2020PASS Object.isExtensible(window.location) is true
    2121PASS successfullyParsed is true
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r270617 r270702  
     12020-12-11  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Reflect.preventExtensions should not throw if called on WindowProxy or Location
     4        https://bugs.webkit.org/show_bug.cgi?id=219270
     5
     6        Reviewed by Darin Adler.
     7
     8        * web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions-expected.txt: Added.
     9        * web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html: Added.
     10        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:
     11        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html:
     12        * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions-expected.txt: Added.
     13        * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html: Added.
     14
    1152020-12-09  Sergio Villar Senin  <svillar@igalia.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt

    r269451 r270702  
    6161PASS [[IsExtensible]] should return true for cross-origin objects (same-origin + document.domain)
    6262PASS [[IsExtensible]] should return true for cross-origin objects (cross-site)
    63 PASS [[PreventExtensions]] should throw for cross-origin objects (cross-origin)
    64 PASS [[PreventExtensions]] should throw for cross-origin objects (same-origin + document.domain)
    65 PASS [[PreventExtensions]] should throw for cross-origin objects (cross-site)
     63PASS [[PreventExtensions]] should return false cross-origin objects (cross-origin)
     64PASS [[PreventExtensions]] should return false cross-origin objects (same-origin + document.domain)
     65PASS [[PreventExtensions]] should return false cross-origin objects (cross-site)
    6666PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (cross-origin)
    6767PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (same-origin + document.domain)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html

    r269451 r270702  
    380380  assert_throws_js(TypeError, function() { Object.preventExtensions(win.location) },
    381381                   "preventExtensions on cross-origin Location should throw");
    382 }, "[[PreventExtensions]] should throw for cross-origin objects");
     382  assert_false(Reflect.preventExtensions(win),
     383              "Reflect.preventExtensions on cross-origin Window");
     384  assert_false(Reflect.preventExtensions(win.location),
     385              "Reflect.preventExtensions on cross-origin Location");
     386}, "[[PreventExtensions]] should return false cross-origin objects");
    383387
    384388/*
  • trunk/Source/WebCore/ChangeLog

    r270699 r270702  
     12020-12-11  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Reflect.preventExtensions should not throw if called on WindowProxy or Location
     4        https://bugs.webkit.org/show_bug.cgi?id=219270
     5
     6        Reviewed by Darin Adler.
     7
     8        Since r254626 fixed Object.preventExtensions to throw a TypeError on
     9        `false` result, this patch makes [[PreventExtensions]] overrides pure,
     10        aligning Reflect.preventExtensions behavior with the spec [1], Gecko,
     11        and (only for WindowProxy [2]) Blink.
     12
     13        [1]: https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
     14        [2]: https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-preventextensions
     15
     16        Tests: imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prevent-extensions.html
     17               imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html
     18               imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html
     19
     20        * bindings/js/JSDOMWindowCustom.cpp:
     21        (WebCore::JSDOMWindow::preventExtensions):
     22        * bindings/js/JSLocationCustom.cpp:
     23        (WebCore::JSLocation::preventExtensions):
     24        * bindings/js/JSRemoteDOMWindowCustom.cpp:
     25        (WebCore::JSRemoteDOMWindow::preventExtensions):
     26
    1272020-12-11  Fujii Hironori  <Hironori.Fujii@sony.com>
    228
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r268990 r270702  
    496496}
    497497
    498 bool JSDOMWindow::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
    499 {
    500     auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
    501 
    502     throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
     498bool JSDOMWindow::preventExtensions(JSObject*, JSGlobalObject*)
     499{
    503500    return false;
    504501}
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r268551 r270702  
    221221}
    222222
    223 bool JSLocation::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
    224 {
    225     auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
    226 
    227     throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
     223bool JSLocation::preventExtensions(JSObject*, JSGlobalObject*)
     224{
    228225    return false;
    229226}
  • trunk/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp

    r257399 r270702  
    123123}
    124124
    125 bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject* lexicalGlobalObject)
     125bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject*)
    126126{
    127     auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
    128     throwTypeError(lexicalGlobalObject, scope, "Cannot prevent extensions on this object"_s);
    129127    return false;
    130128}
Note: See TracChangeset for help on using the changeset viewer.