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

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");
}