Changeset 202832 in webkit


Ignore:
Timestamp:
Jul 5, 2016 2:08:38 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC] The prototype cycle checks throws the wrong error type
https://bugs.webkit.org/show_bug.cgi?id=159393

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-07-05
Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

We were supposed to throw the TypeError:
-https://tc39.github.io/ecma262/#sec-set-object.prototype.__proto

  • runtime/JSObject.cpp:

(JSC::JSObject::setPrototypeWithCycleCheck):

LayoutTests:

  • js/cyclic-prototypes-expected.txt:
  • js/script-tests/cyclic-prototypes.js:

(catch):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202829 r202832  
     12016-07-05  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] The prototype cycle checks throws the wrong error type
     4        https://bugs.webkit.org/show_bug.cgi?id=159393
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/cyclic-prototypes-expected.txt:
     9        * js/script-tests/cyclic-prototypes.js:
     10        (catch):
     11
    1122016-07-05  Jer Noble  <jer.noble@apple.com>
    213
  • trunk/LayoutTests/fast/dom/Window/script-tests/window-custom-prototype.js

    r108259 r202832  
    55var anotherObject = { };
    66
    7 shouldThrow("__proto__ = window; __proto", "'Error: cyclic __proto__ value'");
    8 shouldThrow("__proto__ = chainPointingBackToWindow; __proto__", "'Error: cyclic __proto__ value'");
     7shouldThrow("__proto__ = window; __proto", "'TypeError: cyclic __proto__ value'");
     8shouldThrow("__proto__ = chainPointingBackToWindow; __proto__", "'TypeError: cyclic __proto__ value'");
    99shouldBe("__proto__ = 1; __proto__", "originalWindowPrototype");
    1010shouldBe("__proto__ = 'a string'; __proto__", "originalWindowPrototype");
    1111shouldBe("__proto__ = anotherObject; __proto__", "anotherObject");
    12 shouldThrow("anotherObject.__proto__ = window; __proto__", "'Error: cyclic __proto__ value'");
     12shouldThrow("anotherObject.__proto__ = window; __proto__", "'TypeError: cyclic __proto__ value'");
    1313shouldBe("__proto__ = 1; __proto__", "anotherObject");
    1414shouldBe("__proto__ = 'a string'; __proto__", "anotherObject");
  • trunk/LayoutTests/fast/dom/Window/window-custom-prototype-expected.txt

    r108259 r202832  
    44
    55
    6 PASS __proto__ = window; __proto threw exception Error: cyclic __proto__ value.
    7 PASS __proto__ = chainPointingBackToWindow; __proto__ threw exception Error: cyclic __proto__ value.
     6PASS __proto__ = window; __proto threw exception TypeError: cyclic __proto__ value.
     7PASS __proto__ = chainPointingBackToWindow; __proto__ threw exception TypeError: cyclic __proto__ value.
    88PASS __proto__ = 1; __proto__ is originalWindowPrototype
    99PASS __proto__ = 'a string'; __proto__ is originalWindowPrototype
    1010PASS __proto__ = anotherObject; __proto__ is anotherObject
    11 PASS anotherObject.__proto__ = window; __proto__ threw exception Error: cyclic __proto__ value.
     11PASS anotherObject.__proto__ = window; __proto__ threw exception TypeError: cyclic __proto__ value.
    1212PASS __proto__ = 1; __proto__ is anotherObject
    1313PASS __proto__ = 'a string'; __proto__ is anotherObject
  • trunk/LayoutTests/js/cyclic-prototypes-expected.txt

    r184642 r202832  
    44
    55
    6 PASS o1.__proto__ = o3; threw exception Error: cyclic __proto__ value.
    7 PASS Object.setPrototypeOf(o1, o3) threw exception Error: cyclic __proto__ value.
     6PASS o1.__proto__ = o3; threw exception TypeError: cyclic __proto__ value.
     7PASS Object.setPrototypeOf(o1, o3) threw exception TypeError: cyclic __proto__ value.
     8PASS globalException.constructor is TypeError
     9PASS globalException.constructor is TypeError
    810PASS ({}).hasOwnProperty.call(o1, '__proto__') is false
    911PASS ({}).hasOwnProperty.call(o1, '__proto__') is true
    1012PASS Object.getPrototypeOf(o1) is null
    11 PASS Object.setPrototypeOf(o1, o3) threw exception Error: cyclic __proto__ value.
     13PASS Object.setPrototypeOf(o1, o3) threw exception TypeError: cyclic __proto__ value.
    1214PASS successfullyParsed is true
    1315
  • trunk/LayoutTests/js/dom/cyclic-proto-expected.txt

    r156066 r202832  
    44
    55
    6 PASS x.__proto__ = x; threw exception Error: cyclic __proto__ value.
     6PASS x.__proto__ = x; threw exception TypeError: cyclic __proto__ value.
    77PASS x.__proto__ is originalProto
    88PASS successfullyParsed is true
  • trunk/LayoutTests/js/script-tests/cyclic-prototypes.js

    r184642 r202832  
    88
    99// Try to create a cyclical prototype chain.
    10 shouldThrow("o1.__proto__ = o3;");
    11 shouldThrow("Object.setPrototypeOf(o1, o3)");
     10shouldThrow("o1.__proto__ = o3;", "'TypeError: cyclic __proto__ value'");
     11shouldThrow("Object.setPrototypeOf(o1, o3)", "'TypeError: cyclic __proto__ value'");
     12var globalException;
     13try {
     14    o1.__proto__ = o3;
     15} catch (e) {
     16    globalException = e;
     17}
     18shouldBe("globalException.constructor", "TypeError");
     19
     20globalException = undefined;
     21try {
     22    Object.setPrototypeOf(o1, o3);
     23} catch (e) {
     24    globalException = e;
     25}
     26shouldBe("globalException.constructor", "TypeError");
    1227
    1328// This changes __proto__ setter behaviour, since __proto__ is an accessor on Object.prototype.
  • trunk/Source/JavaScriptCore/ChangeLog

    r202828 r202832  
     12016-07-05  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC] The prototype cycle checks throws the wrong error type
     4        https://bugs.webkit.org/show_bug.cgi?id=159393
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        We were supposed to throw the TypeError:
     9        -https://tc39.github.io/ecma262/#sec-set-object.prototype.__proto__
     10
     11        * runtime/JSObject.cpp:
     12        (JSC::JSObject::setPrototypeWithCycleCheck):
     13
    1142016-07-05  Saam Barati  <sbarati@apple.com>
    215
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r202125 r202832  
    13671367        if (nextPrototype == this) {
    13681368            if (shouldThrowIfCantSet)
    1369                 vm.throwException(exec, createError(exec, ASCIILiteral("cyclic __proto__ value")));
     1369                throwTypeError(exec, ASCIILiteral("cyclic __proto__ value"));
    13701370            return false;
    13711371        }
Note: See TracChangeset for help on using the changeset viewer.