Bug 1464711 - Fix typo in ExtensionContent script.requiresCleanup getter. r=zombie
authorLuca Greco <lgreco@mozilla.com>
Thu, 24 Jan 2019 17:18:22 +0000
changeset 515312 ca8f8514f60dddc015b4a0644520cc1263479ae9
parent 515311 8c7dea6754c6929e05bbd313a9f27c2c96f4148c
child 515314 a2e14bfdfb0076b2bc425689873e36d5d3987ec2
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszombie
bugs1464711
milestone66.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 1464711 - Fix typo in ExtensionContent script.requiresCleanup getter. r=zombie This patch fixes the typo in the requiresCleanup getter and adds an additional step in the automated tests to verify that the scripts created by browser.tabs.removeCSS are not being added to the content scripts that requires cleanup. Differential Revision: https://phabricator.services.mozilla.com/D17345
browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
toolkit/components/extensions/ExtensionContent.jsm
--- a/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js
@@ -106,12 +106,33 @@ add_task(async function testExecuteScrip
       "file2.css": "* { color: rgb(0, 113, 4) }",
     },
   });
 
   await extension.startup();
 
   await extension.awaitFinish("removeCSS");
 
+  // Verify that scripts created by tabs.removeCSS are not added to the content scripts
+  // that requires cleanup (Bug 1464711).
+  await ContentTask.spawn(tab.linkedBrowser, extension.id, async (extId) => {
+    const {
+      DocumentManager,
+    } = ChromeUtils.import("resource://gre/modules/ExtensionContent.jsm", {});
+
+    let contentScriptContext = Array.from(
+      DocumentManager.getContexts(content.window).values()
+    ).find(context => context.extension.id === extId);
+
+    for (let script of contentScriptContext.scripts) {
+      if (script.matcher.removeCSS && script.requiresCleanup) {
+        throw new Error("tabs.removeCSS scripts should not require cleanup");
+      }
+    }
+  }).catch(err => {
+    // Log the error so that it is easy to see where the failure is coming from.
+    ok(false, err);
+  });
+
   await extension.unload();
 
   BrowserTestUtils.removeTab(tab);
 });
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -307,17 +307,17 @@ class Script {
 
     if (matcher.wantReturnValue) {
       this.compileScripts();
       this.loadCSS();
     }
   }
 
   get requiresCleanup() {
-    return !this.removeCss && (this.css.length > 0 || this.cssCodeHash);
+    return !this.removeCSS && (this.css.length > 0 || this.cssCodeHash);
   }
 
   async addCSSCode(cssCode) {
     if (!cssCode) {
       return;
     }
 
     // Store the hash of the cssCode.