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