Promise constructor should throw when not called with "new"
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Oct 2015 00:51:26 +0000 (00:51 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Oct 2015 00:51:26 +0000 (00:51 +0000)
commitb87ff7faab1f2e3f47768299805662e93ab5fd0e
tree610105fdf1609840132c8cc1c1a60b1c00693498
parent669c7dd3c565a7685a44d2e74906371c65c31411
Promise constructor should throw when not called with "new"
https://bugs.webkit.org/show_bug.cgi?id=149380

Reviewed by Darin Adler.

Source/JavaScriptCore:

Implement handling new.target in Promise constructor. And
prohibiting Promise constructor call without "new".

* runtime/JSPromiseConstructor.cpp:
(JSC::constructPromise):
(JSC::callPromise):
(JSC::JSPromiseConstructor::getCallData):
* tests/es6.yaml:
* tests/stress/promise-cannot-be-called.js: Added.
(shouldBe):
(shouldThrow):
(Deferred):
(super):

LayoutTests:

Fix js/dom/Promise-types.html. Before this change, it calls the Promise constructor without new and
expects it succeeds. And we move it from js/dom to js since we can execute this without DOM support.

* js/Promise-types-expected.txt: Renamed from LayoutTests/js/dom/Promise-types-expected.txt.
* js/Promise-types.html: Added.
* js/script-tests/Promise-types.js: Renamed from LayoutTests/js/dom/Promise-types.html.
(aPromise.new.Promise):
(debug.string_appeared_here.shouldThrow.Promise):
* resources/standalone-pre.js:
(shouldBeDefined):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191276 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/js/Promise-types-expected.txt [moved from LayoutTests/js/dom/Promise-types-expected.txt with 69% similarity]
LayoutTests/js/Promise-types.html [new file with mode: 0644]
LayoutTests/js/script-tests/Promise-types.js [moved from LayoutTests/js/dom/Promise-types.html with 66% similarity]
LayoutTests/resources/standalone-pre.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
Source/JavaScriptCore/tests/es6.yaml
Source/JavaScriptCore/tests/stress/promise-cannot-be-called.js [new file with mode: 0644]