Backed out 2 changesets (bug 1343583) at developer's request a=backout
authorWes Kocher <wkocher@mozilla.com>
Thu, 02 Mar 2017 10:44:07 -0800
changeset 492209 ccbea1069d10f6e9099df7ab0ad672bda3b8ed3b
parent 492208 d85992359e22a8dad8535d3c9c6606f6f79f4aec
child 492210 c2c3aa1ebb128cc7078cc93a8dd01b177a056576
push id47559
push userbmo:jryans@gmail.com
push dateThu, 02 Mar 2017 22:39:35 +0000
reviewersbackout
bugs1343583
milestone54.0a1
backs out10fccfc11db1afa434006d83a9a93d8ed12f8800
3b9e06e3d9b812b219fbdfa91e185a6fb998a057
Backed out 2 changesets (bug 1343583) at developer's request a=backout Backed out changeset 10fccfc11db1 (bug 1343583) Backed out changeset 3b9e06e3d9b8 (bug 1343583) MozReview-Commit-ID: FKEYDU9MZIa
browser/components/extensions/test/browser/browser_ext_browserAction_context.js
browser/components/extensions/test/browser/browser_ext_pageAction_context.js
browser/components/extensions/test/browser/browser_ext_pageAction_title.js
browser/components/extensions/test/browser/browser_ext_sidebarAction_context.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
testing/mochitest/tests/SimpleTest/ExtensionTestUtils.js
toolkit/components/extensions/ExtensionTestCommon.jsm
toolkit/components/extensions/test/mochitest/test_ext_clipboard.html
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
@@ -170,17 +170,17 @@ add_task(function* testTabSwitchContext(
       },
 
       "default.png": imageBuffer,
       "default-2.png": imageBuffer,
       "1.png": imageBuffer,
       "2.png": imageBuffer,
     },
 
-    getTests: function(tabs, expectDefaults) {
+    getTests(tabs, expectDefaults) {
       const DEFAULT_BADGE_COLOR = [0xd9, 0, 0, 255];
 
       let details = [
         {"icon": browser.runtime.getURL("default.png"),
          "popup": browser.runtime.getURL("default.html"),
          "title": "Default Title",
          "badge": "",
          "badgeBackgroundColor": DEFAULT_BADGE_COLOR},
@@ -326,17 +326,17 @@ add_task(function* testDefaultTitle() {
 
       "permissions": ["tabs"],
     },
 
     files: {
       "icon.png": imageBuffer,
     },
 
-    getTests: function(tabs, expectDefaults) {
+    getTests(tabs, expectDefaults) {
       const DEFAULT_BADGE_COLOR = [0xd9, 0, 0, 255];
 
       let details = [
         {"title": "Foo Extension",
          "popup": "",
          "badge": "",
          "badgeBackgroundColor": DEFAULT_BADGE_COLOR,
          "icon": browser.runtime.getURL("icon.png")},
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
@@ -48,17 +48,17 @@ add_task(function* testTabSwitchContext(
         },
       },
 
       "default.png": imageBuffer,
       "1.png": imageBuffer,
       "2.png": imageBuffer,
     },
 
-    getTests: function(tabs) {
+    getTests(tabs) {
       let details = [
         {"icon": browser.runtime.getURL("default.png"),
          "popup": browser.runtime.getURL("default.html"),
          "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("1.png"),
          "popup": browser.runtime.getURL("default.html"),
          "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("2.png"),
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_title.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_title.js
@@ -48,17 +48,17 @@ add_task(function* testTabSwitchContext(
         },
       },
 
       "default.png": imageBuffer,
       "1.png": imageBuffer,
       "2.png": imageBuffer,
     },
 
-    getTests: function(tabs) {
+    getTests(tabs) {
       let details = [
         {"icon": browser.runtime.getURL("default.png"),
          "popup": browser.runtime.getURL("default.html"),
          "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("1.png"),
          "popup": browser.runtime.getURL("default.html"),
          "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("2.png"),
@@ -185,17 +185,17 @@ add_task(function* testDefaultTitle() {
 
       "permissions": ["tabs"],
     },
 
     files: {
       "icon.png": imageBuffer,
     },
 
-    getTests: function(tabs) {
+    getTests(tabs) {
       let details = [
         {"title": "Foo Extension",
          "popup": "",
          "icon": browser.runtime.getURL("icon.png")},
         {"title": "Foo Title",
          "popup": "",
          "icon": browser.runtime.getURL("icon.png")},
       ];
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_context.js
@@ -166,17 +166,17 @@ add_task(function* testTabSwitchContext(
       },
 
       "default.png": imageBuffer,
       "default-2.png": imageBuffer,
       "1.png": imageBuffer,
       "2.png": imageBuffer,
     },
 
-    getTests: function(tabs, expectDefaults) {
+    getTests(tabs, expectDefaults) {
       let details = [
         {"icon": browser.runtime.getURL("default.png"),
          "panel": browser.runtime.getURL("default.html"),
          "title": "Default Title",
         },
         {"icon": browser.runtime.getURL("1.png"),
          "panel": browser.runtime.getURL("default.html"),
          "title": "Default Title",
@@ -319,17 +319,17 @@ add_task(function* testDefaultTitle() {
       "permissions": ["tabs"],
     },
 
     files: {
       "sidebar.html": sidebar,
       "icon.png": imageBuffer,
     },
 
-    getTests: function(tabs, expectDefaults) {
+    getTests(tabs, expectDefaults) {
       let details = [
         {"title": "Foo Extension",
          "panel": browser.runtime.getURL("sidebar.html"),
          "icon": browser.runtime.getURL("icon.png")},
         {"title": "Foo Title",
          "panel": browser.runtime.getURL("sidebar.html"),
          "icon": browser.runtime.getURL("icon.png")},
         {"title": "Bar Title",
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
@@ -85,17 +85,17 @@ add_task(function* testBadPermissions() 
       "commands": {
         "test-tabs-executeScript": {
           "suggested_key": {
             "default": "Alt+Shift+K",
           },
         },
       },
     },
-    contentSetup: function() {
+    contentSetup() {
       browser.commands.onCommand.addListener(function(command) {
         if (command == "test-tabs-executeScript") {
           browser.test.sendMessage("tabs-command-key-pressed");
         }
       });
       return Promise.resolve();
     },
     setup: function* (extension) {
@@ -127,17 +127,17 @@ add_task(function* testBadPermissions() 
   });
 
   info("Test active tab, page action, no click");
   yield testHasNoPermission({
     manifest: {
       "permissions": ["http://example.com/", "activeTab"],
       "page_action": {},
     },
-    contentSetup: async function() {
+    async contentSetup() {
       let [tab] = await browser.tabs.query({active: true, currentWindow: true});
       await browser.pageAction.show(tab.id);
     },
   });
 
   yield BrowserTestUtils.removeTab(tab2);
   yield BrowserTestUtils.removeTab(tab1);
 });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
@@ -81,17 +81,17 @@ add_task(function* testGoodPermissions()
       "commands": {
         "test-tabs-executeScript": {
           "suggested_key": {
             "default": "Alt+Shift+K",
           },
         },
       },
     },
-    contentSetup: function() {
+    contentSetup() {
       browser.commands.onCommand.addListener(function(command) {
         if (command == "test-tabs-executeScript") {
           browser.test.sendMessage("tabs-command-key-pressed");
         }
       });
       return Promise.resolve();
     },
     setup: function* (extension) {
@@ -101,17 +101,17 @@ add_task(function* testGoodPermissions()
   });
 
   info("Test activeTab permission with a browser action click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab"],
       "browser_action": {},
     },
-    contentSetup: function() {
+    contentSetup() {
       browser.browserAction.onClicked.addListener(() => {
         browser.test.log("Clicked.");
       });
       return Promise.resolve();
     },
     setup: clickBrowserAction,
     tearDown: closeBrowserAction,
   });
@@ -157,17 +157,17 @@ add_task(function* testGoodPermissions()
     tearDown: closePageAction,
   });
 
   info("Test activeTab permission with a context menu click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab", "contextMenus"],
     },
-    contentSetup: function() {
+    contentSetup() {
       browser.contextMenus.create({title: "activeTab", contexts: ["all"]});
       return Promise.resolve();
     },
     setup: function* (extension) {
       let contextMenu = document.getElementById("contentAreaContextMenu");
       let awaitPopupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
       let awaitPopupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
 
--- a/testing/mochitest/tests/SimpleTest/ExtensionTestUtils.js
+++ b/testing/mochitest/tests/SimpleTest/ExtensionTestUtils.js
@@ -1,12 +1,10 @@
 var ExtensionTestUtils = {};
 
-const {ExtensionTestCommon} = SpecialPowers.Cu.import("resource://testing-common/ExtensionTestCommon.jsm", {});
-
 ExtensionTestUtils.loadExtension = function(ext)
 {
   // Cleanup functions need to be registered differently depending on
   // whether we're in browser chrome or plain mochitests.
   var registerCleanup;
   if (typeof registerCleanupFunction != "undefined") {
     registerCleanup = registerCleanupFunction;
   } else {
@@ -87,21 +85,24 @@ ExtensionTestUtils.loadExtension = funct
 
   // Mimic serialization of functions as done in `Extension.generateXPI` and
   // `Extension.generateZipFile` because functions are dropped when `ext` object
   // is sent to the main process via the message manager.
   ext = Object.assign({}, ext);
   if (ext.files) {
     ext.files = Object.assign({}, ext.files);
     for (let filename of Object.keys(ext.files)) {
-      ext.files[filename] = ExtensionTestCommon.serializeScript(ext.files[filename]);
+      let file = ext.files[filename];
+      if (typeof file == "function") {
+        ext.files[filename] = `(${file})();`
+      }
     }
   }
-  if ("background" in ext) {
-    ext.background = ExtensionTestCommon.serializeScript(ext.background);
+  if (typeof ext.background == "function") {
+    ext.background = `(${ext.background})();`
   }
 
   var extension = SpecialPowers.loadExtension(ext, handler);
 
   registerCleanup(() => {
     if (extension.state == "pending" || extension.state == "running") {
       SimpleTest.ok(false, "Extension left running at test shutdown")
       return extension.unload();
--- a/toolkit/components/extensions/ExtensionTestCommon.jsm
+++ b/toolkit/components/extensions/ExtensionTestCommon.jsm
@@ -135,17 +135,17 @@ class MockExtension {
     return this._extensionPromise.then(extension => {
       return extension.broadcast("Extension:FlushJarCache", {path: this.file.path});
     }).then(() => {
       return OS.File.remove(this.file.path);
     });
   }
 }
 
-this.ExtensionTestCommon = class ExtensionTestCommon {
+class ExtensionTestCommon {
   /**
    * This code is designed to make it easy to test a WebExtension
    * without creating a bunch of files. Everything is contained in a
    * single JSON blob.
    *
    * Properties:
    *   "background": "<JS code>"
    *     A script to be loaded as the background script.
@@ -278,17 +278,17 @@ this.ExtensionTestCommon = class Extensi
           zipW.addEntryDirectory(path, time, false);
         }
       }
     }
 
     for (let filename in files) {
       let script = files[filename];
       if (typeof(script) == "function") {
-        script = this.serializeScript(script);
+        script = "(" + script.toString() + ")()";
       } else if (instanceOf(script, "Object") || instanceOf(script, "Array")) {
         script = JSON.stringify(script);
       }
 
       if (!instanceOf(script, "ArrayBuffer")) {
         script = new TextEncoder("utf-8").encode(script).buffer;
       }
 
@@ -300,40 +300,16 @@ this.ExtensionTestCommon = class Extensi
     }
 
     zipW.close();
 
     return file;
   }
 
   /**
-   * Properly serialize a script into eval-able code string.
-   *
-   * @param {string|function|Array} script
-   * @returns {string}
-   */
-  static serializeScript(script) {
-    if (Array.isArray(script)) {
-      return script.map(this.serializeScript).join(";");
-    }
-    if (typeof script !== "function") {
-      return script;
-    }
-    // Serialization of object methods doesn't include `function` anymore.
-    const method = /^(async )?(\w+)\(/;
-
-    let code = script.toString();
-    let match = code.match(method);
-    if (match && match[2] !== "function") {
-      code = code.replace(method, "$1function $2(");
-    }
-    return `(${code})();`;
-  }
-
-  /**
    * Generates a new extension using |Extension.generateXPI|, and initializes a
    * new |Extension| instance which will execute it.
    *
    * @param {object} data
    * @returns {Extension}
    */
   static generate(data) {
     let file = this.generateXPI(data);
@@ -362,9 +338,9 @@ this.ExtensionTestCommon = class Extensi
     }
 
     return new Extension({
       id,
       resourceURI: jarURI,
       cleanupFile: file,
     });
   }
-};
+}
--- a/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html
@@ -35,17 +35,17 @@ add_task(function* test_background_clipb
   function backgroundScript() {
     browser.test.assertEq(false, doCopy("whatever"),
       "copy should be denied without permission");
     browser.test.assertEq(false, doPaste(),
       "paste should be denied without permission");
     browser.test.sendMessage("ready");
   }
   let extensionData = {
-    background: [shared, backgroundScript],
+    background: `(${shared})();(${backgroundScript})();`,
   };
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
 
   yield extension.awaitMessage("ready");
 
   yield extension.unload();
 });
@@ -189,17 +189,17 @@ add_task(function* test_background_clipb
   function background() {
     browser.test.sendMessage("paste", doPaste());
   }
 
   const extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["clipboardRead"],
     },
-    background: [shared, background],
+    background: `(${shared})();(${background})();`,
   });
 
   const STRANGE = "Stranger Things";
   SpecialPowers.clipboardCopyString(STRANGE);
 
   yield extension.startup();
 
   const paste = yield extension.awaitMessage("paste");