diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/components/extensions/ExtensionContent.sys.mjs | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/ExtensionContent.sys.mjs')
-rw-r--r-- | toolkit/components/extensions/ExtensionContent.sys.mjs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/toolkit/components/extensions/ExtensionContent.sys.mjs b/toolkit/components/extensions/ExtensionContent.sys.mjs index a2fce282ee..83d17ca84e 100644 --- a/toolkit/components/extensions/ExtensionContent.sys.mjs +++ b/toolkit/components/extensions/ExtensionContent.sys.mjs @@ -475,6 +475,10 @@ class Script { * execution is complete. */ async inject(context, reportExceptions = true) { + // NOTE: Avoid unnecessary use of "await" in this function, because doing + // so can delay script execution beyond the scheduled point. In particular, + // document_start scripts should run "immediately" in most cases. + DocumentManager.lazyInit(); if (this.requiresCleanup) { context.addScript(this); @@ -552,11 +556,19 @@ class Script { let scripts = this.getCompiledScripts(context); if (scripts instanceof Promise) { + // Note: in theory, the following async await could result in script + // execution being scheduled too late. That would be an issue for + // document_start scripts. In practice, this is not a problem because the + // compiled script is cached in the process, and preloading to compile + // starts as soon as the network request for the document has been + // received (see ExtensionPolicyService::CheckRequest). scripts = await scripts; } - // Make sure we've injected any related CSS before we run content scripts. - await cssPromise; + if (cssPromise) { + // Make sure we've injected any related CSS before we run content scripts. + await cssPromise; + } let result; @@ -623,7 +635,7 @@ class Script { p.catch(error => { Services.console.logMessage( new ScriptError( - `${error.name}: ${error.message}`, + error.toString(), error.fileName, null, error.lineNumber, |