summaryrefslogtreecommitdiffstats
path: root/js/src/vm
diff options
context:
space:
mode:
authorAndré Bargull <andre.bargull@gmail.com>2019-11-12 17:02:16 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-12 17:02:16 +0100
commit899be7cedbef6678280d56a4725f2697f808bbb5 (patch)
tree3a36479c41d486699379a5ffd420c5b236774616 /js/src/vm
parentb00601953bade944cd6df9cde6fcdd1f10d76feb (diff)
downloadUXP-899be7cedbef6678280d56a4725f2697f808bbb5.tar
UXP-899be7cedbef6678280d56a4725f2697f808bbb5.tar.gz
UXP-899be7cedbef6678280d56a4725f2697f808bbb5.tar.lz
UXP-899be7cedbef6678280d56a4725f2697f808bbb5.tar.xz
UXP-899be7cedbef6678280d56a4725f2697f808bbb5.zip
Issue #1283 - Implement Promise.prototype.finally()
This resolves #1283.
Diffstat (limited to 'js/src/vm')
-rw-r--r--js/src/vm/SelfHosting.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp
index 82d2cde64..833410465 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
};