Bug 1604371 - Fix browser_cloudfile.js in artifact builds by registering a fake provider. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 30 Jan 2020 13:58:44 +1300
changeset 37171 a2cc7c9b4a0635baabcb037cc89c1c5a59f1d4fa
parent 37170 857a1d5c45074840d913440bf8151d79198b98cf
child 37172 676178d1f6725a869c084b30e1a7e822bb5ac0c8
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1604371
Bug 1604371 - Fix browser_cloudfile.js in artifact builds by registering a fake provider. r=mkmelin WeTransfer isn't registered in artifact builds due to the building process, so in this test ensure that one provider is always registered before starting.
mail/components/preferences/test/browser/browser_cloudfile.js
--- a/mail/components/preferences/test/browser/browser_cloudfile.js
+++ b/mail/components/preferences/test/browser/browser_cloudfile.js
@@ -1,19 +1,40 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
 
+let { AddonManager } = ChromeUtils.import(
+  "resource://gre/modules/AddonManager.jsm"
+);
 let { cloudFileAccounts } = ChromeUtils.import(
   "resource:///modules/cloudFileAccounts.jsm"
 );
 let { MockRegistrar } = ChromeUtils.import(
   "resource://testing-common/MockRegistrar.jsm"
 );
 
+add_task(async () => {
+  let weTransfer = await AddonManager.getAddonByID(
+    "wetransfer@extensions.thunderbird.net"
+  );
+  if (!weTransfer) {
+    // WeTransfer isn't registered in artifact builds because the wrong
+    // built_in_addons.json is used. For the purposes of this test, pretend
+    // that it is registered.
+    cloudFileAccounts.registerProvider("WeTransfer-Test", {
+      displayName: "WeTransfer",
+      type: "ext-wetransfer@extensions.thunderbird.net"
+    });
+    registerCleanupFunction(() => {
+      cloudFileAccounts.unregisterProvider("WeTransfer-Test");
+    });
+  }
+});
+
 const ICON_URL = getRootDirectory(gTestPath) + "files/icon.svg";
 const MANAGEMENT_URL = getRootDirectory(gTestPath) + "files/management.html";
 let accountIsConfigured = false;
 let provider = {
   type: "Mochitest",
   displayName: "Mochitest",
   iconURL: ICON_URL,
   initAccount(accountKey) {