Changeset 196986 in webkit


Ignore:
Timestamp:
Feb 23, 2016 11:41:56 AM (8 years ago)
Author:
mark.lam@apple.com
Message:

Debug assertion failure while loading http://kangax.github.io/compat-table/es6/.
https://bugs.webkit.org/show_bug.cgi?id=154542

Reviewed by Saam Barati.

Source/JavaScriptCore:

According to the spec, the constructors of the following types "are not intended
to be called as a function and will throw an exception". These types are:

TypedArrays - https://tc39.github.io/ecma262/#sec-typedarray-constructors
Map - https://tc39.github.io/ecma262/#sec-map-constructor
Set - https://tc39.github.io/ecma262/#sec-set-constructor
WeakMap - https://tc39.github.io/ecma262/#sec-weakmap-constructor
WeakSet - https://tc39.github.io/ecma262/#sec-weakset-constructor
ArrayBuffer - https://tc39.github.io/ecma262/#sec-arraybuffer-constructor
DataView - https://tc39.github.io/ecma262/#sec-dataview-constructor
Promise - https://tc39.github.io/ecma262/#sec-promise-constructor
Proxy - https://tc39.github.io/ecma262/#sec-proxy-constructor

This patch does the foillowing:

  1. Ensures that these constructors can be called but will throw a TypeError when called.
  2. Makes all these objects use throwConstructorCannotBeCalledAsFunctionTypeError() in their implementation to be consistent.
  3. Change the error message to "calling XXX constructor without new is invalid". This is clearer because the error is likely due to the user forgetting to use the new operator on these constructors.
  • runtime/Error.h:
  • runtime/Error.cpp:

(JSC::throwConstructorCannotBeCalledAsFunctionTypeError):

  • Added a convenience function to throw the TypeError.
  • runtime/JSArrayBufferConstructor.cpp:

(JSC::constructArrayBuffer):
(JSC::callArrayBuffer):
(JSC::JSArrayBufferConstructor::getCallData):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::callGenericTypedArrayView):
(JSC::JSGenericTypedArrayViewConstructor<ViewClass>::getCallData):

  • runtime/JSPromiseConstructor.cpp:

(JSC::callPromise):

  • runtime/MapConstructor.cpp:

(JSC::callMap):

  • runtime/ProxyConstructor.cpp:

(JSC::callProxy):
(JSC::ProxyConstructor::getCallData):

  • runtime/SetConstructor.cpp:

(JSC::callSet):

  • runtime/WeakMapConstructor.cpp:

(JSC::callWeakMap):

  • runtime/WeakSetConstructor.cpp:

(JSC::callWeakSet):

  • tests/es6.yaml:
  • The typed_arrays_%TypedArray%[Symbol.species].js test now passes.
  • tests/stress/call-non-calleable-constructors-as-function.js: Added.

(test):

  • tests/stress/map-constructor.js:

(testCallTypeError):

  • tests/stress/promise-cannot-be-called.js:

(shouldThrow):

  • tests/stress/proxy-basic.js:
  • tests/stress/set-constructor.js:
  • tests/stress/throw-from-ftl-call-ic-slow-path-cells.js:

(i.catch):

  • tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js:

(i.catch):

  • tests/stress/throw-from-ftl-call-ic-slow-path.js:

(i.catch):

  • tests/stress/weak-map-constructor.js:

(testCallTypeError):

  • tests/stress/weak-set-constructor.js:
  • Updated error message string.

LayoutTests:

  • js/Promise-types-expected.txt:
  • js/basic-map-expected.txt:
  • js/basic-set-expected.txt:
  • js/dom/basic-weakmap-expected.txt:
  • js/dom/basic-weakset-expected.txt:
  • js/script-tests/Promise-types.js:
  • js/typedarray-constructors-expected.txt:
  • Updated error message string.
Location:
trunk
Files:
1 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196978 r196986  
     12016-02-23  Mark Lam  <mark.lam@apple.com>
     2
     3        Debug assertion failure while loading http://kangax.github.io/compat-table/es6/.
     4        https://bugs.webkit.org/show_bug.cgi?id=154542
     5
     6        Reviewed by Saam Barati.
     7
     8        * js/Promise-types-expected.txt:
     9        * js/basic-map-expected.txt:
     10        * js/basic-set-expected.txt:
     11        * js/dom/basic-weakmap-expected.txt:
     12        * js/dom/basic-weakset-expected.txt:
     13        * js/script-tests/Promise-types.js:
     14        * js/typedarray-constructors-expected.txt:
     15        - Updated error message string.
     16
    1172016-02-23  Manuel Rego Casasnovas  <rego@igalia.com>
    218
  • trunk/LayoutTests/js/Promise-types-expected.txt

    r191276 r196986  
    1717PASS aPromise.catch.length is 1
    1818aPromise2 = Promise(...)
    19 PASS Promise(function(resolve, reject) { resolve(1); }) threw exception TypeError: Type error.
     19PASS Promise(function(resolve, reject) { resolve(1); }) threw exception TypeError: calling Promise constructor without new is invalid.
    2020
    2121Promise constructor
     
    2323PASS Promise.length is 1
    2424PASS new Promise() threw exception TypeError: Promise constructor takes a function argument.
    25 PASS Promise() threw exception TypeError: Type error.
     25PASS Promise() threw exception TypeError: calling Promise constructor without new is invalid.
    2626PASS new Promise(1) threw exception TypeError: Promise constructor takes a function argument.
    2727PASS new Promise('hello') threw exception TypeError: Promise constructor takes a function argument.
     
    3030PASS new Promise(null) threw exception TypeError: Promise constructor takes a function argument.
    3131PASS new Promise(undefined) threw exception TypeError: Promise constructor takes a function argument.
    32 PASS Promise(1) threw exception TypeError: Type error.
    33 PASS Promise('hello') threw exception TypeError: Type error.
    34 PASS Promise([]) threw exception TypeError: Type error.
    35 PASS Promise({}) threw exception TypeError: Type error.
    36 PASS Promise(null) threw exception TypeError: Type error.
    37 PASS Promise(undefined) threw exception TypeError: Type error.
     32PASS Promise(1) threw exception TypeError: calling Promise constructor without new is invalid.
     33PASS Promise('hello') threw exception TypeError: calling Promise constructor without new is invalid.
     34PASS Promise([]) threw exception TypeError: calling Promise constructor without new is invalid.
     35PASS Promise({}) threw exception TypeError: calling Promise constructor without new is invalid.
     36PASS Promise(null) threw exception TypeError: calling Promise constructor without new is invalid.
     37PASS Promise(undefined) threw exception TypeError: calling Promise constructor without new is invalid.
    3838
    3939Promise statics
  • trunk/LayoutTests/js/basic-map-expected.txt

    r181556 r196986  
    1111PASS new Map(undefined, undefined) instanceof Map is true
    1212PASS new Map(null, undefined) instanceof Map is true
    13 PASS Map() threw exception TypeError: Map cannot be called as a function.
    14 PASS Map(1) threw exception TypeError: Map cannot be called as a function.
    15 PASS Map(true) threw exception TypeError: Map cannot be called as a function.
    16 PASS Map('String') threw exception TypeError: Map cannot be called as a function.
    17 PASS Map([]) threw exception TypeError: Map cannot be called as a function.
    18 PASS Map({}) threw exception TypeError: Map cannot be called as a function.
    19 PASS Map(undefined) threw exception TypeError: Map cannot be called as a function.
    20 PASS Map(null) threw exception TypeError: Map cannot be called as a function.
     13PASS Map() threw exception TypeError: calling Map constructor without new is invalid.
     14PASS Map(1) threw exception TypeError: calling Map constructor without new is invalid.
     15PASS Map(true) threw exception TypeError: calling Map constructor without new is invalid.
     16PASS Map('String') threw exception TypeError: calling Map constructor without new is invalid.
     17PASS Map([]) threw exception TypeError: calling Map constructor without new is invalid.
     18PASS Map({}) threw exception TypeError: calling Map constructor without new is invalid.
     19PASS Map(undefined) threw exception TypeError: calling Map constructor without new is invalid.
     20PASS Map(null) threw exception TypeError: calling Map constructor without new is invalid.
    2121PASS new Map(1) threw exception TypeError: Type error.
    2222PASS new Map(true) threw exception TypeError: Type error.
  • trunk/LayoutTests/js/basic-set-expected.txt

    r181556 r196986  
    66PASS Set instanceof Set is false
    77PASS Set.prototype instanceof Set is false
    8 PASS Set() instanceof Set threw exception TypeError: Set cannot be called as a function.
     8PASS Set() instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
    99PASS new Set() instanceof Set is true
    10 PASS Set(null) instanceof Set threw exception TypeError: Set cannot be called as a function.
    11 PASS Set(undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
    12 PASS Set(undefined, undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
    13 PASS Set(null, undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
     10PASS Set(null) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
     11PASS Set(undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
     12PASS Set(undefined, undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
     13PASS Set(null, undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
    1414PASS new Set(null) instanceof Set is true
    1515PASS new Set(undefined) instanceof Set is true
    1616PASS new Set(undefined, undefined) instanceof Set is true
    1717PASS new Set(null, undefined) instanceof Set is true
    18 PASS Set(1) threw exception TypeError: Set cannot be called as a function.
    19 PASS Set(true) threw exception TypeError: Set cannot be called as a function.
    20 PASS Set([]) threw exception TypeError: Set cannot be called as a function.
    21 PASS Set({}) threw exception TypeError: Set cannot be called as a function.
    22 PASS Set(undefined, null) threw exception TypeError: Set cannot be called as a function.
    23 PASS Set(undefined, {}) threw exception TypeError: Set cannot be called as a function.
     18PASS Set(1) threw exception TypeError: calling Set constructor without new is invalid.
     19PASS Set(true) threw exception TypeError: calling Set constructor without new is invalid.
     20PASS Set([]) threw exception TypeError: calling Set constructor without new is invalid.
     21PASS Set({}) threw exception TypeError: calling Set constructor without new is invalid.
     22PASS Set(undefined, null) threw exception TypeError: calling Set constructor without new is invalid.
     23PASS Set(undefined, {}) threw exception TypeError: calling Set constructor without new is invalid.
    2424PASS new Set(1) threw exception TypeError: Type error.
    2525PASS new Set(true) threw exception TypeError: Type error.
  • trunk/LayoutTests/js/dom/basic-weakmap-expected.txt

    r182994 r196986  
    77PASS WeakMap.prototype instanceof WeakMap is false
    88PASS new WeakMap() instanceof WeakMap is true
    9 PASS WeakMap() threw exception TypeError: WeakMap cannot be called as a function.
     9PASS WeakMap() threw exception TypeError: calling WeakMap constructor without new is invalid.
    1010PASS map.set(0, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap.
    1111PASS map.set(0.5, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap.
  • trunk/LayoutTests/js/dom/basic-weakset-expected.txt

    r182994 r196986  
    77PASS WeakSet.prototype instanceof WeakSet is false
    88PASS new WeakSet() instanceof WeakSet is true
    9 PASS WeakSet() threw exception TypeError: WeakSet cannot be called as a function.
     9PASS WeakSet() threw exception TypeError: calling WeakSet constructor without new is invalid.
    1010PASS set.add(0) threw exception TypeError: Attempted to add a non-object key to a WeakSet.
    1111PASS set.add(0.5) threw exception TypeError: Attempted to add a non-object key to a WeakSet.
  • trunk/LayoutTests/js/script-tests/Promise-types.js

    r191276 r196986  
    4242shouldThrow("new Promise(undefined)", "'TypeError: Promise constructor takes a function argument'");
    4343
    44 shouldThrow("Promise(1)", "'TypeError: Type error'");
    45 shouldThrow("Promise('hello')", "'TypeError: Type error'");
    46 shouldThrow("Promise([])", "'TypeError: Type error'");
    47 shouldThrow("Promise({})", "'TypeError: Type error'");
    48 shouldThrow("Promise(null)", "'TypeError: Type error'");
    49 shouldThrow("Promise(undefined)", "'TypeError: Type error'");
     44shouldThrow("Promise(1)", "'TypeError: calling Promise constructor without new is invalid'");
     45shouldThrow("Promise('hello')", "'TypeError: calling Promise constructor without new is invalid'");
     46shouldThrow("Promise([])", "'TypeError: calling Promise constructor without new is invalid'");
     47shouldThrow("Promise({})", "'TypeError: calling Promise constructor without new is invalid'");
     48shouldThrow("Promise(null)", "'TypeError: calling Promise constructor without new is invalid'");
     49shouldThrow("Promise(undefined)", "'TypeError: calling Promise constructor without new is invalid'");
    5050
    5151// Promise statics
  • trunk/LayoutTests/js/typedarray-constructors-expected.txt

    r181889 r196986  
    44
    55
    6 PASS Int8Array() threw exception TypeError: Int8Array is not a function. (In 'Int8Array()', 'Int8Array' is an instance of Function).
     6PASS Int8Array() threw exception TypeError: calling Int8Array constructor without new is invalid.
    77PASS new Int8Array() did not throw exception.
    8 PASS Int16Array() threw exception TypeError: Int16Array is not a function. (In 'Int16Array()', 'Int16Array' is an instance of Function).
     8PASS Int16Array() threw exception TypeError: calling Int16Array constructor without new is invalid.
    99PASS new Int16Array() did not throw exception.
    10 PASS Int32Array() threw exception TypeError: Int32Array is not a function. (In 'Int32Array()', 'Int32Array' is an instance of Function).
     10PASS Int32Array() threw exception TypeError: calling Int32Array constructor without new is invalid.
    1111PASS new Int32Array() did not throw exception.
    12 PASS Uint8Array() threw exception TypeError: Uint8Array is not a function. (In 'Uint8Array()', 'Uint8Array' is an instance of Function).
     12PASS Uint8Array() threw exception TypeError: calling Uint8Array constructor without new is invalid.
    1313PASS new Uint8Array() did not throw exception.
    14 PASS Uint16Array() threw exception TypeError: Uint16Array is not a function. (In 'Uint16Array()', 'Uint16Array' is an instance of Function).
     14PASS Uint16Array() threw exception TypeError: calling Uint16Array constructor without new is invalid.
    1515PASS new Uint16Array() did not throw exception.
    16 PASS Uint32Array() threw exception TypeError: Uint32Array is not a function. (In 'Uint32Array()', 'Uint32Array' is an instance of Function).
     16PASS Uint32Array() threw exception TypeError: calling Uint32Array constructor without new is invalid.
    1717PASS new Uint32Array() did not throw exception.
    18 PASS Uint8ClampedArray() threw exception TypeError: Uint8ClampedArray is not a function. (In 'Uint8ClampedArray()', 'Uint8ClampedArray' is an instance of Function).
     18PASS Uint8ClampedArray() threw exception TypeError: calling Uint8ClampedArray constructor without new is invalid.
    1919PASS new Uint8ClampedArray() did not throw exception.
    20 PASS Float32Array() threw exception TypeError: Float32Array is not a function. (In 'Float32Array()', 'Float32Array' is an instance of Function).
     20PASS Float32Array() threw exception TypeError: calling Float32Array constructor without new is invalid.
    2121PASS new Float32Array() did not throw exception.
    22 PASS Float64Array() threw exception TypeError: Float64Array is not a function. (In 'Float64Array()', 'Float64Array' is an instance of Function).
     22PASS Float64Array() threw exception TypeError: calling Float64Array constructor without new is invalid.
    2323PASS new Float64Array() did not throw exception.
    24 PASS DataView(new ArrayBuffer()) threw exception TypeError: DataView is not a function. (In 'DataView(new ArrayBuffer())', 'DataView' is an instance of Function).
     24PASS DataView(new ArrayBuffer()) threw exception TypeError: calling DataView constructor without new is invalid.
    2525PASS new DataView(new ArrayBuffer()) did not throw exception.
    2626PASS successfullyParsed is true
  • trunk/Source/JavaScriptCore/ChangeLog

    r196985 r196986  
     12016-02-23  Mark Lam  <mark.lam@apple.com>
     2
     3        Debug assertion failure while loading http://kangax.github.io/compat-table/es6/.
     4        https://bugs.webkit.org/show_bug.cgi?id=154542
     5
     6        Reviewed by Saam Barati.
     7
     8        According to the spec, the constructors of the following types "are not intended
     9        to be called as a function and will throw an exception".  These types are:
     10            TypedArrays - https://tc39.github.io/ecma262/#sec-typedarray-constructors
     11            Map - https://tc39.github.io/ecma262/#sec-map-constructor
     12            Set - https://tc39.github.io/ecma262/#sec-set-constructor
     13            WeakMap - https://tc39.github.io/ecma262/#sec-weakmap-constructor
     14            WeakSet - https://tc39.github.io/ecma262/#sec-weakset-constructor
     15            ArrayBuffer - https://tc39.github.io/ecma262/#sec-arraybuffer-constructor
     16            DataView - https://tc39.github.io/ecma262/#sec-dataview-constructor
     17            Promise - https://tc39.github.io/ecma262/#sec-promise-constructor
     18            Proxy - https://tc39.github.io/ecma262/#sec-proxy-constructor
     19
     20        This patch does the foillowing:
     21        1. Ensures that these constructors can be called but will throw a TypeError
     22           when called.
     23        2. Makes all these objects use throwConstructorCannotBeCalledAsFunctionTypeError()
     24           in their implementation to be consistent.
     25        3. Change the error message to "calling XXX constructor without new is invalid".
     26           This is clearer because the error is likely due to the user forgetting to use
     27           the new operator on these constructors.
     28
     29        * runtime/Error.h:
     30        * runtime/Error.cpp:
     31        (JSC::throwConstructorCannotBeCalledAsFunctionTypeError):
     32        - Added a convenience function to throw the TypeError.
     33
     34        * runtime/JSArrayBufferConstructor.cpp:
     35        (JSC::constructArrayBuffer):
     36        (JSC::callArrayBuffer):
     37        (JSC::JSArrayBufferConstructor::getCallData):
     38        * runtime/JSGenericTypedArrayViewConstructorInlines.h:
     39        (JSC::callGenericTypedArrayView):
     40        (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::getCallData):
     41        * runtime/JSPromiseConstructor.cpp:
     42        (JSC::callPromise):
     43        * runtime/MapConstructor.cpp:
     44        (JSC::callMap):
     45        * runtime/ProxyConstructor.cpp:
     46        (JSC::callProxy):
     47        (JSC::ProxyConstructor::getCallData):
     48        * runtime/SetConstructor.cpp:
     49        (JSC::callSet):
     50        * runtime/WeakMapConstructor.cpp:
     51        (JSC::callWeakMap):
     52        * runtime/WeakSetConstructor.cpp:
     53        (JSC::callWeakSet):
     54
     55        * tests/es6.yaml:
     56        - The typed_arrays_%TypedArray%[Symbol.species].js test now passes.
     57
     58        * tests/stress/call-non-calleable-constructors-as-function.js: Added.
     59        (test):
     60
     61        * tests/stress/map-constructor.js:
     62        (testCallTypeError):
     63        * tests/stress/promise-cannot-be-called.js:
     64        (shouldThrow):
     65        * tests/stress/proxy-basic.js:
     66        * tests/stress/set-constructor.js:
     67        * tests/stress/throw-from-ftl-call-ic-slow-path-cells.js:
     68        (i.catch):
     69        * tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js:
     70        (i.catch):
     71        * tests/stress/throw-from-ftl-call-ic-slow-path.js:
     72        (i.catch):
     73        * tests/stress/weak-map-constructor.js:
     74        (testCallTypeError):
     75        * tests/stress/weak-set-constructor.js:
     76        - Updated error message string.
     77
    1782016-02-23  Alexey Proskuryakov  <ap@apple.com>
    279
  • trunk/Source/JavaScriptCore/runtime/Error.cpp

    r189339 r196986  
    210210}
    211211
     212JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState* exec, const char* constructorName)
     213{
     214    return exec->vm().throwException(exec, createTypeError(exec, makeString("calling ", constructorName, " constructor without new is invalid")));
     215}
     216
    212217JSObject* throwTypeError(ExecState* exec)
    213218{
  • trunk/Source/JavaScriptCore/runtime/Error.h

    r189339 r196986  
    7373
    7474// Convenience wrappers, create an throw an exception with a default message.
     75JS_EXPORT_PRIVATE JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState*, const char* constructorName);
    7576JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*);
    7677JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*);
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp

    r196966 r196986  
    105105}
    106106
     107static EncodedJSValue JSC_HOST_CALL callArrayBuffer(ExecState* exec)
     108{
     109    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "ArrayBuffer"));
     110}
     111
    107112ConstructType JSArrayBufferConstructor::getConstructData(
    108113    JSCell*, ConstructData& constructData)
     
    114119CallType JSArrayBufferConstructor::getCallData(JSCell*, CallData& callData)
    115120{
    116     callData.native.function = constructArrayBuffer;
     121    callData.native.function = callArrayBuffer;
    117122    return CallTypeHost;
    118123}
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r196966 r196986  
    259259
    260260template<typename ViewClass>
     261static EncodedJSValue JSC_HOST_CALL callGenericTypedArrayView(ExecState* exec)
     262{
     263    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, ViewClass::info()->className));
     264}
     265
     266template<typename ViewClass>
    261267CallType JSGenericTypedArrayViewConstructor<ViewClass>::getCallData(JSCell*, CallData& callData)
    262268{
    263     callData.native.function = constructGenericTypedArrayView<ViewClass>;
    264     return CallTypeNone;
     269    callData.native.function = callGenericTypedArrayView<ViewClass>;
     270    return CallTypeHost;
    265271}
    266272
  • trunk/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp

    r196966 r196986  
    115115static EncodedJSValue JSC_HOST_CALL callPromise(ExecState* exec)
    116116{
    117     return throwVMTypeError(exec);
     117    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Promise"));
    118118}
    119119
  • trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp

    r196966 r196986  
    5151static EncodedJSValue JSC_HOST_CALL callMap(ExecState* exec)
    5252{
    53     return JSValue::encode(throwTypeError(exec, ASCIILiteral("Map cannot be called as a function")));
     53    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Map"));
    5454}
    5555
  • trunk/Source/JavaScriptCore/runtime/ProxyConstructor.cpp

    r196722 r196986  
    7676}
    7777
     78static EncodedJSValue JSC_HOST_CALL callProxy(ExecState* exec)
     79{
     80    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Proxy"));
     81}
     82
    7883CallType ProxyConstructor::getCallData(JSCell*, CallData& callData)
    7984{
    80     // Proxy should throw a TypeError when called as a function.
    81     callData.js.functionExecutable = 0;
    82     callData.js.scope = 0;
    83     callData.native.function = 0;
    84     return CallTypeNone;
     85    callData.native.function = callProxy;
     86    return CallTypeHost;
    8587}
    8688
  • trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp

    r196966 r196986  
    5252static EncodedJSValue JSC_HOST_CALL callSet(ExecState* exec)
    5353{
    54     return JSValue::encode(throwTypeError(exec, ASCIILiteral("Set cannot be called as a function")));
     54    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Set"));
    5555}
    5656
  • trunk/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp

    r196966 r196986  
    4949static EncodedJSValue JSC_HOST_CALL callWeakMap(ExecState* exec)
    5050{
    51     return JSValue::encode(throwTypeError(exec, ASCIILiteral("WeakMap cannot be called as a function")));
     51    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "WeakMap"));
    5252}
    5353
  • trunk/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp

    r196966 r196986  
    4949static EncodedJSValue JSC_HOST_CALL callWeakSet(ExecState* exec)
    5050{
    51     return JSValue::encode(throwTypeError(exec, ASCIILiteral("WeakSet cannot be called as a function")));
     51    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "WeakSet"));
    5252}
    5353
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r196956 r196986  
    11761176  cmd: runES6 :normal
    11771177- path: es6/typed_arrays_%TypedArray%[Symbol.species].js
    1178   cmd: runES6 :fail
     1178  cmd: runES6 :normal
    11791179- path: es6/typed_arrays_ArrayBuffer[Symbol.species].js
    11801180  cmd: runES6 :normal
  • trunk/Source/JavaScriptCore/tests/stress/map-constructor.js

    r181333 r196986  
    1313    if (!error)
    1414        throw "Error: error not thrown";
    15     if (String(error) !== "TypeError: Map cannot be called as a function")
     15    if (String(error) !== "TypeError: calling Map constructor without new is invalid")
    1616        throw "Error: bad error " + String(error);
    1717}
  • trunk/Source/JavaScriptCore/tests/stress/promise-cannot-be-called.js

    r191276 r196986  
    2222shouldThrow(() => {
    2323    Promise(function (resolve, reject) { executorCalled = true; });
    24 }, `TypeError: Type error`);
     24}, `TypeError: calling Promise constructor without new is invalid`);
    2525shouldBe(executorCalled, false);
    2626
  • trunk/Source/JavaScriptCore/tests/stress/proxy-basic.js

    r196789 r196986  
    7373        } catch(e) {
    7474            threw = true;
    75             assert(e.toString() === "TypeError: Proxy is not a function. (In 'Proxy({}, {})', 'Proxy' is an instance of Function)");
     75            assert(e.toString() === "TypeError: calling Proxy constructor without new is invalid");
    7676        }
    7777        assert(threw === true);
  • trunk/Source/JavaScriptCore/tests/stress/set-constructor.js

    r181333 r196986  
    1313    if (!error)
    1414        throw "Error: error not thrown";
    15     if (String(error) !== "TypeError: Set cannot be called as a function")
     15    if (String(error) !== "TypeError: calling Set constructor without new is invalid")
    1616        throw "Error: bad error " + String(error);
    1717}
  • trunk/Source/JavaScriptCore/tests/stress/throw-from-ftl-call-ic-slow-path-cells.js

    r180234 r196986  
    173173        ftlFunction(array, Int8Array);
    174174    } catch (e) {
    175         if (e.message.indexOf("not a function") < 0)
     175        if (e.message.indexOf("constructor without new is invalid") < 0)
    176176            throw "Error: bad exception message: " + e.message;
    177177        var result = notACell.f;
  • trunk/Source/JavaScriptCore/tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js

    r180234 r196986  
    173173        ftlFunction(array, Int8Array);
    174174    } catch (e) {
    175         if (e.message.indexOf("not a function") < 0)
     175        if (e.message.indexOf("constructor without new is invalid") < 0)
    176176            throw "Error: bad exception message: " + e.message;
    177177        var result = notACell.f;
  • trunk/Source/JavaScriptCore/tests/stress/throw-from-ftl-call-ic-slow-path.js

    r180234 r196986  
    173173        ftlFunction(array, Int8Array);
    174174    } catch (e) {
    175         if (e.message.indexOf("not a function") < 0)
     175        if (e.message.indexOf("constructor without new is invalid") < 0)
    176176            throw "Error: bad exception message: " + e.message;
    177177        var result = notACell.f;
  • trunk/Source/JavaScriptCore/tests/stress/weak-map-constructor.js

    r181333 r196986  
    1313    if (!error)
    1414        throw "Error: error not thrown";
    15     if (String(error) !== "TypeError: WeakMap cannot be called as a function")
     15    if (String(error) !== "TypeError: calling WeakMap constructor without new is invalid")
    1616        throw "Error: bad error " + String(error);
    1717}
  • trunk/Source/JavaScriptCore/tests/stress/weak-set-constructor.js

    r182994 r196986  
    1313    if (!error)
    1414        throw new Error("error not thrown");
    15     if (String(error) !== "TypeError: WeakSet cannot be called as a function")
     15    if (String(error) !== "TypeError: calling WeakSet constructor without new is invalid")
    1616        throw new Error("bad error " + String(error));
    1717}
Note: See TracChangeset for help on using the changeset viewer.