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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 checks work correctly when compatibility
     6 // check is disabled.
     8 const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
    10 // The test extension uses an insecure update url.
    11 Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
    13 Components.utils.import("resource://testing-common/httpd.js");
    14 var testserver = new HttpServer();
    15 testserver.start(-1);
    16 gPort = testserver.identity.primaryPort;
    17 mapFile("/data/test_update.rdf", testserver);
    18 mapFile("/data/test_update.xml", testserver);
    19 testserver.registerDirectory("/addons/", do_get_file("addons"));
    21 const profileDir = gProfD.clone();
    22 profileDir.append("extensions");
    25 function run_test() {
    26   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
    28   run_test_1();
    29 }
    31 // Test that the update check correctly observes the
    32 // extensions.strictCompatibility pref and compatibility overrides.
    33 function run_test_1() {
    34   writeInstallRDFForExtension({
    35     id: "addon9@tests.mozilla.org",
    36     version: "1.0",
    37     updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
    38     targetApplications: [{
    39       id: "xpcshell@tests.mozilla.org",
    40       minVersion: "0.1",
    41       maxVersion: "0.2"
    42     }],
    43     name: "Test Addon 9",
    44   }, profileDir);
    45   restartManager();
    47   AddonManager.addInstallListener({
    48     onNewInstall: function(aInstall) {
    49       if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
    50         do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
    51       do_check_eq(aInstall.version, "4.0");
    52     },
    53     onDownloadFailed: function(aInstall) {
    54       do_execute_soon(run_test_2);
    55     }
    56   });
    58   Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
    59                              "http://localhost:" + gPort + "/data/test_update.xml");
    60   Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
    61   // Fake a timer event
    62   gInternalManager.notify(null);
    63 }
    65 // Test that the update check correctly observes when an addon opts-in to
    66 // strict compatibility checking.
    67 function run_test_2() {
    68   writeInstallRDFForExtension({
    69     id: "addon11@tests.mozilla.org",
    70     version: "1.0",
    71     updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
    72     targetApplications: [{
    73       id: "xpcshell@tests.mozilla.org",
    74       minVersion: "0.1",
    75       maxVersion: "0.2"
    76     }],
    77     name: "Test Addon 11",
    78   }, profileDir);
    79   restartManager();
    81   AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) {
    82     do_check_neq(a11, null);
    84     a11.findUpdates({
    85       onCompatibilityUpdateAvailable: function() {
    86         do_throw("Should have not have seen compatibility information");
    87       },
    89       onNoUpdateAvailable: function() {
    90         do_throw("Should have seen an available update");
    91       },
    93       onUpdateFinished: function() {
    94         end_test();
    95       }
    96     }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
    97   });
    98 }

mercurial