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.

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

mercurial