summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_throttlequeue.js
blob: fdfa80d1b0aa036cacb282cbf2b39d33db837d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Test ThrottleQueue initialization.

function init(tq, mean, max) {
  let threw = false;
  try {
    tq.init(mean, max);
  } catch (e) {
    threw = true;
  }
  return !threw;
}

function run_test() {
  let tq = Cc["@mozilla.org/network/throttlequeue;1"]
      .createInstance(Ci.nsIInputChannelThrottleQueue);

  ok(!init(tq, 0, 50), "mean bytes cannot be 0");
  ok(!init(tq, 50, 0), "max bytes cannot be 0");
  ok(!init(tq, 0, 0), "mean and max bytes cannot be 0");
  ok(!init(tq, 70, 20), "max cannot be less than mean");

  ok(init(tq, 2, 2), "valid initialization");
}