summaryrefslogtreecommitdiffstats
path: root/dom/url/tests/urlSearchParams_worker.js
blob: 16314a41c5f96a34463ab2d3dec1a1fb50fb7874 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-env worker */

importScripts("urlSearchParams_commons.js");

function ok(a, msg) {
  dump("OK: " + !!a + "  =>  " + a + " " + msg + "\n");
  postMessage({ type: "status", status: !!a, msg: a + ": " + msg });
}

function is(a, b, msg) {
  dump("IS: " + (a === b) + "  =>  " + a + " | " + b + " " + msg + "\n");
  postMessage({
    type: "status",
    status: a === b,
    msg: a + " === " + b + ": " + msg,
  });
}

var tests = [
  testSimpleURLSearchParams,
  testCopyURLSearchParams,
  testParserURLSearchParams,
  testURL,
  testEncoding,
  testCTORs,
];

function runTest() {
  if (!tests.length) {
    postMessage({ type: "finish" });
    return;
  }

  var test = tests.shift();
  test();
}

onmessage = function() {
  let status = false;
  try {
    if (URLSearchParams instanceof Object) {
      status = true;
    }
  } catch (e) {}
  ok(status, "URLSearchParams in workers \\o/");

  runTest();
};