mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-17 01:43:08 +09:00
Issue #618 - Further align error handling for module scripts with the spec
Ref: BZ 1388728
This commit is contained in:
parent
c65ca2ca58
commit
743bdc04fb
6 changed files with 280 additions and 89 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue