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.

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

mercurial