toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 // This verifies that add-on update check failures are propogated correctly
michael@0 6
michael@0 7 // The test extension uses an insecure update url.
michael@0 8 Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
michael@0 9
michael@0 10 Components.utils.import("resource://testing-common/httpd.js");
michael@0 11 var testserver;
michael@0 12 const profileDir = gProfD.clone();
michael@0 13 profileDir.append("extensions");
michael@0 14
michael@0 15 function run_test() {
michael@0 16 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
michael@0 17
michael@0 18 // Create and configure the HTTP server.
michael@0 19 testserver = new HttpServer();
michael@0 20 testserver.registerDirectory("/data/", do_get_file("data"));
michael@0 21 testserver.registerDirectory("/addons/", do_get_file("addons"));
michael@0 22 testserver.start(-1);
michael@0 23 gPort = testserver.identity.primaryPort;
michael@0 24
michael@0 25 writeInstallRDFForExtension({
michael@0 26 id: "addon1@tests.mozilla.org",
michael@0 27 version: "1.0",
michael@0 28 updateURL: "http://localhost:" + gPort + "/data/test_missing.rdf",
michael@0 29 targetApplications: [{
michael@0 30 id: "xpcshell@tests.mozilla.org",
michael@0 31 minVersion: "1",
michael@0 32 maxVersion: "1"
michael@0 33 }],
michael@0 34 name: "Test Addon 1",
michael@0 35 }, profileDir);
michael@0 36
michael@0 37 startupManager();
michael@0 38
michael@0 39 do_test_pending();
michael@0 40 run_test_1();
michael@0 41 }
michael@0 42
michael@0 43 function end_test() {
michael@0 44 testserver.stop(do_test_finished);
michael@0 45 }
michael@0 46
michael@0 47 // Verify that an update check returns the correct errors.
michael@0 48 function run_test_1() {
michael@0 49 AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
michael@0 50 do_check_neq(a1, null);
michael@0 51 do_check_eq(a1.version, "1.0");
michael@0 52
michael@0 53 let sawCompat = false;
michael@0 54 let sawUpdate = false;
michael@0 55 a1.findUpdates({
michael@0 56 onNoCompatibilityUpdateAvailable: function(addon) {
michael@0 57 sawCompat = true;
michael@0 58 },
michael@0 59
michael@0 60 onCompatibilityUpdateAvailable: function(addon) {
michael@0 61 do_throw("Should not have seen a compatibility update");
michael@0 62 },
michael@0 63
michael@0 64 onNoUpdateAvailable: function(addon) {
michael@0 65 sawUpdate = true;
michael@0 66 },
michael@0 67
michael@0 68 onUpdateAvailable: function(addon, install) {
michael@0 69 do_throw("Should not have seen an update");
michael@0 70 },
michael@0 71
michael@0 72 onUpdateFinished: function(addon, error) {
michael@0 73 do_check_true(sawCompat);
michael@0 74 do_check_true(sawUpdate);
michael@0 75 do_check_eq(error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
michael@0 76 end_test();
michael@0 77 }
michael@0 78 }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
michael@0 79 });
michael@0 80 }

mercurial