summaryrefslogtreecommitdiffstats
path: root/dom/script/ModuleScript.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-08 12:58:30 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-08 12:58:30 +0000
commit43e0632cd474265ef0660bf881f4472996c8ad5a (patch)
tree70b3b307f37c54a66419995c74a3ac2d06ccb19a /dom/script/ModuleScript.cpp
parent786e344698c5a577ea82e2fa0d29faf2a2d851ea (diff)
downloadUXP-43e0632cd474265ef0660bf881f4472996c8ad5a.tar
UXP-43e0632cd474265ef0660bf881f4472996c8ad5a.tar.gz
UXP-43e0632cd474265ef0660bf881f4472996c8ad5a.tar.lz
UXP-43e0632cd474265ef0660bf881f4472996c8ad5a.tar.xz
UXP-43e0632cd474265ef0660bf881f4472996c8ad5a.zip
Issue #618 - Align error handling for module scripts with the spec (again)
This updates module implementation to match spec regarding handling of instantiation errors, after it was changed yet again, this time to not remember instantiation errors, but instead immediately rethrow applicable ones. Ref: BZ 1420420
Diffstat (limited to 'dom/script/ModuleScript.cpp')
-rw-r--r--dom/script/ModuleScript.cpp43
1 files changed, 17 insertions, 26 deletions
diff --git a/dom/script/ModuleScript.cpp b/dom/script/ModuleScript.cpp
index 28b97a3cb..1bf9d0b0f 100644
--- a/dom/script/ModuleScript.cpp
+++ b/dom/script/ModuleScript.cpp
@@ -26,7 +26,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ModuleScript)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBaseURL)
tmp->UnlinkModuleRecord();
- tmp->mError.setUndefined();
+ tmp->mParseError.setUndefined();
+ tmp->mErrorToRethrow.setUndefined();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ModuleScript)
@@ -35,7 +36,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ModuleScript)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mModuleRecord)
- NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mError)
+ NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mParseError)
+ NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mErrorToRethrow)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleScript)
@@ -48,7 +50,8 @@ ModuleScript::ModuleScript(ScriptLoader *aLoader, nsIURI* aBaseURL)
MOZ_ASSERT(mLoader);
MOZ_ASSERT(mBaseURL);
MOZ_ASSERT(!mModuleRecord);
- MOZ_ASSERT(mError.isUndefined());
+ MOZ_ASSERT(!HasParseError());
+ MOZ_ASSERT(!HasErrorToRethrow());
}
void
@@ -74,7 +77,8 @@ void
ModuleScript::SetModuleRecord(JS::Handle<JSObject*> aModuleRecord)
{
MOZ_ASSERT(!mModuleRecord);
- MOZ_ASSERT(mError.isUndefined());
+ MOZ_ASSERT(!HasParseError());
+ MOZ_ASSERT(!HasErrorToRethrow());
mModuleRecord = aModuleRecord;
@@ -85,37 +89,24 @@ ModuleScript::SetModuleRecord(JS::Handle<JSObject*> aModuleRecord)
}
void
-ModuleScript::SetPreInstantiationError(const JS::Value& aError)
+ModuleScript::SetParseError(const JS::Value& aError)
{
MOZ_ASSERT(!aError.isUndefined());
+ MOZ_ASSERT(!HasParseError());
+ MOZ_ASSERT(!HasErrorToRethrow());
UnlinkModuleRecord();
- mError = aError;
-
+ mParseError = aError;
HoldJSObjects(this);
}
-bool
-ModuleScript::IsErrored() const
-{
- if (!mModuleRecord) {
- MOZ_ASSERT(!mError.isUndefined());
- return true;
- }
-
- return JS::IsModuleErrored(mModuleRecord);
-}
-
-JS::Value
-ModuleScript::Error() const
+void
+ModuleScript::SetErrorToRethrow(const JS::Value& aError)
{
- MOZ_ASSERT(IsErrored());
-
- if (!mModuleRecord) {
- return mError;
- }
+ MOZ_ASSERT(!aError.isUndefined());
+ MOZ_ASSERT(!HasErrorToRethrow());
- return JS::GetModuleError(mModuleRecord);
+ mErrorToRethrow = aError;
}
} // dom namespace