Bug 1449255: Part 22 - Rename test_bug570173 to test_updatecheck_errors.js and modernize. r=aswan

MozReview-Commit-ID: 2sN8JzFdEfy

--HG--
rename : toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js => toolkit/mozapps/extensions/test/xpcshell/test_updatecheck_errors.js
extra : rebase_source : 9a49fc5ced9c8813cc4fa672aa67cdc63d58d4cf
This commit is contained in:
Kris Maglione 2018-03-27 16:39:26 -07:00
Родитель 7a58de4d77
Коммит 38e3f67780
3 изменённых файлов: 53 добавлений и 62 удалений

Просмотреть файл

@ -1,61 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that add-on update check failures are propagated correctly
// 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() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Create and configure the HTTP server.
testserver = createHttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
gPort = testserver.identity.primaryPort;
run_next_test();
}
// 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 promiseAddonByID("addon1@tests.mozilla.org");
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);
ok(!update.compatibilityUpdate, "not expecting a compatibility update");
ok(!update.updateAvailable, "not expecting a compatibility update");
equal(update.error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
addon.uninstall();
}
});

Просмотреть файл

@ -0,0 +1,52 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that add-on update check failures are propagated correctly
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
var testserver;
const profileDir = gProfD.clone();
profileDir.append("extensions");
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Create and configure the HTTP server.
testserver = AddonTestUtils.createHttpServer({hosts: ["example.com"]});
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
await promiseStartupManager();
});
// Verify that an update check returns the correct errors.
add_task(async function() {
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",
});
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);
ok(!update.compatibilityUpdate, "not expecting a compatibility update");
ok(!update.updateAvailable, "not expecting a compatibility update");
equal(update.error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
addon.uninstall();
});

Просмотреть файл

@ -79,7 +79,6 @@ skip-if = true # Bug 1358846 Bug 1365021 Bug 676992
[test_bug1180901_2.js]
skip-if = os != "win"
[test_bug566626.js]
[test_bug570173.js]
[test_bug587088.js]
skip-if = os == "win" # Bug 1358846
[test_bug595081.js]
@ -267,6 +266,7 @@ 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"