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 let proxyPrefValue;
3 // ----------------------------------------------------------------------------
4 // Tests that going offline cancels an in progress download.
5 function test() {
6 Harness.downloadProgressCallback = download_progress;
7 Harness.installsCompletedCallback = finish_test;
8 Harness.setup();
10 var pm = Services.perms;
11 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
13 var triggers = encodeURIComponent(JSON.stringify({
14 "Unsigned XPI": TESTROOT + "unsigned.xpi"
15 }));
16 gBrowser.selectedTab = gBrowser.addTab();
17 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
18 }
20 function download_progress(addon, value, maxValue) {
21 try {
22 // Tests always connect to localhost, and per bug 87717, localhost is now
23 // reachable in offline mode. To avoid this, disable any proxy.
24 proxyPrefValue = Services.prefs.getIntPref("network.proxy.type");
25 Services.prefs.setIntPref("network.proxy.type", 0);
26 Services.io.manageOfflineStatus = false;
27 Services.io.offline = true;
28 } catch (ex) {
29 }
30 }
32 function finish_test(count) {
33 function wait_for_online() {
34 info("Checking if the browser is still offline...");
36 let tab = gBrowser.selectedTab;
37 tab.linkedBrowser.addEventListener("DOMContentLoaded", function errorLoad() {
38 tab.linkedBrowser.removeEventListener("DOMContentLoaded", errorLoad, true);
39 let url = tab.linkedBrowser.contentDocument.documentURI;
40 info("loaded: " + url);
41 if (/^about:neterror\?e=netOffline/.test(url)) {
42 wait_for_online();
43 } else {
44 gBrowser.removeCurrentTab();
45 Harness.finish();
46 }
47 }, true);
48 tab.linkedBrowser.loadURI("http://example.com/");
49 }
51 is(count, 0, "No add-ons should have been installed");
52 try {
53 Services.prefs.setIntPref("network.proxy.type", proxyPrefValue);
54 Services.io.offline = false;
55 } catch (ex) {
56 }
58 Services.perms.remove("example.com", "install");
60 wait_for_online();
61 }