summaryrefslogtreecommitdiffstats
path: root/dom/script/ModuleLoadRequest.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-04 16:28:30 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-10 18:30:48 +0000
commitf6a6900a6b14d1d54da46370015b28d4d8a152a7 (patch)
tree6af248540f32f4427e9a01164804aca505aae379 /dom/script/ModuleLoadRequest.cpp
parent40aad1a2209607b973170f4fb64548e5d8103402 (diff)
downloadUXP-f6a6900a6b14d1d54da46370015b28d4d8a152a7.tar
UXP-f6a6900a6b14d1d54da46370015b28d4d8a152a7.tar.gz
UXP-f6a6900a6b14d1d54da46370015b28d4d8a152a7.tar.lz
UXP-f6a6900a6b14d1d54da46370015b28d4d8a152a7.tar.xz
UXP-f6a6900a6b14d1d54da46370015b28d4d8a152a7.zip
Issue #618 - Further align error handling for module scripts with the spec
Ref: BZ 1388728
Diffstat (limited to 'dom/script/ModuleLoadRequest.cpp')
-rw-r--r--dom/script/ModuleLoadRequest.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/dom/script/ModuleLoadRequest.cpp b/dom/script/ModuleLoadRequest.cpp
index 8871dcdab..d62214304 100644
--- a/dom/script/ModuleLoadRequest.cpp
+++ b/dom/script/ModuleLoadRequest.cpp
@@ -43,10 +43,16 @@ void ModuleLoadRequest::Cancel()
ScriptLoadRequest::Cancel();
mModuleScript = nullptr;
mProgress = ScriptLoadRequest::Progress::Ready;
+ CancelImports();
+ mReady.RejectIfExists(NS_ERROR_DOM_ABORT_ERR, __func__);
+}
+
+void
+ModuleLoadRequest::CancelImports()
+{
for (size_t i = 0; i < mImports.Length(); i++) {
mImports[i]->Cancel();
}
- mReady.RejectIfExists(NS_ERROR_FAILURE, __func__);
}
void
@@ -77,25 +83,53 @@ ModuleLoadRequest::ModuleLoaded()
// been loaded.
mModuleScript = mLoader->GetFetchedModule(mURI);
+ if (!mModuleScript || mModuleScript->IsErrored()) {
+ ModuleErrored();
+ return;
+ }
+
mLoader->StartFetchingModuleDependencies(this);
}
void
+ModuleLoadRequest::ModuleErrored()
+{
+ mLoader->CheckModuleDependenciesLoaded(this);
+ MOZ_ASSERT(!mModuleScript || mModuleScript->IsErrored());
+
+ CancelImports();
+ SetReady();
+ LoadFinished();
+}
+
+void
ModuleLoadRequest::DependenciesLoaded()
{
// The module and all of its dependencies have been successfully fetched and
// compiled.
+ MOZ_ASSERT(mModuleScript);
+
+ mLoader->CheckModuleDependenciesLoaded(this);
SetReady();
- mLoader->ProcessLoadedModuleTree(this);
- mLoader = nullptr;
- mParent = nullptr;
+ LoadFinished();
}
void
ModuleLoadRequest::LoadFailed()
{
+ // We failed to load the source text or an error occurred unrelated to the
+ // content of the module (e.g. OOM).
+
+ MOZ_ASSERT(!mModuleScript);
+
Cancel();
+ LoadFinished();
+}
+
+void
+ModuleLoadRequest::LoadFinished()
+{
mLoader->ProcessLoadedModuleTree(this);
mLoader = nullptr;
mParent = nullptr;