Bug 1447903: Part 14 - Update test_bug655254.js to use only bootstrapped extensions. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 21 Mar 2018 23:02:14 -0700
changeset 772385 056c9a0a074daf023e9f12eaa05caaeaf8bfb84b
parent 772384 ac7872ed8fc020744225c9113ceac24ad36924ff
child 772386 4286d2dd9c535db621a3e8c22d67ecfe6a44fcae
push id103897
push usermaglione.k@gmail.com
push dateMon, 26 Mar 2018 01:31:53 +0000
reviewersaswan
bugs1447903, 655254
milestone61.0a1
Bug 1447903: Part 14 - Update test_bug655254.js to use only bootstrapped extensions. r?aswan MozReview-Commit-ID: 6OPMB9ntlVl
toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf
toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js
toolkit/mozapps/extensions/test/addons/test_bug655254_2/install.rdf
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon1@tests.mozilla.org</em:id>
-    <em:version>1.0</em:version>
-    <em:name>Test 1</em:name>
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>1</em:minVersion>
-        <em:maxVersion>1</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-  </Description>
-</RDF>
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/bootstrap.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/* exported startup, shutdown */
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-function startup(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 1);
-}
-
-function shutdown(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 0);
-}
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug655254_2/install.rdf
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon2@tests.mozilla.org</em:id>
-    <em:version>1.0</em:version>
-    <em:name>Test 2</em:name>
-    <em:bootstrap>true</em:bootstrap>
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>2</em:minVersion>
-        <em:maxVersion>2</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-  </Description>
-</RDF>
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -74,17 +74,16 @@ const LEGACY_NON_RESTARTLESS_TESTS = new
   "test_bug335238.js",
   "test_bug397778.js",
   "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",
 ]);
 
 if (LEGACY_NON_RESTARTLESS_TESTS.has(_TEST_FILE[0].replace(/.*\//, ""))) {
   Services.prefs.setBoolPref("extensions.legacy.non-restartless.enabled", true);
 }
 
 const {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
@@ -35,65 +35,96 @@ var dirProvider = {
                                          AM_Ci.nsISupports])
 };
 Services.dirsvc.registerProvider(dirProvider);
 
 var addon1 = {
   id: "addon1@tests.mozilla.org",
   version: "1.0",
   name: "Test 1",
+  bootstrap: true,
   updateURL: "http://localhost:" + gPort + "/data/test_bug655254.json",
   targetApplications: [{
     id: "xpcshell@tests.mozilla.org",
     minVersion: "1",
     maxVersion: "1"
   }]
 };
 
+const ADDONS = [
+  {
+    "install.rdf": {
+      id: "addon2@tests.mozilla.org",
+      version: "1.0",
+      name: "Test 2",
+      bootstrap: true,
+
+      targetApplications: [{
+        id: "xpcshell@tests.mozilla.org",
+        minVersion: "2",
+        maxVersion: "2"}],
+    },
+    "bootstrap.js": `
+      /* exported startup, shutdown */
+      ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+      function startup(data, reason) {
+        Services.prefs.setIntPref("bootstraptest.active_version", 1);
+      }
+
+      function shutdown(data, reason) {
+        Services.prefs.setIntPref("bootstraptest.active_version", 0);
+      }
+    `
+  },
+];
+
+const XPIS = ADDONS.map(addon => AddonTestUtils.createTempXPIFile(addon));
+
 // Set up the profile
 function run_test() {
   do_test_pending();
   run_test_1();
 }
 
 function end_test() {
   testserver.stop(do_test_finished);
 }
 
 async function run_test_1() {
   var time = Date.now();
   var dir = writeInstallRDFForExtension(addon1, userDir);
   setExtensionModifiedTime(dir, time);
 
-  manuallyInstall(do_get_addon("test_bug655254_2"), userDir, "addon2@tests.mozilla.org");
+  manuallyInstall(XPIS[0], userDir, "addon2@tests.mozilla.org");
 
   await promiseStartupManager();
 
   AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                "addon2@tests.mozilla.org"], function([a1, a2]) {
     Assert.notEqual(a1, null);
     Assert.ok(a1.appDisabled);
     Assert.ok(!a1.isActive);
-    Assert.ok(!isExtensionInAddonsList(userDir, a1.id));
+    Assert.ok(!isExtensionInBootstrappedList(userDir, a1.id));
 
     Assert.notEqual(a2, null);
     Assert.ok(!a2.appDisabled);
     Assert.ok(a2.isActive);
-    Assert.ok(!isExtensionInAddonsList(userDir, a2.id));
+    Assert.ok(isExtensionInBootstrappedList(userDir, a2.id));
     Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
 
     a1.findUpdates({
       async onUpdateFinished() {
         await promiseRestartManager();
 
         AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(async function(a1_2) {
           Assert.notEqual(a1_2, null);
           Assert.ok(!a1_2.appDisabled);
           Assert.ok(a1_2.isActive);
-          Assert.ok(isExtensionInAddonsList(userDir, a1_2.id));
+          Assert.ok(isExtensionInBootstrappedList(userDir, a1_2.id));
 
           shutdownManager();
 
           Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
 
           userDir.parent.moveTo(gProfD, "extensions3");
           userDir = gProfD.clone();
           userDir.append("extensions3");
@@ -102,39 +133,39 @@ async function run_test_1() {
 
           await promiseStartupManager(false);
 
           AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                        "addon2@tests.mozilla.org"], function([a1_3, a2_3]) {
             Assert.notEqual(a1_3, null);
             Assert.ok(!a1_3.appDisabled);
             Assert.ok(a1_3.isActive);
-            Assert.ok(isExtensionInAddonsList(userDir, a1_3.id));
+            Assert.ok(isExtensionInBootstrappedList(userDir, a1_3.id));
 
             Assert.notEqual(a2_3, null);
             Assert.ok(!a2_3.appDisabled);
             Assert.ok(a2_3.isActive);
-            Assert.ok(!isExtensionInAddonsList(userDir, a2_3.id));
+            Assert.ok(isExtensionInBootstrappedList(userDir, a2_3.id));
             Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
 
             executeSoon(run_test_2);
           });
         }));
       }
     }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
   });
 }
 
 // Set up the profile
 function run_test_2() {
   AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(async function(a2) {
    Assert.notEqual(a2, null);
    Assert.ok(!a2.appDisabled);
    Assert.ok(a2.isActive);
-   Assert.ok(!isExtensionInAddonsList(userDir, a2.id));
+   Assert.ok(isExtensionInBootstrappedList(userDir, a2.id));
    Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
 
    a2.userDisabled = true;
    Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
 
    shutdownManager();
 
    userDir.parent.moveTo(gProfD, "extensions4");
@@ -145,20 +176,20 @@ function run_test_2() {
 
    await promiseStartupManager(false);
 
    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
                                 "addon2@tests.mozilla.org"], function([a1_2, a2_2]) {
      Assert.notEqual(a1_2, null);
      Assert.ok(!a1_2.appDisabled);
      Assert.ok(a1_2.isActive);
-     Assert.ok(isExtensionInAddonsList(userDir, a1_2.id));
+     Assert.ok(isExtensionInBootstrappedList(userDir, a1_2.id));
 
      Assert.notEqual(a2_2, null);
      Assert.ok(a2_2.userDisabled);
      Assert.ok(!a2_2.isActive);
-     Assert.ok(!isExtensionInAddonsList(userDir, a2_2.id));
+     Assert.ok(!isExtensionInBootstrappedList(userDir, a2_2.id));
      Assert.equal(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
 
      end_test();
    });
   }));
 }