Title: [197106] releases/WebKitGTK/webkit-2.12
Revision
197106
Author
carlo...@webkit.org
Date
2016-02-25 06:15:46 -0800 (Thu, 25 Feb 2016)

Log Message

Merge r196986 - 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/_javascript_Core:

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.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/ChangeLog	2016-02-25 14:15:46 UTC (rev 197106)
@@ -1,3 +1,19 @@
+2016-02-23  Mark Lam  <mark....@apple.com>
+
+        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.
+
+        * 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.
+
 2016-02-23  Nikos Andronikos  <nikos.andronikos-web...@cisra.canon.com.au>
 
         [SVG] Update SVG source to return string literals as ASCIILiteral and add test cases for case sensitivity

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/Promise-types-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/Promise-types-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/Promise-types-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -16,25 +16,25 @@
 PASS aPromise.catch is an instance of Function
 PASS aPromise.catch.length is 1
 aPromise2 = Promise(...)
-PASS Promise(function(resolve, reject) { resolve(1); }) threw exception TypeError: Type error.
+PASS Promise(function(resolve, reject) { resolve(1); }) threw exception TypeError: calling Promise constructor without new is invalid.
 
 Promise constructor
 
 PASS Promise.length is 1
 PASS new Promise() threw exception TypeError: Promise constructor takes a function argument.
-PASS Promise() threw exception TypeError: Type error.
+PASS Promise() threw exception TypeError: calling Promise constructor without new is invalid.
 PASS new Promise(1) threw exception TypeError: Promise constructor takes a function argument.
 PASS new Promise('hello') threw exception TypeError: Promise constructor takes a function argument.
 PASS new Promise([]) threw exception TypeError: Promise constructor takes a function argument.
 PASS new Promise({}) threw exception TypeError: Promise constructor takes a function argument.
 PASS new Promise(null) threw exception TypeError: Promise constructor takes a function argument.
 PASS new Promise(undefined) threw exception TypeError: Promise constructor takes a function argument.
-PASS Promise(1) threw exception TypeError: Type error.
-PASS Promise('hello') threw exception TypeError: Type error.
-PASS Promise([]) threw exception TypeError: Type error.
-PASS Promise({}) threw exception TypeError: Type error.
-PASS Promise(null) threw exception TypeError: Type error.
-PASS Promise(undefined) threw exception TypeError: Type error.
+PASS Promise(1) threw exception TypeError: calling Promise constructor without new is invalid.
+PASS Promise('hello') threw exception TypeError: calling Promise constructor without new is invalid.
+PASS Promise([]) threw exception TypeError: calling Promise constructor without new is invalid.
+PASS Promise({}) threw exception TypeError: calling Promise constructor without new is invalid.
+PASS Promise(null) threw exception TypeError: calling Promise constructor without new is invalid.
+PASS Promise(undefined) threw exception TypeError: calling Promise constructor without new is invalid.
 
 Promise statics
 

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-map-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-map-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-map-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -10,14 +10,14 @@
 PASS new Map(undefined) instanceof Map is true
 PASS new Map(undefined, undefined) instanceof Map is true
 PASS new Map(null, undefined) instanceof Map is true
-PASS Map() threw exception TypeError: Map cannot be called as a function.
-PASS Map(1) threw exception TypeError: Map cannot be called as a function.
-PASS Map(true) threw exception TypeError: Map cannot be called as a function.
-PASS Map('String') threw exception TypeError: Map cannot be called as a function.
-PASS Map([]) threw exception TypeError: Map cannot be called as a function.
-PASS Map({}) threw exception TypeError: Map cannot be called as a function.
-PASS Map(undefined) threw exception TypeError: Map cannot be called as a function.
-PASS Map(null) threw exception TypeError: Map cannot be called as a function.
+PASS Map() threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map(1) threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map(true) threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map('String') threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map([]) threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map({}) threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map(undefined) threw exception TypeError: calling Map constructor without new is invalid.
+PASS Map(null) threw exception TypeError: calling Map constructor without new is invalid.
 PASS new Map(1) threw exception TypeError: Type error.
 PASS new Map(true) threw exception TypeError: Type error.
 PASS new Map([]) did not throw exception.

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-set-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-set-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/basic-set-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -5,22 +5,22 @@
 
 PASS Set instanceof Set is false
 PASS Set.prototype instanceof Set is false
-PASS Set() instanceof Set threw exception TypeError: Set cannot be called as a function.
+PASS Set() instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
 PASS new Set() instanceof Set is true
-PASS Set(null) instanceof Set threw exception TypeError: Set cannot be called as a function.
-PASS Set(undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
-PASS Set(undefined, undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
-PASS Set(null, undefined) instanceof Set threw exception TypeError: Set cannot be called as a function.
+PASS Set(null) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(undefined, undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(null, undefined) instanceof Set threw exception TypeError: calling Set constructor without new is invalid.
 PASS new Set(null) instanceof Set is true
 PASS new Set(undefined) instanceof Set is true
 PASS new Set(undefined, undefined) instanceof Set is true
 PASS new Set(null, undefined) instanceof Set is true
-PASS Set(1) threw exception TypeError: Set cannot be called as a function.
-PASS Set(true) threw exception TypeError: Set cannot be called as a function.
-PASS Set([]) threw exception TypeError: Set cannot be called as a function.
-PASS Set({}) threw exception TypeError: Set cannot be called as a function.
-PASS Set(undefined, null) threw exception TypeError: Set cannot be called as a function.
-PASS Set(undefined, {}) threw exception TypeError: Set cannot be called as a function.
+PASS Set(1) threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(true) threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set([]) threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set({}) threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(undefined, null) threw exception TypeError: calling Set constructor without new is invalid.
+PASS Set(undefined, {}) threw exception TypeError: calling Set constructor without new is invalid.
 PASS new Set(1) threw exception TypeError: Type error.
 PASS new Set(true) threw exception TypeError: Type error.
 PASS new Set([]) did not throw exception.

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakmap-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakmap-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakmap-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -6,7 +6,7 @@
 PASS WeakMap instanceof WeakMap is false
 PASS WeakMap.prototype instanceof WeakMap is false
 PASS new WeakMap() instanceof WeakMap is true
-PASS WeakMap() threw exception TypeError: WeakMap cannot be called as a function.
+PASS WeakMap() threw exception TypeError: calling WeakMap constructor without new is invalid.
 PASS map.set(0, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap.
 PASS map.set(0.5, 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap.
 PASS map.set('foo', 1) threw exception TypeError: Attempted to set a non-object key in a WeakMap.

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakset-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakset-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/dom/basic-weakset-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -6,7 +6,7 @@
 PASS WeakSet instanceof WeakSet is false
 PASS WeakSet.prototype instanceof WeakSet is false
 PASS new WeakSet() instanceof WeakSet is true
-PASS WeakSet() threw exception TypeError: WeakSet cannot be called as a function.
+PASS WeakSet() threw exception TypeError: calling WeakSet constructor without new is invalid.
 PASS set.add(0) threw exception TypeError: Attempted to add a non-object key to a WeakSet.
 PASS set.add(0.5) threw exception TypeError: Attempted to add a non-object key to a WeakSet.
 PASS set.add('foo') threw exception TypeError: Attempted to add a non-object key to a WeakSet.

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/script-tests/Promise-types.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/script-tests/Promise-types.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/script-tests/Promise-types.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -41,12 +41,12 @@
 shouldThrow("new Promise(null)", "'TypeError: Promise constructor takes a function argument'");
 shouldThrow("new Promise(undefined)", "'TypeError: Promise constructor takes a function argument'");
 
-shouldThrow("Promise(1)", "'TypeError: Type error'");
-shouldThrow("Promise('hello')", "'TypeError: Type error'");
-shouldThrow("Promise([])", "'TypeError: Type error'");
-shouldThrow("Promise({})", "'TypeError: Type error'");
-shouldThrow("Promise(null)", "'TypeError: Type error'");
-shouldThrow("Promise(undefined)", "'TypeError: Type error'");
+shouldThrow("Promise(1)", "'TypeError: calling Promise constructor without new is invalid'");
+shouldThrow("Promise('hello')", "'TypeError: calling Promise constructor without new is invalid'");
+shouldThrow("Promise([])", "'TypeError: calling Promise constructor without new is invalid'");
+shouldThrow("Promise({})", "'TypeError: calling Promise constructor without new is invalid'");
+shouldThrow("Promise(null)", "'TypeError: calling Promise constructor without new is invalid'");
+shouldThrow("Promise(undefined)", "'TypeError: calling Promise constructor without new is invalid'");
 
 // Promise statics
 debug("");

Modified: releases/WebKitGTK/webkit-2.12/LayoutTests/js/typedarray-constructors-expected.txt (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/LayoutTests/js/typedarray-constructors-expected.txt	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/LayoutTests/js/typedarray-constructors-expected.txt	2016-02-25 14:15:46 UTC (rev 197106)
@@ -3,25 +3,25 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS Int8Array() threw exception TypeError: Int8Array is not a function. (In 'Int8Array()', 'Int8Array' is an instance of Function).
+PASS Int8Array() threw exception TypeError: calling Int8Array constructor without new is invalid.
 PASS new Int8Array() did not throw exception.
-PASS Int16Array() threw exception TypeError: Int16Array is not a function. (In 'Int16Array()', 'Int16Array' is an instance of Function).
+PASS Int16Array() threw exception TypeError: calling Int16Array constructor without new is invalid.
 PASS new Int16Array() did not throw exception.
-PASS Int32Array() threw exception TypeError: Int32Array is not a function. (In 'Int32Array()', 'Int32Array' is an instance of Function).
+PASS Int32Array() threw exception TypeError: calling Int32Array constructor without new is invalid.
 PASS new Int32Array() did not throw exception.
-PASS Uint8Array() threw exception TypeError: Uint8Array is not a function. (In 'Uint8Array()', 'Uint8Array' is an instance of Function).
+PASS Uint8Array() threw exception TypeError: calling Uint8Array constructor without new is invalid.
 PASS new Uint8Array() did not throw exception.
-PASS Uint16Array() threw exception TypeError: Uint16Array is not a function. (In 'Uint16Array()', 'Uint16Array' is an instance of Function).
+PASS Uint16Array() threw exception TypeError: calling Uint16Array constructor without new is invalid.
 PASS new Uint16Array() did not throw exception.
-PASS Uint32Array() threw exception TypeError: Uint32Array is not a function. (In 'Uint32Array()', 'Uint32Array' is an instance of Function).
+PASS Uint32Array() threw exception TypeError: calling Uint32Array constructor without new is invalid.
 PASS new Uint32Array() did not throw exception.
-PASS Uint8ClampedArray() threw exception TypeError: Uint8ClampedArray is not a function. (In 'Uint8ClampedArray()', 'Uint8ClampedArray' is an instance of Function).
+PASS Uint8ClampedArray() threw exception TypeError: calling Uint8ClampedArray constructor without new is invalid.
 PASS new Uint8ClampedArray() did not throw exception.
-PASS Float32Array() threw exception TypeError: Float32Array is not a function. (In 'Float32Array()', 'Float32Array' is an instance of Function).
+PASS Float32Array() threw exception TypeError: calling Float32Array constructor without new is invalid.
 PASS new Float32Array() did not throw exception.
-PASS Float64Array() threw exception TypeError: Float64Array is not a function. (In 'Float64Array()', 'Float64Array' is an instance of Function).
+PASS Float64Array() threw exception TypeError: calling Float64Array constructor without new is invalid.
 PASS new Float64Array() did not throw exception.
-PASS DataView(new ArrayBuffer()) threw exception TypeError: DataView is not a function. (In 'DataView(new ArrayBuffer())', 'DataView' is an instance of Function).
+PASS DataView(new ArrayBuffer()) threw exception TypeError: calling DataView constructor without new is invalid.
 PASS new DataView(new ArrayBuffer()) did not throw exception.
 PASS successfullyParsed is true
 

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/ChangeLog (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/ChangeLog	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/ChangeLog	2016-02-25 14:15:46 UTC (rev 197106)
@@ -1,3 +1,80 @@
+2016-02-23  Mark Lam  <mark....@apple.com>
+
+        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.
+
+        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.
+
 2016-02-22  Saam barati  <sbar...@apple.com>
 
         JSGlobalObject doesn't visit ProxyObjectStructure during GC

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -209,6 +209,11 @@
         || error->hasProperty(exec, Identifier::fromString(exec, sourceURLPropertyName));
 }
 
+JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState* exec, const char* constructorName)
+{
+    return exec->vm().throwException(exec, createTypeError(exec, makeString("calling ", constructorName, " constructor without new is invalid")));
+}
+
 JSObject* throwTypeError(ExecState* exec)
 {
     return exec->vm().throwException(exec, createTypeError(exec));

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.h (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.h	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/Error.h	2016-02-25 14:15:46 UTC (rev 197106)
@@ -72,6 +72,7 @@
 // Methods to throw Errors.
 
 // Convenience wrappers, create an throw an exception with a default message.
+JS_EXPORT_PRIVATE JSObject* throwConstructorCannotBeCalledAsFunctionTypeError(ExecState*, const char* constructorName);
 JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*);
 JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*);
 JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*, const String& errorMessage);

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSArrayBufferConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSArrayBufferConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSArrayBufferConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -102,6 +102,11 @@
     return JSValue::encode(result);
 }
 
+static EncodedJSValue JSC_HOST_CALL callArrayBuffer(ExecState* exec)
+{
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "ArrayBuffer"));
+}
+
 ConstructType JSArrayBufferConstructor::getConstructData(
     JSCell*, ConstructData& constructData)
 {
@@ -111,7 +116,7 @@
 
 CallType JSArrayBufferConstructor::getCallData(JSCell*, CallData& callData)
 {
-    callData.native.function = constructArrayBuffer;
+    callData.native.function = callArrayBuffer;
     return CallTypeHost;
 }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h	2016-02-25 14:15:46 UTC (rev 197106)
@@ -256,10 +256,16 @@
 }
 
 template<typename ViewClass>
+static EncodedJSValue JSC_HOST_CALL callGenericTypedArrayView(ExecState* exec)
+{
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, ViewClass::info()->className));
+}
+
+template<typename ViewClass>
 CallType JSGenericTypedArrayViewConstructor<ViewClass>::getCallData(JSCell*, CallData& callData)
 {
-    callData.native.function = constructGenericTypedArrayView<ViewClass>;
-    return CallTypeNone;
+    callData.native.function = callGenericTypedArrayView<ViewClass>;
+    return CallTypeHost;
 }
 
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSPromiseConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSPromiseConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/JSPromiseConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -112,7 +112,7 @@
 
 static EncodedJSValue JSC_HOST_CALL callPromise(ExecState* exec)
 {
-    return throwVMTypeError(exec);
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Promise"));
 }
 
 ConstructType JSPromiseConstructor::getConstructData(JSCell*, ConstructData& constructData)

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/MapConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/MapConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/MapConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -50,7 +50,7 @@
 
 static EncodedJSValue JSC_HOST_CALL callMap(ExecState* exec)
 {
-    return JSValue::encode(throwTypeError(exec, ASCIILiteral("Map cannot be called as a function")));
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Map"));
 }
 
 static EncodedJSValue JSC_HOST_CALL constructMap(ExecState* exec)

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/ProxyConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/ProxyConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/ProxyConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -75,13 +75,15 @@
     return ConstructTypeHost;
 }
 
+static EncodedJSValue JSC_HOST_CALL callProxy(ExecState* exec)
+{
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Proxy"));
+}
+
 CallType ProxyConstructor::getCallData(JSCell*, CallData& callData)
 {
-    // Proxy should throw a TypeError when called as a function.
-    callData.js.functionExecutable = 0;
-    callData.js.scope = 0;
-    callData.native.function = 0;
-    return CallTypeNone;
+    callData.native.function = callProxy;
+    return CallTypeHost;
 }
 
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/SetConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/SetConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/SetConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -51,7 +51,7 @@
 
 static EncodedJSValue JSC_HOST_CALL callSet(ExecState* exec)
 {
-    return JSValue::encode(throwTypeError(exec, ASCIILiteral("Set cannot be called as a function")));
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "Set"));
 }
 
 static EncodedJSValue JSC_HOST_CALL constructSet(ExecState* exec)

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakMapConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakMapConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakMapConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -48,7 +48,7 @@
 
 static EncodedJSValue JSC_HOST_CALL callWeakMap(ExecState* exec)
 {
-    return JSValue::encode(throwTypeError(exec, ASCIILiteral("WeakMap cannot be called as a function")));
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "WeakMap"));
 }
 
 static EncodedJSValue JSC_HOST_CALL constructWeakMap(ExecState* exec)

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakSetConstructor.cpp (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakSetConstructor.cpp	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/runtime/WeakSetConstructor.cpp	2016-02-25 14:15:46 UTC (rev 197106)
@@ -48,7 +48,7 @@
 
 static EncodedJSValue JSC_HOST_CALL callWeakSet(ExecState* exec)
 {
-    return JSValue::encode(throwTypeError(exec, ASCIILiteral("WeakSet cannot be called as a function")));
+    return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "WeakSet"));
 }
 
 static EncodedJSValue JSC_HOST_CALL constructWeakSet(ExecState* exec)

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/es6.yaml (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/es6.yaml	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/es6.yaml	2016-02-25 14:15:46 UTC (rev 197106)
@@ -1175,7 +1175,7 @@
 - path: es6/typed_arrays_%TypedArray%.prototype[Symbol.iterator].js
   cmd: runES6 :normal
 - path: es6/typed_arrays_%TypedArray%[Symbol.species].js
-  cmd: runES6 :fail
+  cmd: runES6 :normal
 - path: es6/typed_arrays_ArrayBuffer[Symbol.species].js
   cmd: runES6 :normal
 - path: es6/typed_arrays_correct_prototype_chains.js

Added: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/call-non-calleable-constructors-as-function.js (0 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/call-non-calleable-constructors-as-function.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/call-non-calleable-constructors-as-function.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -0,0 +1,59 @@
+var errors = "";
+var numTests = 0;
+
+function test(type) {
+    var didThrow = false;
+    try {
+        var bad = type(10);
+    } catch(e) {
+        didThrow = true;
+    }
+
+    if (!didThrow) {
+        errors += ("bad result: calling " + type.name + " as a function did not throw\n");
+    }
+    numTests++;
+
+    if (typeof type !== "function")
+        errors += ("bad result: typeof " + type.name + " is not function. Was " + (typeof type) + "\n");
+    numTests++;
+}
+
+// According to the spec, the constructors of the following types "are not intended to be
+// called as a function and will throw an exception". However, as constructors, their
+// type should be "function". 
+
+// https://tc39.github.io/ecma262/#sec-typedarray-constructors
+test(Int8Array);
+test(Uint8Array);
+test(Uint8ClampedArray);
+test(Int16Array);
+test(Uint16Array);
+test(Int32Array);
+test(Uint32Array);
+test(Float32Array);
+test(Float64Array);
+
+// https://tc39.github.io/ecma262/#sec-map-constructor
+test(Map);
+// https://tc39.github.io/ecma262/#sec-set-constructor
+test(Set);
+// https://tc39.github.io/ecma262/#sec-weakmap-constructor
+test(WeakMap);
+// https://tc39.github.io/ecma262/#sec-weakset-constructor
+test(WeakSet);
+// https://tc39.github.io/ecma262/#sec-arraybuffer-constructor
+test(ArrayBuffer);
+// https://tc39.github.io/ecma262/#sec-dataview-constructor
+test(DataView);
+// https://tc39.github.io/ecma262/#sec-promise-constructor
+test(Promise);
+// https://tc39.github.io/ecma262/#sec-proxy-constructor
+test(Proxy);
+
+let expectedNumTests = 34;
+if (numTests != expectedNumTests) {
+    errors += "Not all tests were run: ran " + numTests + " out of " + expectedNumTests + " \n";
+}
+if (errors.length)
+    throw new Error(errors);

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/map-constructor.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/map-constructor.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/map-constructor.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -12,7 +12,7 @@
     }
     if (!error)
         throw "Error: error not thrown";
-    if (String(error) !== "TypeError: Map cannot be called as a function")
+    if (String(error) !== "TypeError: calling Map constructor without new is invalid")
         throw "Error: bad error " + String(error);
 }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/promise-cannot-be-called.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/promise-cannot-be-called.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/promise-cannot-be-called.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -21,7 +21,7 @@
 var executorCalled = false;
 shouldThrow(() => {
     Promise(function (resolve, reject) { executorCalled = true; });
-}, `TypeError: Type error`);
+}, `TypeError: calling Promise constructor without new is invalid`);
 shouldBe(executorCalled, false);
 
 // But should accept inheriting Promise.

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/proxy-basic.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/proxy-basic.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/proxy-basic.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -72,7 +72,7 @@
             Proxy({}, {});
         } catch(e) {
             threw = true;
-            assert(e.toString() === "TypeError: Proxy is not a function. (In 'Proxy({}, {})', 'Proxy' is an instance of Function)");
+            assert(e.toString() === "TypeError: calling Proxy constructor without new is invalid");
         }
         assert(threw === true);
     }

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/set-constructor.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/set-constructor.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/set-constructor.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -12,7 +12,7 @@
     }
     if (!error)
         throw "Error: error not thrown";
-    if (String(error) !== "TypeError: Set cannot be called as a function")
+    if (String(error) !== "TypeError: calling Set constructor without new is invalid")
         throw "Error: bad error " + String(error);
 }
 

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-cells.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-cells.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-cells.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -172,7 +172,7 @@
     try {
         ftlFunction(array, Int8Array);
     } catch (e) {
-        if (e.message.indexOf("not a function") < 0)
+        if (e.message.indexOf("constructor without new is invalid") < 0)
             throw "Error: bad exception message: " + e.message;
         var result = notACell.f;
         if (result !== void 0) {

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path-undefined.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -172,7 +172,7 @@
     try {
         ftlFunction(array, Int8Array);
     } catch (e) {
-        if (e.message.indexOf("not a function") < 0)
+        if (e.message.indexOf("constructor without new is invalid") < 0)
             throw "Error: bad exception message: " + e.message;
         var result = notACell.f;
         if (result !== void 0) {

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/throw-from-ftl-call-ic-slow-path.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -172,7 +172,7 @@
     try {
         ftlFunction(array, Int8Array);
     } catch (e) {
-        if (e.message.indexOf("not a function") < 0)
+        if (e.message.indexOf("constructor without new is invalid") < 0)
             throw "Error: bad exception message: " + e.message;
         var result = notACell.f;
         if (result !== void 0) {

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-map-constructor.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-map-constructor.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-map-constructor.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -12,7 +12,7 @@
     }
     if (!error)
         throw "Error: error not thrown";
-    if (String(error) !== "TypeError: WeakMap cannot be called as a function")
+    if (String(error) !== "TypeError: calling WeakMap constructor without new is invalid")
         throw "Error: bad error " + String(error);
 }
 var obj1 = {};

Modified: releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-set-constructor.js (197105 => 197106)


--- releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-set-constructor.js	2016-02-25 13:56:57 UTC (rev 197105)
+++ releases/WebKitGTK/webkit-2.12/Source/_javascript_Core/tests/stress/weak-set-constructor.js	2016-02-25 14:15:46 UTC (rev 197106)
@@ -12,7 +12,7 @@
     }
     if (!error)
         throw new Error("error not thrown");
-    if (String(error) !== "TypeError: WeakSet cannot be called as a function")
+    if (String(error) !== "TypeError: calling WeakSet constructor without new is invalid")
         throw new Error("bad error " + String(error));
 }
 var obj1 = {};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to