diff options
author | André Bargull <andre.bargull@gmail.com> | 2019-11-12 17:02:16 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-11-12 17:02:16 +0100 |
commit | 899be7cedbef6678280d56a4725f2697f808bbb5 (patch) | |
tree | 3a36479c41d486699379a5ffd420c5b236774616 /js/src/vm/SelfHosting.cpp | |
parent | b00601953bade944cd6df9cde6fcdd1f10d76feb (diff) | |
download | uxp-899be7cedbef6678280d56a4725f2697f808bbb5.tar.gz |
Issue #1283 - Implement Promise.prototype.finally()
This resolves #1283.
Diffstat (limited to 'js/src/vm/SelfHosting.cpp')
-rw-r--r-- | js/src/vm/SelfHosting.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 82d2cde642..8334104652 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2102,6 +2102,21 @@ intrinsic_ModuleNamespaceExports(JSContext* cx, unsigned argc, Value* vp) return true; } +static bool +intrinsic_PromiseResolve(JSContext* cx, unsigned argc, Value* vp) +{ + CallArgs args = CallArgsFromVp(argc, vp); + MOZ_ASSERT(args.length() == 2); + + RootedObject constructor(cx, &args[0].toObject()); + JSObject* promise = js::PromiseResolve(cx, constructor, args[1]); + if (!promise) + return false; + + args.rval().setObject(*promise); + return true; +} + // The self-hosting global isn't initialized with the normal set of builtins. // Instead, individual C++-implemented functions that're required by // self-hosted code are defined as global functions. Accessing these @@ -2498,6 +2513,10 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("AddModuleNamespaceBinding", intrinsic_AddModuleNamespaceBinding, 4, 0), JS_FN("ModuleNamespaceExports", intrinsic_ModuleNamespaceExports, 1, 0), + JS_FN("IsPromiseObject", intrinsic_IsInstanceOfBuiltin<PromiseObject>, 1, 0), + JS_FN("CallPromiseMethodIfWrapped", CallNonGenericSelfhostedMethod<Is<PromiseObject>>, 2, 0), + JS_FN("PromiseResolve", intrinsic_PromiseResolve, 2, 0), + JS_FS_END }; |