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 var prefetch = Cc["@mozilla.org/prefetch-service;1"].
2 getService(Ci.nsIPrefetchService);
3 var ios = Cc["@mozilla.org/network/io-service;1"].
4 getService(Ci.nsIIOService);
5 var prefs = Cc["@mozilla.org/preferences-service;1"].
6 getService(Ci.nsIPrefBranch);
8 function run_test() {
9 // Fill up the queue
10 prefs.setBoolPref("network.prefetch-next", true);
11 for (var i = 0; i < 5; i++) {
12 var uri = ios.newURI("http://localhost/" + i, null, null);
13 prefetch.prefetchURI(uri, uri, null, true);
14 }
16 // Make sure the queue has items in it...
17 var queue = prefetch.enumerateQueue();
18 do_check_true(queue.hasMoreElements());
20 // Now disable the pref to force the queue to empty...
21 prefs.setBoolPref("network.prefetch-next", false);
22 queue = prefetch.enumerateQueue();
23 do_check_false(queue.hasMoreElements());
25 // Now reenable the pref, and add more items to the queue.
26 prefs.setBoolPref("network.prefetch-next", true);
27 for (var i = 0; i < 5; i++) {
28 var uri = ios.newURI("http://localhost/" + i, null, null);
29 prefetch.prefetchURI(uri, uri, null, true);
30 }
31 queue = prefetch.enumerateQueue();
32 do_check_true(queue.hasMoreElements());
33 }