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