Issue #1691 - Part 8: Fix --enable-debug builds and continue dynamic module import changes. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012 Support import from timeout handlers by associating the initiating script with the compiled JSScript. Fix error message that covers all import() failures that don't throw a JS exception. https://bugzilla.mozilla.org/show_bug.cgi?id=1331662 Partial - Replace nsJSUtils::EvaluateString calls by ExecutionContext scopes. Left EvaluateString() in nsXBLProtoImplField.cpp until ExecutionContext errors can be fixed.

(cherry picked from commit 22fcfc77971a9bb204df664c474681f4dcf54211)
This commit is contained in:
Brian Smith 2023-04-21 17:35:04 -05:00 • committed by roytam1
commit 1109559a5d
20 changed files with 166 additions and 24 deletions

View file

@ -1072,7 +1072,7 @@ void ScriptLoader::FinishDynamicImport(JSContext* aCx,
if (NS_FAILED(aResult)) {
MOZ_ASSERT(!JS_IsExceptionPending(aCx));
JS_ReportErrorNumberUC(aCx, js::GetErrorMessage, nullptr,
JSMSG_IMPORT_SCRIPT_NOT_FOUND);
JSMSG_DYNAMIC_IMPORT_FAILED);
}
JS::Rooted<JS::Value> referencingScript(aCx,
@ -2374,6 +2374,15 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
return rv;
}
/* static */ LoadedScript* ScriptLoader::GetActiveScript(JSContext* aCx) {
JS::Value value = JS::GetScriptedCallerPrivate(aCx);
if (value.isUndefined()) {
return nullptr;
}
return static_cast<LoadedScript*>(value.toPrivate());
}
void
ScriptLoader::ProcessPendingRequestsAsync()
{

View file

@ -34,6 +34,7 @@ namespace mozilla {
namespace dom {
class AutoJSAPI;
class LoadedScript;
class ModuleLoadRequest;
class ModuleScript;
class ScriptLoadRequestList;
@ -586,6 +587,12 @@ public:
void FinishDynamicImport(JSContext* aCx, ModuleLoadRequest* aRequest,
nsresult aResult);
/*
* Get the currently active script. This is used as the initiating script when
* executing timeout handler scripts.
*/
static LoadedScript* GetActiveScript(JSContext* aCx);
nsIDocument* GetDocument() const { return mDocument; }
private:

View file

@ -12,6 +12,7 @@ XPIDL_MODULE = 'dom'
EXPORTS += ['nsIScriptElement.h']
EXPORTS.mozilla.dom += [
'ModuleScript.h',
'ScriptElement.h',
'ScriptLoader.h',
'ScriptSettings.h',