Title: [205027] trunk
Revision
205027
Author
[email protected]
Date
2016-08-26 10:37:31 -0700 (Fri, 26 Aug 2016)

Log Message

[ES6] newPromiseCapabilities should check the given argument is constructor
https://bugs.webkit.org/show_bug.cgi?id=161226

Reviewed by Mark Lam.

JSTests:

The arrow function should not be a constructor. So the error should be raised.

* stress/new-promise-capabilities-requires-constructor.js: Added.
(shouldThrow):

Source/_javascript_Core:

Use @isConstructor.

* builtins/PromiseOperations.js:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (205026 => 205027)


--- trunk/JSTests/ChangeLog	2016-08-26 17:36:59 UTC (rev 205026)
+++ trunk/JSTests/ChangeLog	2016-08-26 17:37:31 UTC (rev 205027)
@@ -1,3 +1,15 @@
+2016-08-26  Yusuke Suzuki  <[email protected]>
+
+        [ES6] newPromiseCapabilities should check the given argument is constructor
+        https://bugs.webkit.org/show_bug.cgi?id=161226
+
+        Reviewed by Mark Lam.
+
+        The arrow function should not be a constructor. So the error should be raised.
+
+        * stress/new-promise-capabilities-requires-constructor.js: Added.
+        (shouldThrow):
+
 2016-08-25  Benjamin Poulain  <[email protected]>
 
         [JSC] Clean up the abstract interpreter for cos/sin/sqrt/fround/log

Added: trunk/JSTests/stress/new-promise-capabilities-requires-constructor.js (0 => 205027)


--- trunk/JSTests/stress/new-promise-capabilities-requires-constructor.js	                        (rev 0)
+++ trunk/JSTests/stress/new-promise-capabilities-requires-constructor.js	2016-08-26 17:37:31 UTC (rev 205027)
@@ -0,0 +1,18 @@
+function shouldThrow(func, errorMessage) {
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
+
+shouldThrow(() => {
+    Promise.race.call(() => { }, []);
+}, `TypeError: promise capability requires a constructor function`);

Modified: trunk/Source/_javascript_Core/ChangeLog (205026 => 205027)


--- trunk/Source/_javascript_Core/ChangeLog	2016-08-26 17:36:59 UTC (rev 205026)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-08-26 17:37:31 UTC (rev 205027)
@@ -1,3 +1,14 @@
+2016-08-26  Yusuke Suzuki  <[email protected]>
+
+        [ES6] newPromiseCapabilities should check the given argument is constructor
+        https://bugs.webkit.org/show_bug.cgi?id=161226
+
+        Reviewed by Mark Lam.
+
+        Use @isConstructor.
+
+        * builtins/PromiseOperations.js:
+
 2016-08-25  Keith Miller  <[email protected]>
 
         toString called on proxies returns incorrect tag

Modified: trunk/Source/_javascript_Core/builtins/PromiseOperations.js (205026 => 205027)


--- trunk/Source/_javascript_Core/builtins/PromiseOperations.js	2016-08-26 17:36:59 UTC (rev 205026)
+++ trunk/Source/_javascript_Core/builtins/PromiseOperations.js	2016-08-26 17:37:31 UTC (rev 205027)
@@ -50,8 +50,7 @@
 {
     "use strict";
 
-    // FIXME: Check isConstructor(constructor).
-    if (typeof constructor !== "function")
+    if (!@isConstructor(constructor))
         throw new @TypeError("promise capability requires a constructor function");
 
     var promiseCapability = {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to