WebKit Bugzilla
Attachment 372443 Details for
Bug 198976
: Promise constructor should check argument before [[Construct]]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198976-20190619111927.patch (text/plain), 5.84 KB, created by
Alexey Shvayka
on 2019-06-19 01:19:28 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alexey Shvayka
Created:
2019-06-19 01:19:28 PDT
Size:
5.84 KB
patch
obsolete
>Index: JSTests/ChangeLog >=================================================================== >--- JSTests/ChangeLog (revision 246582) >+++ JSTests/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2019-06-19 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ Promise constructor should check argument before [[Construct]] >+ https://bugs.webkit.org/show_bug.cgi?id=198976 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * stress/create-subclass-structure-may-throw-exception-when-getting-prototype.js: Fix test. >+ * stress/create-subclass-structure-might-throw.js: Fix test. >+ * test262/expectations.yaml: Mark 2 test cases as passing. >+ > 2019-06-18 Justin Michaud <justin_michaud@apple.com> > > [WASM-References] Add support for Table.size, grow and fill instructions >Index: JSTests/stress/create-subclass-structure-may-throw-exception-when-getting-prototype.js >=================================================================== >--- JSTests/stress/create-subclass-structure-may-throw-exception-when-getting-prototype.js (revision 246576) >+++ JSTests/stress/create-subclass-structure-may-throw-exception-when-getting-prototype.js (working copy) >@@ -29,7 +29,6 @@ Object.defineProperty(bf, "prototype", { > Error, > Uint8Array, > ArrayBuffer, >- Promise, > Map, > WeakMap, > Set, >@@ -40,5 +39,9 @@ Object.defineProperty(bf, "prototype", { > }, `Error: OK`); > }); > >+shouldThrow(() => { >+ Reflect.construct(Promise, [() => {}], bf); >+}, `Error: OK`); >+ > // Proxy constructor is not aware of new.target. > Reflect.construct(Proxy, [{}, {}], bf); >Index: JSTests/stress/create-subclass-structure-might-throw.js >=================================================================== >--- JSTests/stress/create-subclass-structure-might-throw.js (revision 246576) >+++ JSTests/stress/create-subclass-structure-might-throw.js (working copy) >@@ -21,7 +21,10 @@ for (let target of targets) { > for (let i = 0; i < 500; i++) { > let threw = false; > try { >- new proxy; >+ if (target === Promise) >+ new proxy(function() {}); >+ else >+ new proxy; > } catch(e) { > threw = true; > assert(e === error); >Index: JSTests/test262/expectations.yaml >=================================================================== >--- JSTests/test262/expectations.yaml (revision 246576) >+++ JSTests/test262/expectations.yaml (working copy) >@@ -1122,9 +1122,6 @@ test/built-ins/Promise/allSettled/reject > test/built-ins/Promise/allSettled/resolve-element-function-nonconstructor.js: > default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all' > strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all' >-test/built-ins/Promise/get-prototype-abrupt-executor-not-callable.js: >- default: 'Test262Error: Expected a TypeError but got a Test262Error' >- strict mode: 'Test262Error: Expected a TypeError but got a Test262Error' > test/built-ins/Promise/proto-from-ctor-realm.js: > default: 'Test262Error: Expected SameValue(ë[object Promise]û, ë[object Promise]û) to be true' > strict mode: 'Test262Error: Expected SameValue(ë[object Promise]û, ë[object Promise]û) to be true' >Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 246576) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2019-06-19 Alexey Shvayka <shvaikalesh@gmail.com> >+ >+ Promise constructor should check argument before [[Construct]] >+ https://bugs.webkit.org/show_bug.cgi?id=198976 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Check if argument is a function before invoking `createSubclassStructure`. >+ (step 2 of https://tc39.es/ecma262/#sec-promise-executor) >+ >+ * builtins/PromiseOperations.js: >+ (globalPrivate.initializePromise): Remove typeof check. >+ * runtime/JSPromiseConstructor.cpp: >+ (JSC::constructPromise): Add isFunction check. >+ > 2019-06-18 Keith Miller <keith_miller@apple.com> > > Unreviewed, fix signature of currentWeakRefVersion to return an uintptr_t. >Index: Source/JavaScriptCore/builtins/PromiseOperations.js >=================================================================== >--- Source/JavaScriptCore/builtins/PromiseOperations.js (revision 246576) >+++ Source/JavaScriptCore/builtins/PromiseOperations.js (working copy) >@@ -216,9 +216,6 @@ function initializePromise(executor) > { > "use strict"; > >- if (typeof executor !== 'function') >- @throwTypeError("Promise constructor takes a function argument"); >- > @putByIdDirectPrivate(this, "promiseState", @promiseStatePending); > @putByIdDirectPrivate(this, "promiseReactions", []); > @putByIdDirectPrivate(this, "promiseIsHandled", false); >Index: Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp (revision 246576) >+++ Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp (working copy) >@@ -112,10 +112,14 @@ static EncodedJSValue JSC_HOST_CALL cons > if (newTarget.isUndefined()) > return throwVMTypeError(exec, scope); > >+ JSValue executor = exec->argument(0); >+ if (!executor.isFunction(vm)) >+ return throwVMTypeError(exec, scope, "Promise constructor takes a function argument"_s); >+ > Structure* promiseStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->promiseStructure()); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); > JSPromise* promise = JSPromise::create(vm, promiseStructure); >- promise->initialize(exec, globalObject, exec->argument(0)); >+ promise->initialize(exec, globalObject, executor); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); > > return JSValue::encode(promise);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198976
:
372377
|
372401
| 372443