Wed, 31 Dec 2014 06:09:35 +0100
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 moving an extension in the filesystem without any other |
michael@0 | 6 | // change still keeps updated compatibility information |
michael@0 | 7 | |
michael@0 | 8 | // The test extension uses an insecure update url. |
michael@0 | 9 | Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); |
michael@0 | 10 | // Enable loading extensions from the user and system scopes |
michael@0 | 11 | Services.prefs.setIntPref("extensions.enabledScopes", |
michael@0 | 12 | AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER); |
michael@0 | 13 | |
michael@0 | 14 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9.2"); |
michael@0 | 15 | |
michael@0 | 16 | Components.utils.import("resource://testing-common/httpd.js"); |
michael@0 | 17 | var testserver = new HttpServer(); |
michael@0 | 18 | testserver.start(-1); |
michael@0 | 19 | gPort = testserver.identity.primaryPort; |
michael@0 | 20 | mapFile("/data/test_bug655254.rdf", testserver); |
michael@0 | 21 | |
michael@0 | 22 | var userDir = gProfD.clone(); |
michael@0 | 23 | userDir.append("extensions2"); |
michael@0 | 24 | userDir.append(gAppInfo.ID); |
michael@0 | 25 | |
michael@0 | 26 | var dirProvider = { |
michael@0 | 27 | getFile: function(aProp, aPersistent) { |
michael@0 | 28 | aPersistent.value = false; |
michael@0 | 29 | if (aProp == "XREUSysExt") |
michael@0 | 30 | return userDir.parent; |
michael@0 | 31 | return null; |
michael@0 | 32 | }, |
michael@0 | 33 | |
michael@0 | 34 | QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIDirectoryServiceProvider, |
michael@0 | 35 | AM_Ci.nsISupports]) |
michael@0 | 36 | }; |
michael@0 | 37 | Services.dirsvc.registerProvider(dirProvider); |
michael@0 | 38 | |
michael@0 | 39 | var addon1 = { |
michael@0 | 40 | id: "addon1@tests.mozilla.org", |
michael@0 | 41 | version: "1.0", |
michael@0 | 42 | name: "Test 1", |
michael@0 | 43 | updateURL: "http://localhost:" + gPort + "/data/test_bug655254.rdf", |
michael@0 | 44 | targetApplications: [{ |
michael@0 | 45 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 46 | minVersion: "1", |
michael@0 | 47 | maxVersion: "1" |
michael@0 | 48 | }] |
michael@0 | 49 | }; |
michael@0 | 50 | |
michael@0 | 51 | // Set up the profile |
michael@0 | 52 | function run_test() { |
michael@0 | 53 | do_test_pending(); |
michael@0 | 54 | run_test_1(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function end_test() { |
michael@0 | 58 | testserver.stop(do_test_finished); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function run_test_1() { |
michael@0 | 62 | var time = Date.now(); |
michael@0 | 63 | var dir = writeInstallRDFForExtension(addon1, userDir); |
michael@0 | 64 | setExtensionModifiedTime(dir, time); |
michael@0 | 65 | |
michael@0 | 66 | manuallyInstall(do_get_addon("test_bug655254_2"), userDir, "addon2@tests.mozilla.org"); |
michael@0 | 67 | |
michael@0 | 68 | startupManager(); |
michael@0 | 69 | |
michael@0 | 70 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 71 | "addon2@tests.mozilla.org"], function([a1, a2]) { |
michael@0 | 72 | do_check_neq(a1, null); |
michael@0 | 73 | do_check_true(a1.appDisabled); |
michael@0 | 74 | do_check_false(a1.isActive); |
michael@0 | 75 | do_check_false(isExtensionInAddonsList(userDir, a1.id)); |
michael@0 | 76 | |
michael@0 | 77 | do_check_neq(a2, null); |
michael@0 | 78 | do_check_false(a2.appDisabled); |
michael@0 | 79 | do_check_true(a2.isActive); |
michael@0 | 80 | do_check_false(isExtensionInAddonsList(userDir, a2.id)); |
michael@0 | 81 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1); |
michael@0 | 82 | |
michael@0 | 83 | a1.findUpdates({ |
michael@0 | 84 | onUpdateFinished: function() { |
michael@0 | 85 | restartManager(); |
michael@0 | 86 | |
michael@0 | 87 | AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) { |
michael@0 | 88 | do_check_neq(a1, null); |
michael@0 | 89 | do_check_false(a1.appDisabled); |
michael@0 | 90 | do_check_true(a1.isActive); |
michael@0 | 91 | do_check_true(isExtensionInAddonsList(userDir, a1.id)); |
michael@0 | 92 | |
michael@0 | 93 | shutdownManager(); |
michael@0 | 94 | |
michael@0 | 95 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0); |
michael@0 | 96 | |
michael@0 | 97 | userDir.parent.moveTo(gProfD, "extensions3"); |
michael@0 | 98 | userDir = gProfD.clone(); |
michael@0 | 99 | userDir.append("extensions3"); |
michael@0 | 100 | userDir.append(gAppInfo.ID); |
michael@0 | 101 | do_check_true(userDir.exists()); |
michael@0 | 102 | |
michael@0 | 103 | startupManager(false); |
michael@0 | 104 | |
michael@0 | 105 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 106 | "addon2@tests.mozilla.org"], function([a1, a2]) { |
michael@0 | 107 | do_check_neq(a1, null); |
michael@0 | 108 | do_check_false(a1.appDisabled); |
michael@0 | 109 | do_check_true(a1.isActive); |
michael@0 | 110 | do_check_true(isExtensionInAddonsList(userDir, a1.id)); |
michael@0 | 111 | |
michael@0 | 112 | do_check_neq(a2, null); |
michael@0 | 113 | do_check_false(a2.appDisabled); |
michael@0 | 114 | do_check_true(a2.isActive); |
michael@0 | 115 | do_check_false(isExtensionInAddonsList(userDir, a2.id)); |
michael@0 | 116 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1); |
michael@0 | 117 | |
michael@0 | 118 | do_execute_soon(run_test_2); |
michael@0 | 119 | }); |
michael@0 | 120 | })); |
michael@0 | 121 | } |
michael@0 | 122 | }, AddonManager.UPDATE_WHEN_USER_REQUESTED); |
michael@0 | 123 | }); |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | //Set up the profile |
michael@0 | 127 | function run_test_2() { |
michael@0 | 128 | AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { |
michael@0 | 129 | do_check_neq(a2, null); |
michael@0 | 130 | do_check_false(a2.appDisabled); |
michael@0 | 131 | do_check_true(a2.isActive); |
michael@0 | 132 | do_check_false(isExtensionInAddonsList(userDir, a2.id)); |
michael@0 | 133 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1); |
michael@0 | 134 | |
michael@0 | 135 | a2.userDisabled = true; |
michael@0 | 136 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0); |
michael@0 | 137 | |
michael@0 | 138 | shutdownManager(); |
michael@0 | 139 | |
michael@0 | 140 | userDir.parent.moveTo(gProfD, "extensions4"); |
michael@0 | 141 | userDir = gProfD.clone(); |
michael@0 | 142 | userDir.append("extensions4"); |
michael@0 | 143 | userDir.append(gAppInfo.ID); |
michael@0 | 144 | do_check_true(userDir.exists()); |
michael@0 | 145 | |
michael@0 | 146 | startupManager(false); |
michael@0 | 147 | |
michael@0 | 148 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 149 | "addon2@tests.mozilla.org"], function([a1, a2]) { |
michael@0 | 150 | do_check_neq(a1, null); |
michael@0 | 151 | do_check_false(a1.appDisabled); |
michael@0 | 152 | do_check_true(a1.isActive); |
michael@0 | 153 | do_check_true(isExtensionInAddonsList(userDir, a1.id)); |
michael@0 | 154 | |
michael@0 | 155 | do_check_neq(a2, null); |
michael@0 | 156 | do_check_true(a2.userDisabled); |
michael@0 | 157 | do_check_false(a2.isActive); |
michael@0 | 158 | do_check_false(isExtensionInAddonsList(userDir, a2.id)); |
michael@0 | 159 | do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0); |
michael@0 | 160 | |
michael@0 | 161 | end_test(); |
michael@0 | 162 | }); |
michael@0 | 163 | })); |
michael@0 | 164 | } |