Bug 1449255: Part 22 - Rename test_bug570173 to test_updatecheck_errors.js and modernize. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 27 Mar 2018 16:39:26 -0700
changeset 773491 88ee0ab7d6d8db3954a5c42b5ff0839e7ff258b0
parent 773490 6bc320dce58e032ab3b8e44a8767e3fc6e054d5c
child 773492 5486c87167c23e8f8d5cd301f51db53fc754e77a
push id104243
push usermaglione.k@gmail.com
push dateWed, 28 Mar 2018 00:15:32 +0000
reviewersaswan
bugs1449255, 570173
milestone61.0a1
Bug 1449255: Part 22 - Rename test_bug570173 to test_updatecheck_errors.js and modernize. r?aswan MozReview-Commit-ID: 2sN8JzFdEfy
toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
toolkit/mozapps/extensions/test/xpcshell/test_updatecheck_errors.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
rename from toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
rename to toolkit/mozapps/extensions/test/xpcshell/test_updatecheck_errors.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck_errors.js
@@ -6,56 +6,47 @@
 
 // The test extension uses an insecure update url.
 Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
 
 var testserver;
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function run_test() {
+add_task(async function setup() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
 
   // Create and configure the HTTP server.
-  testserver = createHttpServer();
+  testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
   testserver.registerDirectory("/data/", do_get_file("data"));
   testserver.registerDirectory("/addons/", do_get_file("addons"));
-  gPort = testserver.identity.primaryPort;
 
-  run_next_test();
-}
+  await promiseStartupManager();
+});
 
 // Verify that an update check returns the correct errors.
 add_task(async function() {
-  for (let manifestType of ["rdf", "json"]) {
-    writeInstallRDFForExtension({
-      id: "addon1@tests.mozilla.org",
-      version: "1.0",
-      updateURL: `http://localhost:${gPort}/data/test_missing.${manifestType}`,
-      targetApplications: [{
-        id: "xpcshell@tests.mozilla.org",
-        minVersion: "1",
-        maxVersion: "1"
-      }],
-      name: "Test Addon 1",
-      bootstrap: "true",
-    }, profileDir);
-
-    await promiseRestartManager();
+  let {addon} = await promiseInstallXPI({
+    id: "addon1@tests.mozilla.org",
+    version: "1.0",
+    updateURL: `http://example.com/data/test_missing.json`,
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "1",
+      maxVersion: "1"
+    }],
+    name: "Test Addon 1",
+    bootstrap: "true",
+  });
 
-    let addon = await promiseAddonByID("addon1@tests.mozilla.org");
+  equal(addon.version, "1.0");
 
-    ok(addon);
-    ok(addon.updateURL.endsWith(manifestType));
-    equal(addon.version, "1.0");
+  // We're expecting an error, so resolve when the promise is rejected.
+  let update = await promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED)
+    .catch(e => e);
 
-    // We're expecting an error, so resolve when the promise is rejected.
-    let update = await promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED)
-      .catch(e => e);
+  ok(!update.compatibilityUpdate, "not expecting a compatibility update");
+  ok(!update.updateAvailable, "not expecting a compatibility update");
 
-    ok(!update.compatibilityUpdate, "not expecting a compatibility update");
-    ok(!update.updateAvailable, "not expecting a compatibility update");
+  equal(update.error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
 
-    equal(update.error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
-
-    addon.uninstall();
-  }
+  addon.uninstall();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -75,17 +75,16 @@ skip-if = true # Bug 1358846 Bug 1365021
 [test_bug1180901_2.js]
 skip-if = os != "win"
 [test_bug514327_2.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 tags = blocklist
 [test_bug521905.js]
 [test_bug566626.js]
-[test_bug570173.js]
 [test_bug587088.js]
 skip-if = os == "win" # Bug 1358846
 [test_bug595081.js]
 [test_bug596607.js]
 [test_cache_certdb.js]
 run-if = addon_signing
 [test_cacheflush.js]
 [test_childprocess.js]
@@ -263,16 +262,17 @@ skip-if = os == "android"
 [test_update_ignorecompat.js]
 skip-if = true # Bug 676922 Bug 1437697
 [test_update_rdf.js]
 [test_update_webextensions.js]
 tags = webextensions
 [test_updatecheck.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
+[test_updatecheck_errors.js]
 [test_updateid.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 [test_upgrade.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 run-sequentially = Uses global XCurProcD dir.
 [test_upgrade_incompatible.js]