Bug 1449255: Part 12b - Fold test_bug675371 into test_bootstrapped_chrome_manifest.js. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 27 Mar 2018 16:02:02 -0700
changeset 773481 afbe49beeaf17097267e4349ffdb2ccc835d1082
parent 773480 e84d17c68fe3d61518d700be78df6e41d0b41366
child 773482 26ca3e929b0680812a5e5adb5ef5cbdc5cd56058
push id104243
push usermaglione.k@gmail.com
push dateWed, 28 Mar 2018 00:15:32 +0000
reviewersaswan
bugs1449255, 675371
milestone61.0a1
Bug 1449255: Part 12b - Fold test_bug675371 into test_bootstrapped_chrome_manifest.js. r?aswan MozReview-Commit-ID: 356HXe3iPKT
toolkit/mozapps/extensions/test/addons/test_bug675371/chrome.manifest
toolkit/mozapps/extensions/test/addons/test_bug675371/install.rdf
toolkit/mozapps/extensions/test/addons/test_bug675371/test.js
toolkit/mozapps/extensions/test/xpcshell/test_bootstrapped_chrome_manifest.js
toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug675371/chrome.manifest
+++ /dev/null
@@ -1,1 +0,0 @@
-content bug675371 .
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_bug675371/install.rdf
+++ /dev/null
@@ -1,24 +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>bug675371@tests.mozilla.org</em:id>
-    <em:version>1.0</em:version>
-    <em:bootstrap>true</em:bootstrap>
-
-    <!-- Front End MetaData -->
-    <em:name>Bug 675371 Test</em:name>
-    <em:description>Test Description</em:description>
-
-    <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_bug675371/test.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/* exported active */
-var active = true;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrapped_chrome_manifest.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrapped_chrome_manifest.js
@@ -21,25 +21,41 @@ const ADDON = {
   "test.js": `var active = true;`,
 };
 
 add_task(async function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   await promiseStartupManager();
 });
 
+function checkActive(expected) {
+  let target = { active: false };
+  let load = () => {
+    Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
+  };
+
+  if (expected) {
+    load();
+  } else {
+    Assert.throws(load);
+  }
+  equal(target.active, expected, "Manifest is active?");
+}
+
 add_task(async function test() {
   let {addon} = await AddonTestUtils.promiseInstallXPI(ADDON);
 
   Assert.ok(addon.isActive);
 
   // Tests that chrome.manifest is registered when the addon is installed.
-  var target = { active: false };
-  Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-  Assert.ok(target.active);
+  checkActive(true);
+
+  addon.userDisabled = true;
+  checkActive(false);
+
+  addon.userDisabled = false;
+  checkActive(true);
 
   await promiseShutdownManager();
 
   // Tests that chrome.manifest remains registered at app shutdown.
-  target.active = false;
-  Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-  Assert.ok(target.active);
+  checkActive(true);
 });
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function run_test() {
-  do_test_pending();
-  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-  startupManager();
-
-  prepare_test({ }, [
-    "onNewInstall"
-  ]);
-
-  AddonManager.getInstallForFile(do_get_addon("test_bug675371"), function(install) {
-    ensure_test_completed();
-
-    Assert.notEqual(install, null);
-
-    prepare_test({
-      "bug675371@tests.mozilla.org": [
-        ["onInstalling", false],
-        "onInstalled"
-      ]
-    }, [
-      "onInstallStarted",
-      "onInstallEnded",
-    ], callback_soon(check_test));
-    install.install();
-  });
-}
-
-function check_test() {
-  AddonManager.getAddonByID("bug675371@tests.mozilla.org", do_exception_wrap(function(addon) {
-    Assert.notEqual(addon, null);
-    Assert.ok(addon.isActive);
-
-    // Tests that chrome.manifest is registered when the addon is installed.
-    var target = { };
-    Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-    Assert.ok(target.active);
-
-    prepare_test({
-      "bug675371@tests.mozilla.org": [
-        ["onDisabling", false],
-        "onDisabled"
-      ]
-    });
-
-    // Tests that chrome.manifest is unregistered when the addon is disabled.
-    addon.userDisabled = true;
-    target.active = false;
-    try {
-      Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-      do_throw("Chrome file should not have been found");
-    } catch (e) {
-      Assert.ok(!target.active);
-    }
-
-    prepare_test({
-      "bug675371@tests.mozilla.org": [
-        ["onEnabling", false],
-        "onEnabled"
-      ]
-    });
-
-    // Tests that chrome.manifest is registered when the addon is enabled.
-    addon.userDisabled = false;
-    target.active = false;
-    Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-    Assert.ok(target.active);
-
-    prepare_test({
-      "bug675371@tests.mozilla.org": [
-        ["onUninstalling", false],
-        "onUninstalled"
-      ]
-    });
-
-    // Tests that chrome.manifest is unregistered when the addon is uninstalled.
-    addon.uninstall();
-    target.active = false;
-    try {
-      Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
-      do_throw("Chrome file should not have been found");
-    } catch (e) {
-      Assert.ok(!target.active);
-    }
-
-    executeSoon(do_test_finished);
-  }));
-}
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -88,17 +88,16 @@ skip-if = os == "win" # Bug 1358846
 [test_bug616841.js]
 # Bug 676992: test consistently fails on Android
 fail-if = os == "android"
 [test_bug619730.js]
 tags = blocklist
 [test_bug620837.js]
 tags = blocklist
 [test_bug655254.js]
-[test_bug675371.js]
 [test_bug740612.js]
 [test_bug753900.js]
 [test_bug757663.js]
 [test_cache_certdb.js]
 run-if = addon_signing
 [test_cacheflush.js]
 [test_childprocess.js]
 [test_compatoverrides.js]