summaryrefslogtreecommitdiffstats
path: root/dom/url/tests/url_exceptions_worker.js
blob: caefc22021e01239642e25a41d64ce4804d34c36 (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
function ok(a, msg) {
  postMessage({type: 'status', status: !!a, msg: msg });
}

onmessage = function(event) {
  // URL.href throws
  var url = new URL('http://www.example.com');
  ok(url, "URL created");

  var status = false;
  try {
    url.href = '42';
  } catch(e) {
    status = true;
  }
  ok(status, "url.href = 42 should throw");

  url.href = 'http://www.example.org';
  ok(true, "url.href should not throw");

  status = false
  try {
    new URL('42');
  } catch(e) {
    status = true;
  }
  ok(status, "new URL(42) should throw");

  status = false
  try {
    new URL('http://www.example.com', '42');
  } catch(e) {
    status = true;
  }
  ok(status, "new URL(something, 42) should throw");

  postMessage({type: 'finish' });
}