Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 }