diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /js/xpconnect/loader/mozJSModuleLoader.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/xpconnect/loader/mozJSModuleLoader.cpp')
-rw-r--r-- | js/xpconnect/loader/mozJSModuleLoader.cpp | 28 |
1 files changed, 28 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. |