test_throttlequeue.js (591B)
1 // Test ThrottleQueue initialization. 2 "use strict"; 3 4 function init(tq, mean, max) { 5 let threw = false; 6 try { 7 tq.init(mean, max); 8 } catch (e) { 9 threw = true; 10 } 11 return !threw; 12 } 13 14 function run_test() { 15 let tq = Cc["@mozilla.org/network/throttlequeue;1"].createInstance( 16 Ci.nsIInputChannelThrottleQueue 17 ); 18 19 ok(!init(tq, 0, 50), "mean bytes cannot be 0"); 20 ok(!init(tq, 50, 0), "max bytes cannot be 0"); 21 ok(!init(tq, 0, 0), "mean and max bytes cannot be 0"); 22 ok(!init(tq, 70, 20), "max cannot be less than mean"); 23 24 ok(init(tq, 2, 2), "valid initialization"); 25 }