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 | Components.utils.import("resource://testing-common/httpd.js"); |
michael@0 | 6 | var gServer = new HttpServer(); |
michael@0 | 7 | gServer.start(-1); |
michael@0 | 8 | |
michael@0 | 9 | const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; |
michael@0 | 10 | |
michael@0 | 11 | const PORT = gServer.identity.primaryPort; |
michael@0 | 12 | const BASE_URL = "http://localhost:" + PORT; |
michael@0 | 13 | const DEFAULT_URL = "about:blank"; |
michael@0 | 14 | |
michael@0 | 15 | var addon = { |
michael@0 | 16 | id: "addon@tests.mozilla.org", |
michael@0 | 17 | version: "1.0", |
michael@0 | 18 | name: "Test", |
michael@0 | 19 | targetApplications: [{ |
michael@0 | 20 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 21 | minVersion: "1", |
michael@0 | 22 | maxVersion: "1" |
michael@0 | 23 | }] |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | const profileDir = gProfD.clone(); |
michael@0 | 27 | profileDir.append("extensions"); |
michael@0 | 28 | |
michael@0 | 29 | function backgroundUpdate(aCallback) { |
michael@0 | 30 | Services.obs.addObserver(function() { |
michael@0 | 31 | Services.obs.removeObserver(arguments.callee, "addons-background-update-complete"); |
michael@0 | 32 | aCallback(); |
michael@0 | 33 | }, "addons-background-update-complete", false); |
michael@0 | 34 | |
michael@0 | 35 | AddonManagerPrivate.backgroundUpdateCheck(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function run_test() { |
michael@0 | 39 | do_test_pending(); |
michael@0 | 40 | |
michael@0 | 41 | mapUrlToFile("/cache.xml", do_get_file("data/test_sourceURI.xml"), gServer); |
michael@0 | 42 | Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, BASE_URL + "/cache.xml"); |
michael@0 | 43 | Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE, BASE_URL + "/cache.xml"); |
michael@0 | 44 | Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); |
michael@0 | 45 | |
michael@0 | 46 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); |
michael@0 | 47 | writeInstallRDFForExtension(addon, profileDir); |
michael@0 | 48 | startupManager(); |
michael@0 | 49 | |
michael@0 | 50 | AddonManager.getAddonByID("addon@tests.mozilla.org", function(a) { |
michael@0 | 51 | do_check_neq(a, null); |
michael@0 | 52 | do_check_eq(a.sourceURI, null); |
michael@0 | 53 | |
michael@0 | 54 | backgroundUpdate(function() { |
michael@0 | 55 | restartManager(); |
michael@0 | 56 | |
michael@0 | 57 | AddonManager.getAddonByID("addon@tests.mozilla.org", function(a) { |
michael@0 | 58 | do_check_neq(a, null); |
michael@0 | 59 | do_check_neq(a.sourceURI, null); |
michael@0 | 60 | do_check_eq(a.sourceURI.spec, "http://www.example.com/testaddon.xpi"); |
michael@0 | 61 | |
michael@0 | 62 | do_test_finished(); |
michael@0 | 63 | }); |
michael@0 | 64 | }); |
michael@0 | 65 | }); |
michael@0 | 66 | } |