docshell/test/unit/test_bug442584.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial