summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-03 14:15:55 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-03 14:15:55 +0000
commit8473be474446ae1e60468b87503654efafddf3e2 (patch)
tree79df6e5f4d8f963d71cc25cd81020e7c6f400197
parentb36794a7a5bbb4bf5145a82e3ceb87d94431fbbf (diff)
downloadaura-central-8473be474446ae1e60468b87503654efafddf3e2.tar.gz
Issue mcp-graveyard/UXP%618 - Add APIs to query module record errors
Ref: BZ 1388728
-rw-r--r--js/src/jsapi.cpp14
-rw-r--r--js/src/jsapi.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index 53ea4ebc6..f8c34885b 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4739,6 +4739,20 @@ JS::GetModuleScript(JSContext* cx, JS::HandleObject moduleArg)
return moduleArg->as<ModuleObject>().script();
}
+JS_PUBLIC_API(bool)
+JS::IsModuleErrored(JSObject* moduleArg)
+{
+ AssertHeapIsIdle();
+ return moduleArg->as<ModuleObject>().status() == MODULE_STATUS_ERRORED;
+}
+
+JS_PUBLIC_API(JS::Value)
+JS::GetModuleError(JSObject* moduleArg)
+{
+ AssertHeapIsIdle();
+ return moduleArg->as<ModuleObject>().error();
+}
+
JS_PUBLIC_API(JSObject*)
JS_New(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& inputArgs)
{
diff --git a/js/src/jsapi.h b/js/src/jsapi.h
index 9138a4a92..5e0259587 100644
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4396,6 +4396,12 @@ GetRequestedModules(JSContext* cx, JS::HandleObject moduleRecord);
extern JS_PUBLIC_API(JSScript*)
GetModuleScript(JSContext* cx, JS::HandleObject moduleRecord);
+extern JS_PUBLIC_API(bool)
+IsModuleErrored(JSObject* moduleRecord);
+
+extern JS_PUBLIC_API(JS::Value)
+GetModuleError(JSObject* moduleRecord);
+
} /* namespace JS */
extern JS_PUBLIC_API(bool)