WebKit Bugzilla
Attachment 370789 Details for
Bug 197600
: Implement Promise.allSettled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197600-20190529081756.patch (text/plain), 11.04 KB, created by
Dean Jackson
on 2019-05-28 15:17:57 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dean Jackson
Created:
2019-05-28 15:17:57 PDT
Size:
11.04 KB
patch
obsolete
>Subversion Revision: 245795 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index df5adc4cc725fa461b2ac8974f772558f11a5455..a240c54462a85924153ce4187b988eb85a13e76d 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,24 @@ >+2019-05-28 Dean Jackson <dino@apple.com> >+ >+ Implement Promise.allSettled >+ https://bugs.webkit.org/show_bug.cgi?id=197600 >+ <rdar://problem/50483885> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement Promise.allSettled >+ https://github.com/tc39/proposal-promise-allSettled/ >+ >+ Shipping in Firefox since version 68. >+ Shipping in V8 since https://chromium.googlesource.com/v8/v8.git/+/1f6d27e8df819b448712dface6ad367fb8de426b >+ >+ * builtins/PromiseConstructor.js: >+ (allSettled.newResolveRejectElements.resolveElement): >+ (allSettled.newResolveRejectElements.rejectElement): >+ (allSettled.newResolveRejectElements): >+ (allSettled): Added. >+ * runtime/JSPromiseConstructor.cpp: Add ref to allSettled. >+ > 2019-05-25 Tadeu Zagallo <tzagallo@apple.com> > > JITOperations getByVal should mark negative array indices as out-of-bounds >diff --git a/Source/JavaScriptCore/builtins/PromiseConstructor.js b/Source/JavaScriptCore/builtins/PromiseConstructor.js >index b13d146b7796cbd1ca476c124001ea536bce9588..c667afd2981bc4e50c6207852aca089b8b01783b 100644 >--- a/Source/JavaScriptCore/builtins/PromiseConstructor.js >+++ b/Source/JavaScriptCore/builtins/PromiseConstructor.js >@@ -75,6 +75,86 @@ function all(iterable) > return promiseCapability.@promise; > } > >+function allSettled(iterable) >+{ >+ "use strict"; >+ >+ if (!@isObject(this)) >+ @throwTypeError("|this| is not a object"); >+ >+ var promiseCapability = @newPromiseCapability(this); >+ >+ var values = []; >+ var remainingElementsCount = 1; >+ var index = 0; >+ >+ function newResolveRejectElements(index) >+ { >+ var alreadyCalled = false; >+ >+ var resolveElement = function @resolve(x) >+ { >+ if (alreadyCalled) >+ return @undefined; >+ alreadyCalled = true; >+ >+ var obj = { >+ status: "fulfilled", >+ value: x >+ }; >+ >+ @putByValDirect(values, index, obj); >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ return promiseCapability.@resolve.@call(@undefined, values); >+ >+ return @undefined; >+ }; >+ >+ var rejectElement = function @reject(x) >+ { >+ if (alreadyCalled) >+ return @undefined; >+ alreadyCalled = true; >+ >+ var obj = { >+ status: "rejected", >+ reason: x >+ }; >+ >+ @putByValDirect(values, index, obj); >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ return promiseCapability.@resolve.@call(@undefined, values); >+ >+ return @undefined; >+ }; >+ >+ return [resolveElement, rejectElement]; >+ } >+ >+ try { >+ for (var value of iterable) { >+ @putByValDirect(values, index, @undefined); >+ var nextPromise = this.resolve(value); >+ var [resolveElement, rejectElement] = newResolveRejectElements(index); >+ ++remainingElementsCount; >+ nextPromise.then(resolveElement, rejectElement); >+ ++index; >+ } >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ promiseCapability.@resolve.@call(@undefined, values); >+ } catch (error) { >+ promiseCapability.@reject.@call(@undefined, error); >+ } >+ >+ return promiseCapability.@promise; >+} >+ > function race(iterable) > { > "use strict"; >diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >index 74177c4b6a2556df21172317d1a5a5c4ba9282dc..053fed21cac809037d341905fc318fe11940913f 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >@@ -57,6 +57,7 @@ const ClassInfo JSPromiseConstructor::s_info = { "Function", &Base::s_info, &pro > reject JSBuiltin DontEnum|Function 1 > race JSBuiltin DontEnum|Function 1 > all JSBuiltin DontEnum|Function 1 >+ allSettled JSBuiltin DontEnum|Function 1 > @end > */ > >diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog >index 96d083c93a85dfc81c589526c3a439dbd8bd881a..3a77767dcc273dcae7fb11d9f649a097ba8e1f5d 100644 >--- a/JSTests/ChangeLog >+++ b/JSTests/ChangeLog >@@ -1,3 +1,17 @@ >+2019-05-28 Dean Jackson <dino@apple.com> >+ >+ Implement Promise.allSettled >+ https://bugs.webkit.org/show_bug.cgi?id=197600 >+ <rdar://problem/50483885> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Start testing Promise.allSettled. We pass most of the tests. >+ The ones that fail are similar to the Promise.all tests we already fail. >+ >+ * test262/config.yaml: Remove Promise.allSettled from skipped tests. >+ * test262/expectations.yaml: Add new expectations for allSettled tests. >+ > 2019-05-25 Tadeu Zagallo <tzagallo@apple.com> > > JITOperations getByVal should mark negative array indices as out-of-bounds >diff --git a/JSTests/test262/config.yaml b/JSTests/test262/config.yaml >index 85ccab58dfe35e94d02db0233a7345aca390190b..df1bbc79f3dca36df5f93ef0b754e4d63d37ae03 100644 >--- a/JSTests/test262/config.yaml >+++ b/JSTests/test262/config.yaml >@@ -31,8 +31,6 @@ skip: > - Intl.NumberFormat-unified > - Intl.RelativeTimeFormat > - Intl.Segmenter >- # https://bugs.webkit.org/show_bug.cgi?id=196332 >- - Promise.allSettled > files: > - test/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js > - test/built-ins/Array/prototype/unshift/length-near-integer-limit.js >diff --git a/JSTests/test262/expectations.yaml b/JSTests/test262/expectations.yaml >index 9cbe35d3128956cbc98e38be585bb427ee201af8..6427a7f9f76729881db82ec64001fb8a6259e8c5 100644 >--- a/JSTests/test262/expectations.yaml >+++ b/JSTests/test262/expectations.yaml >@@ -1086,9 +1086,27 @@ test/built-ins/Promise/all/invoke-resolve-get-error-close.js: > test/built-ins/Promise/all/invoke-resolve-get-once-multiple-calls.js: > default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë4û, ë1û) to be true' > strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë4û, ë1û) to be true' >+test/built-ins/Promise/all/invoke-resolve-get-once-no-calls.js: >+ default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë0û, ë1û) to be true' >+ strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë0û, ë1û) to be true' > test/built-ins/Promise/all/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/allSettled/invoke-resolve-get-error-close.js: >+ default: 'Test262Error: Expected SameValue(ë1û, ë0û) to be true' >+ strict mode: 'Test262Error: Expected SameValue(ë1û, ë0û) to be true' >+test/built-ins/Promise/allSettled/invoke-resolve-get-once-multiple-calls.js: >+ default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë4û, ë1û) to be true' >+ strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë4û, ë1û) to be true' >+test/built-ins/Promise/allSettled/invoke-resolve-get-once-no-calls.js: >+ default: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë0û, ë1û) to be true' >+ strict mode: 'Test262Error: Got `resolve` only once for each iterated value Expected SameValue(ë0û, ë1û) to be true' >+test/built-ins/Promise/allSettled/reject-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/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/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' >@@ -1766,6 +1784,9 @@ test/built-ins/WeakMap/proto-from-ctor-realm.js: > test/built-ins/WeakSet/proto-from-ctor-realm.js: > default: 'Test262Error: Expected SameValue(ë[object WeakSet]û, ë[object WeakSet]û) to be true' > strict mode: 'Test262Error: Expected SameValue(ë[object WeakSet]û, ë[object WeakSet]û) to be true' >+test/intl402/Collator/ignore-invalid-unicode-ext-values.js: >+ default: 'Test262Error: Locale en is affected by key co; value standard. Expected SameValue(ëenû, ëen-AUû) to be true' >+ strict mode: 'Test262Error: Locale en is affected by key co; value standard. Expected SameValue(ëenû, ëen-AUû) to be true' > test/intl402/Collator/missing-unicode-ext-value-defaults-to-true.js: > default: 'Test262Error: "kn" should be returned in locale. Expected SameValue(ëfalseû, ëtrueû) to be true' > strict mode: 'Test262Error: "kn" should be returned in locale. Expected SameValue(ëfalseû, ëtrueû) to be true' >@@ -1793,6 +1814,9 @@ test/intl402/NumberFormat/prototype/format/format-function-name.js: > test/intl402/NumberFormat/prototype/format/format-negative-numbers.js: > default: 'Test262Error: Intl.NumberFormat is formatting 0 and -0 the same way. Expected SameValue(ë0û, ë0û) to be false' > strict mode: 'Test262Error: Intl.NumberFormat is formatting 0 and -0 the same way. Expected SameValue(ë0û, ë0û) to be false' >+test/intl402/fallback-locales-are-supported.js: >+ default: "Test262Error: Locale zh-Hans-CN is supported, but fallback zh-Hans isn't. Expected SameValue(ë-1û, ë-1û) to be false (Testing with Collator.)" >+ strict mode: "Test262Error: Locale zh-Hans-CN is supported, but fallback zh-Hans isn't. Expected SameValue(ë-1û, ë-1û) to be false (Testing with Collator.)" > test/intl402/supportedLocalesOf-returned-array-elements-are-not-frozen.js: > default: 'Test262Error: Property 0 of object returned by SupportedLocales is not writable. Expected SameValue(ëfalseû, ëtrueû) to be true (Testing with Collator.)' > strict mode: 'Test262Error: Property 0 of object returned by SupportedLocales is not writable. Expected SameValue(ëfalseû, ëtrueû) to be true (Testing with Collator.)'
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
Flags:
keith_miller
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197600
:
369095
|
369096
|
369149
|
369161
| 370789