Changeset 248793 in webkit


Ignore:
Timestamp:
Aug 16, 2019 1:44:37 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Promise.prototype.finally should accept non-promise objects
https://bugs.webkit.org/show_bug.cgi?id=200829

Reviewed by Mark Lam.

JSTests:

  • stress/promise-finally-should-accept-non-promise-objects.js: Added.

(shouldBe):
(Thenable):
(Thenable.prototype.then):

Source/JavaScriptCore:

According to the Promise.prototype.finally spec step 2[1], we should check @isObject instead of @isPromise,
since Promise.prototype.finally should accept thenable objects that are defined by user libraries (like, bluebird for example).
This patch changes this check to the specified one.

[1]: https://tc39.es/proposal-promise-finally/

  • builtins/PromisePrototype.js:

(finally):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r248787 r248793  
     12019-08-16  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Promise.prototype.finally should accept non-promise objects
     4        https://bugs.webkit.org/show_bug.cgi?id=200829
     5
     6        Reviewed by Mark Lam.
     7
     8        * stress/promise-finally-should-accept-non-promise-objects.js: Added.
     9        (shouldBe):
     10        (Thenable):
     11        (Thenable.prototype.then):
     12
    1132019-08-16  Alexey Shvayka  <shvaikalesh@gmail.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r248787 r248793  
     12019-08-16  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Promise.prototype.finally should accept non-promise objects
     4        https://bugs.webkit.org/show_bug.cgi?id=200829
     5
     6        Reviewed by Mark Lam.
     7
     8        According to the Promise.prototype.finally spec step 2[1], we should check @isObject instead of @isPromise,
     9        since Promise.prototype.finally should accept thenable objects that are defined by user libraries (like, bluebird for example).
     10        This patch changes this check to the specified one.
     11
     12        [1]: https://tc39.es/proposal-promise-finally/
     13
     14        * builtins/PromisePrototype.js:
     15        (finally):
     16
    1172019-08-16  Alexey Shvayka  <shvaikalesh@gmail.com>
    218
  • trunk/Source/JavaScriptCore/builtins/PromisePrototype.js

    r230459 r248793  
    6969    "use strict";
    7070
    71     if (!@isPromise(this))
    72         @throwTypeError("|this| is not a Promise");
     71    if (!@isObject(this))
     72        @throwTypeError("|this| is not a object");
    7373
    7474    const constructor = @speciesConstructor(this, @Promise);
Note: See TracChangeset for help on using the changeset viewer.