Bug 1429425 - contentScripts.register runAt option should be set to document_idle when missing. r=mixedpuppy,zombie
authorLuca Greco <lgreco@mozilla.com>
Wed, 31 Jan 2018 20:55:39 +0100
changeset 402085 0e0273e2fb91bf46500a23152bbf8f4e9a58f104
parent 402084 6bcaae60c82e02e3c1f549745d77653e96b06583
child 402086 7eed1367d341d8ca200d454d95e4ba0c399dc1e2
push id59002
push userluca.greco@alcacoop.it
push dateThu, 01 Feb 2018 16:41:01 +0000
treeherderautoland@0e0273e2fb91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, zombie
bugs1429425
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1429425 - contentScripts.register runAt option should be set to document_idle when missing. r=mixedpuppy,zombie MozReview-Commit-ID: 1D1J8zmVWqC
toolkit/components/extensions/ext-contentScripts.js
toolkit/components/extensions/test/xpcshell/test_ext_contentScripts_register.js
--- 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);