summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/loader
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /js/xpconnect/loader
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/xpconnect/loader/mozJSModuleLoader.cpp28
-rw-r--r--js/xpconnect/loader/mozJSModuleLoader.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/js/xpconnect/loader/mozJSModuleLoader.cpp b/js/xpconnect/loader/mozJSModuleLoader.cpp
index 017ac32b3b..cdf4df1970 100644
--- a/js/xpconnect/loader/mozJSModuleLoader.cpp
+++ b/js/xpconnect/loader/mozJSModuleLoader.cpp
@@ -1279,7 +1279,10 @@ nsresult mozJSModuleLoader::GetScriptForLocation(
}
void mozJSModuleLoader::UnloadModules() {
+ MOZ_ASSERT(!mIsUnloaded);
+
mInitialized = false;
+ mIsUnloaded = true;
if (mLoaderGlobal) {
MOZ_ASSERT(JS_HasExtensibleLexicalEnvironment(mLoaderGlobal));
@@ -1387,6 +1390,11 @@ nsresult mozJSModuleLoader::IsModuleLoaded(const nsACString& aLocation,
bool* retval) {
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
+ if (mIsUnloaded) {
+ *retval = false;
+ return NS_OK;
+ }
+
mInitialized = true;
ModuleLoaderInfo info(aLocation);
if (mImports.Get(info.Key())) {
@@ -1420,6 +1428,11 @@ nsresult mozJSModuleLoader::IsJSModuleLoaded(const nsACString& aLocation,
bool* retval) {
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
+ if (mIsUnloaded) {
+ *retval = false;
+ return NS_OK;
+ }
+
mInitialized = true;
ModuleLoaderInfo info(aLocation);
if (mImports.Get(info.Key())) {
@@ -1435,6 +1448,11 @@ nsresult mozJSModuleLoader::IsESModuleLoaded(const nsACString& aLocation,
bool* retval) {
MOZ_ASSERT(nsContentUtils::IsCallerChrome());
+ if (mIsUnloaded) {
+ *retval = false;
+ return NS_OK;
+ }
+
mInitialized = true;
ModuleLoaderInfo info(aLocation);
@@ -1728,6 +1746,11 @@ nsresult mozJSModuleLoader::Import(JSContext* aCx, const nsACString& aLocation,
JS::MutableHandleObject aModuleGlobal,
JS::MutableHandleObject aModuleExports,
bool aIgnoreExports) {
+ if (mIsUnloaded) {
+ JS_ReportErrorASCII(aCx, "Module loaded is already unloaded");
+ return NS_ERROR_FAILURE;
+ }
+
mInitialized = true;
AUTO_PROFILER_MARKER_TEXT(
@@ -2013,6 +2036,11 @@ nsresult mozJSModuleLoader::ImportESModule(
aSkipCheck /* = SkipCheckForBrokenURLOrZeroSized::No */) {
using namespace JS::loader;
+ if (mIsUnloaded) {
+ JS_ReportErrorASCII(aCx, "Module loaded is already unloaded");
+ return NS_ERROR_FAILURE;
+ }
+
mInitialized = true;
// Called from ChromeUtils::ImportESModule.
diff --git a/js/xpconnect/loader/mozJSModuleLoader.h b/js/xpconnect/loader/mozJSModuleLoader.h
index ac118c507d..b5e81a4b25 100644
--- a/js/xpconnect/loader/mozJSModuleLoader.h
+++ b/js/xpconnect/loader/mozJSModuleLoader.h
@@ -290,6 +290,7 @@ class mozJSModuleLoader final : public nsIMemoryReporter {
nsClassHashtable<nsCStringHashKey, nsCString> mLocations;
bool mInitialized;
+ bool mIsUnloaded = false;
#ifdef DEBUG
bool mIsInitializingLoaderGlobal = false;
#endif