Bug 1495855 - Rework the about:debugging webextensions tests to do not use symlink-ed test addons. r=ochameau
authorLuca Greco <lgreco@mozilla.com>
Thu, 18 Oct 2018 11:40:02 +0000
changeset 490322 545ff4f7bc5ca0cd013eda97efb96e5a5759c810
parent 490321 b815b16f74a14ce0173bae0000f47ebf5e277e17
child 490323 99d43f9d3918d1bddf2be683e9b9d8c9de6d688f
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersochameau
bugs1495855
milestone64.0a1
Bug 1495855 - Rework the about:debugging webextensions tests to do not use symlink-ed test addons. r=ochameau Differential Revision: https://phabricator.services.mozilla.com/D8589
devtools/client/aboutdebugging/test/addons/test-devtools-webextension-nobg/manifest.json
devtools/client/aboutdebugging/test/addons/test-devtools-webextension-noid/manifest.json
devtools/client/aboutdebugging/test/addons/test-devtools-webextension-unknown-prop/manifest.json
devtools/client/aboutdebugging/test/addons/test-devtools-webextension/bg.js
devtools/client/aboutdebugging/test/addons/test-devtools-webextension/manifest.json
devtools/client/aboutdebugging/test/addons/test-devtools-webextension/popup.html
devtools/client/aboutdebugging/test/addons/test-devtools-webextension/popup.js
devtools/client/aboutdebugging/test/browser_addons_debug_info.js
devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
devtools/client/aboutdebugging/test/browser_addons_debug_webextension_nobg.js
devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
devtools/client/aboutdebugging/test/browser_addons_remove.js
devtools/client/aboutdebugging/test/head.js
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension-nobg/manifest.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  "manifest_version": 2,
-  "name": "test-devtools-webextension-nobg",
-  "version": "1.0",
-  "applications": {
-    "gecko": {
-      "id": "test-devtools-webextension-nobg@mozilla.org"
-    }
-  }
-}
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension-noid/manifest.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-  "manifest_version": 2,
-  "name": "test-devtools-webextension-noid",
-  "version": "1.0"
-}
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension-unknown-prop/manifest.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-  "manifest_version": 2,
-  "name": "test-devtools-webextension-unknown-prop",
-  "version": "1.0",
-  "applications": {
-    "gecko": {
-      "id": "test-devtools-webextension-unknown-prop@mozilla.org"
-    }
-  },
-  "browser_actions": {
-    "default_title": "WebExtension Popup Debugging",
-    "default_popup": "popup.html"
-  }
-}
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension/bg.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/* eslint-env browser */
-/* global browser */
-
-"use strict";
-
-document.body.innerText = "Background Page Body Test Content";
-
-// These functions are called from the following about:debugging tests:
-// - browser_addons_debug_webextension.js
-// - browser_addons_debug_webextension_popup.js
-
-// eslint-disable-next-line no-unused-vars
-function myWebExtensionAddonFunction() {
-  console.log("Background page function called", browser.runtime.getManifest());
-}
-
-// eslint-disable-next-line no-unused-vars
-function myWebExtensionShowPopup() {
-  browser.test.sendMessage("readyForOpenPopup");
-}
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension/manifest.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-  "manifest_version": 2,
-  "name": "test-devtools-webextension",
-  "version": "1.0",
-  "applications": {
-    "gecko": {
-      "id": "test-devtools-webextension@mozilla.org"
-    }
-  },
-  "background": {
-    "scripts": ["bg.js"]
-  },
-  "browser_action": {
-    "default_title": "WebExtension Popup Debugging",
-    "default_popup": "popup.html"
-  }
-}
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension/popup.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="utf-8">
-    <script src="popup.js"></script>
-  </head>
-  <body>
-    Background Page Body Test Content
-  </body>
-</html>
deleted file mode 100644
--- a/devtools/client/aboutdebugging/test/addons/test-devtools-webextension/popup.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/* eslint-env browser */
-/* global browser */
-
-"use strict";
-
-// This function is called from the following about:debugging test:
-// browser_addons_debug_webextension.js
-//
-// eslint-disable-next-line no-unused-vars
-function myWebExtensionPopupAddonFunction() {
-  browser.test.sendMessage("popupPageFunctionCalled", browser.runtime.getManifest());
-}
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_info.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_info.js
@@ -34,25 +34,37 @@ add_task(async function testLegacyAddon(
 });
 
 add_task(async function testWebExtension() {
   const addonId = "test-devtools-webextension-nobg@mozilla.org";
   const addonName = "test-devtools-webextension-nobg";
   const { tab, document } = await openAboutDebugging("addons");
 
   await waitForInitialAddonList(document);
+
+  const addonFile = ExtensionTestCommon.generateXPI({
+    manifest: {
+      name: addonName,
+      applications: {
+        gecko: {id: addonId},
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   await installAddon({
     document,
-    path: "addons/test-devtools-webextension-nobg/manifest.json",
+    file: addonFile,
     name: addonName,
     isWebExtension: true
   });
 
   const container = document.querySelector(`[data-addon-id="${addonId}"]`);
-  testFilePath(container, "/test/addons/test-devtools-webextension-nobg/");
+
+  testFilePath(container, addonFile.leafName);
 
   const extensionID = container.querySelector(".extension-id span");
   ok(extensionID.textContent === "test-devtools-webextension-nobg@mozilla.org");
 
   const internalUUID = container.querySelector(".internal-uuid span");
   ok(internalUUID.textContent.match(UUID_REGEX), "internalUUID is correct");
 
   const manifestURL = container.querySelector(".manifest-url");
@@ -63,19 +75,27 @@ add_task(async function testWebExtension
   await closeAboutDebugging(tab);
 });
 
 add_task(async function testTemporaryWebExtension() {
   const addonName = "test-devtools-webextension-noid";
   const { tab, document } = await openAboutDebugging("addons");
 
   await waitForInitialAddonList(document);
+
+  const addonFile = ExtensionTestCommon.generateXPI({
+    manifest: {
+      name: addonName,
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   await installAddon({
     document,
-    path: "addons/test-devtools-webextension-noid/manifest.json",
+    file: addonFile,
     name: addonName,
     isWebExtension: true
   });
 
   const addons =
     document.querySelectorAll("#temporary-extensions .addon-target-container");
   // Assuming that our temporary add-on is now at the top.
   const container = addons[addons.length - 1];
@@ -93,32 +113,45 @@ add_task(async function testTemporaryWeb
 });
 
 add_task(async function testUnknownManifestProperty() {
   const addonId = "test-devtools-webextension-unknown-prop@mozilla.org";
   const addonName = "test-devtools-webextension-unknown-prop";
   const { tab, document } = await openAboutDebugging("addons");
 
   await waitForInitialAddonList(document);
+
+  const addonFile = ExtensionTestCommon.generateXPI({
+    manifest: {
+      name: addonName,
+      applications: {
+        gecko: {id: addonId},
+      },
+      wrong_manifest_property_name: {
+      }
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   await installAddon({
     document,
-    path: "addons/test-devtools-webextension-unknown-prop/manifest.json",
+    file: addonFile,
     name: addonName,
     isWebExtension: true
   });
 
   info("Wait until the addon appears in about:debugging");
   const container = await waitUntilAddonContainer(addonName, document);
 
   info("Wait until the installation message appears for the new addon");
   await waitUntilElement(".addon-target-messages", container);
 
   const messages = container.querySelectorAll(".addon-target-message");
   ok(messages.length === 1, "there is one message");
-  ok(messages[0].textContent.match(/Error processing browser_actions/),
+  ok(messages[0].textContent.match(/Error processing wrong_manifest_property_name/),
      "the message is helpful");
   ok(messages[0].classList.contains("addon-target-warning-message"),
      "the message is a warning");
 
   await uninstallAddon({document, id: addonId, name: addonName});
 
   await closeAboutDebugging(tab);
 });
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension.js
@@ -8,31 +8,46 @@
 const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
 PromiseTestUtils.whitelistRejectionsGlobally(/File closed/);
 
 // Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
 requestLongerTimeout(2);
 
 const ADDON_ID = "test-devtools-webextension@mozilla.org";
 const ADDON_NAME = "test-devtools-webextension";
-const ADDON_MANIFEST_PATH = "addons/test-devtools-webextension/manifest.json";
 
 const {
   BrowserToolboxProcess
 } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 
 /**
  * This test file ensures that the webextension addon developer toolbox:
  * - when the debug button is clicked on a webextension, the opened toolbox
  *   has a working webconsole with the background page as default target;
  */
 add_task(async function testWebExtensionsToolboxWebConsole() {
+  const addonFile = ExtensionTestCommon.generateXPI({
+    background: function() {
+      window.myWebExtensionAddonFunction = function() {
+        console.log("Background page function called",
+                    this.browser.runtime.getManifest());
+      };
+    },
+    manifest: {
+      name: ADDON_NAME,
+      applications: {
+        gecko: {id: ADDON_ID},
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   const {
     tab, document, debugBtn,
-  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
+  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
 
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   const env = Cc["@mozilla.org/process/environment;1"]
               .getService(Ci.nsIEnvironment);
   const testScript = function() {
     /* eslint-disable no-undef */
     function findMessages(hud, text, selector = ".message") {
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
@@ -7,31 +7,43 @@
 const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
 PromiseTestUtils.whitelistRejectionsGlobally(/File closed/);
 
 // Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
 requestLongerTimeout(2);
 
 const ADDON_ID = "test-devtools-webextension@mozilla.org";
 const ADDON_NAME = "test-devtools-webextension";
-const ADDON_PATH = "addons/test-devtools-webextension/manifest.json";
 
 const {
   BrowserToolboxProcess
 } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 
 /**
  * This test file ensures that the webextension addon developer toolbox:
  * - the webextension developer toolbox has a working Inspector panel, with the
  *   background page as default target;
  */
 add_task(async function testWebExtensionsToolboxInspector() {
+  const addonFile = ExtensionTestCommon.generateXPI({
+    background: function() {
+      document.body.innerText = "Background Page Body Test Content";
+    },
+    manifest: {
+      name: ADDON_NAME,
+      applications: {
+        gecko: {id: ADDON_ID},
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   const {
     tab, document, debugBtn,
-  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_PATH);
+  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
 
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   const env = Cc["@mozilla.org/process/environment;1"]
         .getService(Ci.nsIEnvironment);
   const testScript = function() {
     /* eslint-disable no-undef */
     toolbox.selectTool("inspector")
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_nobg.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_nobg.js
@@ -7,75 +7,80 @@
 const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
 PromiseTestUtils.whitelistRejectionsGlobally(/File closed/);
 
 // Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
 requestLongerTimeout(2);
 
 const ADDON_NOBG_ID = "test-devtools-webextension-nobg@mozilla.org";
 const ADDON_NOBG_NAME = "test-devtools-webextension-nobg";
-const ADDON_NOBG_PATH = "addons/test-devtools-webextension-nobg/manifest.json";
 
 const {
   BrowserToolboxProcess
 } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 
 /**
  * This test file ensures that the webextension addon developer toolbox:
  * - the webextension developer toolbox is connected to a fallback page when the
  *   background page is not available (and in the fallback page document body contains
  *   the expected message, which warns the user that the current page is not a real
  *   webextension context);
  */
 add_task(async function testWebExtensionsToolboxNoBackgroundPage() {
+  const addonFile = ExtensionTestCommon.generateXPI({
+    manifest: {
+      name: ADDON_NOBG_NAME,
+      applications: {
+        gecko: {id: ADDON_NOBG_ID},
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   const {
     tab, document, debugBtn,
-  } = await setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, ADDON_NOBG_PATH);
+  } = await setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, addonFile);
 
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   const env = Cc["@mozilla.org/process/environment;1"]
         .getService(Ci.nsIEnvironment);
   const testScript = function() {
     /* eslint-disable no-undef */
-    toolbox.selectTool("inspector")
-      .then(inspector => {
-        return inspector.walker.querySelector(inspector.walker.rootNode, "body");
-      })
-      .then((nodeActor) => {
-        if (!nodeActor) {
-          throw new Error("nodeActor not found");
-        }
+    toolbox.selectTool("inspector").then(async inspector => {
+      const nodeActor = await inspector.walker.querySelector(
+        inspector.walker.rootNode, "body");
 
-        dump("Got a nodeActor\n");
+      if (!nodeActor) {
+        throw new Error("nodeActor not found");
+      }
 
-        if (!(nodeActor.inlineTextChild)) {
-          throw new Error("inlineTextChild not found");
-        }
+      if (!(nodeActor.inlineTextChild)) {
+        throw new Error("inlineTextChild not found");
+      }
 
-        dump("Got a nodeActor with an inline text child\n");
+      dump("Got a nodeActor with an inline text child\n");
 
-        const expectedValue = "Your addon does not have any document opened yet.";
-        const actualValue = nodeActor.inlineTextChild._form.nodeValue;
+      const expectedValue = "Your addon does not have any document opened yet.";
+      const actualValue = nodeActor.inlineTextChild._form.nodeValue;
 
-        if (actualValue !== expectedValue) {
-          throw new Error(
-            `mismatched inlineTextchild value: "${actualValue}" !== "${expectedValue}"`
-          );
-        }
+      if (actualValue !== expectedValue) {
+        throw new Error(
+          `mismatched inlineTextchild value: "${actualValue}" !== "${expectedValue}"`
+        );
+      }
 
-        dump("Got the expected inline text content in the selected node\n");
-        return Promise.resolve();
-      })
-      .then(() => toolbox.destroy())
-      .catch((error) => {
-        dump("Error while running code in the browser toolbox process:\n");
-        dump(error + "\n");
-        dump("stack:\n" + error.stack + "\n");
-      });
+      dump("Got the expected inline text content in the selected node\n");
+
+      await toolbox.destroy();
+    }).catch((error) => {
+      dump("Error while running code in the browser toolbox process:\n");
+      dump(error + "\n");
+      dump("stack:\n" + error.stack + "\n");
+    });
     /* eslint-enable no-undef */
   };
   env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript);
   registerCleanupFunction(() => {
     env.set("MOZ_TOOLBOX_TEST_SCRIPT", "");
   });
 
   const onToolboxClose = BrowserToolboxProcess.once("close");
--- a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_popup.js
@@ -7,17 +7,16 @@
 const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
 PromiseTestUtils.whitelistRejectionsGlobally(/File closed/);
 
 // Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
 requestLongerTimeout(2);
 
 const ADDON_ID = "test-devtools-webextension@mozilla.org";
 const ADDON_NAME = "test-devtools-webextension";
-const ADDON_MANIFEST_PATH = "addons/test-devtools-webextension/manifest.json";
 
 const {
   BrowserToolboxProcess
 } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 
 /**
  * This test file ensures that the webextension addon developer toolbox:
  * - when the debug button is clicked on a webextension, the opened toolbox
@@ -37,16 +36,56 @@ const {
  * Returns the widget id for an extension with the passed id.
  */
 function makeWidgetId(id) {
   id = id.toLowerCase();
   return id.replace(/[^a-z0-9_-]/g, "_");
 }
 
 add_task(async function testWebExtensionsToolboxSwitchToPopup() {
+  const addonFile = ExtensionTestCommon.generateXPI({
+    background: function() {
+      const {browser} = this;
+      window.myWebExtensionShowPopup = function() {
+        browser.test.sendMessage("readyForOpenPopup");
+      };
+    },
+    manifest: {
+      name: ADDON_NAME,
+      applications: {
+        gecko: {id: ADDON_ID},
+      },
+      browser_action: {
+        default_title: "WebExtension Popup Debugging",
+        default_popup: "popup.html",
+      },
+    },
+    files: {
+      "popup.html": `<!DOCTYPE html>
+        <html>
+          <head>
+            <meta charset="utf-8">
+            <script src="popup.js"></script>
+          </head>
+          <body>
+            Background Page Body Test Content
+          </body>
+        </html>
+      `,
+      "popup.js": function() {
+        const {browser} = this;
+        window.myWebExtensionPopupAddonFunction = function() {
+          browser.test.sendMessage("popupPageFunctionCalled",
+                                   browser.runtime.getManifest());
+        };
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   let onReadyForOpenPopup;
   let onPopupCustomMessage;
 
   is(Services.prefs.getBoolPref("ui.popup.disable_autohide"), false,
      "disable_autohide shoult be initially false");
 
   Management.on("startup", function listener(event, extension) {
     if (extension.name != ADDON_NAME) {
@@ -76,17 +115,17 @@ add_task(async function testWebExtension
 
     // Wait for a notification sent by a script evaluated the test addon via
     // the web console.
     onPopupCustomMessage = waitForExtensionTestMessage("popupPageFunctionCalled");
   });
 
   const {
     tab, document, debugBtn,
-  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
+  } = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
 
   // Be careful, this JS function is going to be executed in the addon toolbox,
   // which lives in another process. So do not try to use any scope variable!
   const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
 
   const testScript = function() {
     /* eslint-disable no-undef */
 
--- a/devtools/client/aboutdebugging/test/browser_addons_remove.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_remove.js
@@ -39,20 +39,30 @@ add_task(async function removeLegacyExte
 
 add_task(async function removeWebextension() {
   const addonID = "test-devtools-webextension@mozilla.org";
   const addonName = "test-devtools-webextension";
 
   const { tab, document } = await openAboutDebugging("addons");
   await waitForInitialAddonList(document);
 
+  const addonFile = ExtensionTestCommon.generateXPI({
+    manifest: {
+      name: addonName,
+      applications: {
+        gecko: {id: addonID},
+      },
+    },
+  });
+  registerCleanupFunction(() => addonFile.remove(false));
+
   // Install this add-on, and verify that it appears in the about:debugging UI
   await installAddon({
     document,
-    path: "addons/test-devtools-webextension/manifest.json",
+    file: addonFile,
     name: addonName,
     isWebExtension: true,
   });
 
   ok(getTargetEl(document, addonID), "add-on is shown");
 
   info("Click on the remove button and wait until the addon container is removed");
   getRemoveButton(document, addonID).click();
--- a/devtools/client/aboutdebugging/test/head.js
+++ b/devtools/client/aboutdebugging/test/head.js
@@ -9,16 +9,17 @@
 
 // Load the shared-head file first.
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
   this);
 
 const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm", {});
 const { Management } = ChromeUtils.import("resource://gre/modules/Extension.jsm", {});
+const { ExtensionTestCommon } = ChromeUtils.import("resource://testing-common/ExtensionTestCommon.jsm", {});
 
 async function openAboutDebugging(page, win) {
   info("opening about:debugging");
   let url = "about:debugging";
   if (page) {
     url += "#" + page;
   }
 
@@ -160,22 +161,26 @@ async function waitUntilElement(selector
  * @param  {DOMDocument}  document   #tabs section container document
  * @return {DOMNode}                 target list or container element
  */
 function getTabList(document) {
   return document.querySelector("#tabs .target-list") ||
     document.querySelector("#tabs.targets");
 }
 
-async function installAddon({document, path, name, isWebExtension}) {
+async function installAddon({document, path, file, name, isWebExtension}) {
   // Mock the file picker to select a test addon
   const MockFilePicker = SpecialPowers.MockFilePicker;
   MockFilePicker.init(window);
-  const file = getSupportsFile(path);
-  MockFilePicker.setFiles([file.file]);
+  if (path) {
+    file = getSupportsFile(path);
+    MockFilePicker.setFiles([file.file]);
+  } else {
+    MockFilePicker.setFiles([file]);
+  }
 
   let onAddonInstalled;
 
   if (isWebExtension) {
     onAddonInstalled = new Promise(done => {
       Management.on("startup", function listener(event, extension) {
         if (extension.name != name) {
           return;
@@ -336,17 +341,17 @@ function waitForDelayedStartupFinished(w
       }
     }, "browser-delayed-startup-finished");
   });
 }
 
 /**
  * open the about:debugging page and install an addon
  */
-async function setupTestAboutDebuggingWebExtension(name, path) {
+async function setupTestAboutDebuggingWebExtension(name, file) {
   await new Promise(resolve => {
     const options = {"set": [
       // Force enabling of addons debugging
       ["devtools.chrome.enabled", true],
       ["devtools.debugger.remote-enabled", true],
       // Disable security prompt
       ["devtools.debugger.prompt-connection", false],
       // Enable Browser toolbox test script execution via env variable
@@ -355,17 +360,17 @@ async function setupTestAboutDebuggingWe
     SpecialPowers.pushPrefEnv(options, resolve);
   });
 
   const { tab, document } = await openAboutDebugging("addons");
   await waitForInitialAddonList(document);
 
   await installAddon({
     document,
-    path,
+    file,
     name,
     isWebExtension: true,
   });
 
   // Retrieve the DEBUG button for the addon
   const names = getInstalledAddonNames(document);
   const nameEl = names.filter(element => element.textContent === name)[0];
   ok(name, "Found the addon in the list");