tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9ee6c601a83a9b06b4e96e60c7c68d60fc83f073
parent d675f72925235c31495d00146b8d404aa2b8de2a
Author: Cornelius Emase <corneliuslochipi@gmail.com>
Date:   Tue, 16 Dec 2025 02:20:00 +0000

Bug 2003970 - Add NIGHTLY-only Promise.allKeyed / allSettledKeyed stub. r=arai

Add NIGHTLY-only stubs for Promise.allKeyed and allSettledKeyed,
update promise_static_methods, and fix Xray tests to match.

Differential Revision: https://phabricator.services.mozilla.com/D275520

Diffstat:
Mjs/src/builtin/Promise.cpp | 29+++++++++++++++++++++++++++++
Mjs/src/vm/CommonPropertyNames.h | 2++
Mjs/src/vm/JSObject.cpp | 6++++++
Mjs/xpconnect/tests/chrome/test_xrayToJS.xhtml | 13++++++++++---
4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp @@ -3602,6 +3602,31 @@ static bool Promise_static_all(JSContext* cx, unsigned argc, Value* vp) { return CommonPromiseCombinator(cx, args, CombinatorKind::All); } +#ifdef NIGHTLY_BUILD +/** + * Await Dictionary Proposal + * + * Promise.allKeyed + * https://tc39.es/proposal-await-dictionary/#sec-promise.allkeyed + */ +static bool Promise_static_allKeyed(JSContext* cx, unsigned argc, Value* vp) { + JS_ReportErrorASCII(cx, "Promise.allKeyed is not yet implemented"); + return false; +} + +/** + * Await Dictionary Proposal + * + * Promise.allSettledKeyed + * https://tc39.es/proposal-await-dictionary/#sec-promise.allsettledkeyed + */ +static bool Promise_static_allSettledKeyed(JSContext* cx, unsigned argc, + Value* vp) { + JS_ReportErrorASCII(cx, "Promise.allSettledKeyed is not yet implemented"); + return false; +} +#endif + [[nodiscard]] static bool PerformPromiseThen( JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_, HandleValue onRejected_, Handle<PromiseCapability> resultCapability); @@ -7906,6 +7931,10 @@ static const JSPropertySpec promise_properties[] = { static const JSFunctionSpec promise_static_methods[] = { JS_FN("all", Promise_static_all, 1, 0), JS_FN("allSettled", Promise_static_allSettled, 1, 0), +#ifdef NIGHTLY_BUILD + JS_FN("allKeyed", Promise_static_allKeyed, 1, 0), + JS_FN("allSettledKeyed", Promise_static_allSettledKeyed, 1, 0), +#endif JS_FN("any", Promise_static_any, 1, 0), JS_FN("race", Promise_static_race, 1, 0), JS_FN("reject", Promise_reject, 1, 0), diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h @@ -28,6 +28,8 @@ IF_DECORATORS(MACRO_(addInitializer, "addInitializer")) \ MACRO_(address, "address") \ MACRO_(all, "all") \ + MACRO_(allKeyed, "allKeyed") \ + MACRO_(allSettledKeyed, "allSettledKeyed") \ MACRO_(allowContentIter, "allowContentIter") \ MACRO_(allowContentIterWith, "allowContentIterWith") \ MACRO_(allowContentIterWithNext, "allowContentIterWithNext") \ diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp @@ -2256,6 +2256,12 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, return true; } } + if (key == JSProto_Promise && !JS::Prefs::experimental_promise_allkeyed()) { + if (id == NameToId(cx->names().allKeyed) || + id == NameToId(cx->names().allSettledKeyed)) { + return true; + } + } #endif if (key == JSProto_Function && diff --git a/js/xpconnect/tests/chrome/test_xrayToJS.xhtml b/js/xpconnect/tests/chrome/test_xrayToJS.xhtml @@ -299,9 +299,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681 gPrototypeProperties.Promise = ["constructor", "catch", "then", "finally", Symbol.toStringTag]; - gConstructorProperties.Promise = - constructorProps(["resolve", "reject", "all", "allSettled", "any", "race", "try", - "withResolvers", Symbol.species]); + + if ("allKeyed" in Promise) { + gConstructorProperties.Promise = + constructorProps(["resolve", "reject", "all", "allSettled", "allKeyed", "allSettledKeyed", "any", "race", "try", + "withResolvers", Symbol.species]); + } else { + gConstructorProperties.Promise = + constructorProps(["resolve", "reject", "all", "allSettled", "any", "race", "try", + "withResolvers", Symbol.species]); + } gPrototypeProperties.ArrayBuffer = ["constructor", "byteLength", "detached", "slice", Symbol.toStringTag, "transfer", "transferToFixedLength", "maxByteLength", "resizable", "resize"];