Bug 1447903: Part 13 - Update test_syncGUID.js to use only bootstrapped extensions. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 21 Mar 2018 22:55:18 -0700
changeset 772456 6510c8088471a654866cf728a49325932e8867ab
parent 772455 effb420053178be1c494bb3ad739db8ab35806cd
child 772457 09eb705381d7e455a2a2322834883aa54467382a
push id103918
push usermaglione.k@gmail.com
push dateMon, 26 Mar 2018 06:33:35 +0000
reviewersaswan
bugs1447903
milestone61.0a1
Bug 1447903: Part 13 - Update test_syncGUID.js to use only bootstrapped extensions. r?aswan MozReview-Commit-ID: CEsf2jxbpP3
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -76,17 +76,16 @@ const LEGACY_NON_RESTARTLESS_TESTS = new
   "test_bug425657.js",
   "test_bug455906.js",
   "test_bug470377_1.js",
   "test_bug470377_2.js",
   "test_bug470377_3.js",
   "test_bug470377_4.js",
   "test_bug655254.js",
   "test_signed_verify.js",
-  "test_syncGUID.js",
 ]);
 
 if (LEGACY_NON_RESTARTLESS_TESTS.has(_TEST_FILE[0].replace(/.*\//, ""))) {
   Services.prefs.setBoolPref("extensions.legacy.non-restartless.enabled", true);
 }
 
 const {
   awaitPromise,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
@@ -17,16 +17,45 @@ function run_test() {
   Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
   startupManager();
 
   run_next_test();
 }
 
+const ADDONS = [
+  {
+    id: "addon1@tests.mozilla.org",
+    version: "1.0",
+    name: "Test 1",
+    bootstrap: true,
+    description: "Test Description",
+
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"}],
+  },
+  {
+    id: "addon2@tests.mozilla.org",
+    version: "2.0",
+    name: "Real Test 2",
+    bootstrap: true,
+    description: "Test Description",
+
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"}],
+  },
+];
+
+const XPIS = ADDONS.map(addon => createTempXPIFile(addon));
+
 const UUID_PATTERN = /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i;
 
 add_test(function test_getter_and_setter() {
   // Our test add-on requires a restart.
   let listener = {
     onInstallEnded: function onInstallEnded() {
      AddonManager.removeInstallListener(listener);
      // never restart directly inside an onInstallEnded handler!
@@ -53,17 +82,17 @@ add_test(function test_getter_and_setter
         run_next_test();
       });
      });
     }
   };
 
   AddonManager.addInstallListener(listener);
 
-  AddonManager.getInstallForFile(do_get_addon("test_install1"),
+  AddonManager.getInstallForFile(XPIS[0],
                                  function(install) {
     install.install();
   });
 });
 
 add_test(function test_fetch_by_guid_unknown_guid() {
   XPIProvider.getAddonBySyncGUID("XXXX", function(addon) {
     Assert.equal(null, addon);
@@ -106,18 +135,18 @@ add_test(function test_error_on_duplicat
        });
       }
     }
   };
 
   AddonManager.addInstallListener(listener);
   let getInstallCB = function(install) { install.install(); };
 
-  for (let name of installNames) {
-    AddonManager.getInstallForFile(do_get_addon(name), getInstallCB);
+  for (let xpi of XPIS) {
+    AddonManager.getInstallForFile(xpi, getInstallCB);
   }
 });
 
 add_test(function test_fetch_by_guid_known_guid() {
   AddonManager.getAddonByID(addonId, function(addon) {
     Assert.notEqual(null, addon);
     Assert.notEqual(null, addon.syncGUID);