Bug 1429425 - contentScripts.register runAt option should be set to document_idle when missing.
MozReview-Commit-ID: 1D1J8zmVWqC
--- a/toolkit/components/extensions/ext-contentScripts.js
+++ b/toolkit/components/extensions/ext-contentScripts.js
@@ -63,17 +63,17 @@ class ContentScriptParent {
const options = {
matches: details.matches,
exclude_matches: details.excludeMatches,
include_globs: details.includeGlobs,
exclude_globs: details.excludeGlobs,
all_frames: details.allFrames,
match_about_blank: details.matchAboutBlank,
- run_at: details.runAt,
+ run_at: details.runAt || "document_idle",
js: [],
css: [],
};
const convertCodeToURL = (data, mime) => {
const blob = new context.cloneScope.Blob(data, {type: mime});
const blobURL = context.cloneScope.URL.createObjectURL(blob);
--- a/toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
@@ -303,17 +303,16 @@ add_task(async function test_contentscri
js: [{code: `(${textScriptCodeEnd})()`}],
runAt: "document_end",
},
{
matches: ["http://localhost/*/file_sample.html"],
js: [{code: `(${textScriptCodeIdle})()`}],
runAt: "document_idle",
},
-
// Extension URLs.
{
matches: ["http://localhost/*/file_sample.html"],
js: [{file: "content_script_start.js"}],
runAt: "document_start",
},
{
matches: ["http://localhost/*/file_sample.html"],
@@ -323,17 +322,17 @@ add_task(async function test_contentscri
{
matches: ["http://localhost/*/file_sample.html"],
js: [{file: "content_script_idle.js"}],
runAt: "document_idle",
},
{
matches: ["http://localhost/*/file_sample.html"],
js: [{file: "content_script.js"}],
- runAt: "document_idle",
+ // "runAt" is not specified here to ensure that it defaults to document_idle when missing.
},
];
const expectedAPIs = ["unregister"];
for (const scriptOptions of content_scripts) {
const script = await browser.contentScripts.register(scriptOptions);
const actualAPIs = Object.keys(script);