dom/workers/test/url_exceptions_worker.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/test/url_exceptions_worker.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +function ok(a, msg) {
     1.5 +  postMessage({type: 'status', status: !!a, msg: msg });
     1.6 +}
     1.7 +
     1.8 +onmessage = function(event) {
     1.9 +  // URL.href throws
    1.10 +  var url = new URL('http://www.example.com');
    1.11 +  ok(url, "URL created");
    1.12 +
    1.13 +  var status = false;
    1.14 +  try {
    1.15 +    url.href = '42';
    1.16 +  } catch(e) {
    1.17 +    status = true;
    1.18 +  }
    1.19 +  ok(status, "url.href = 42 should throw");
    1.20 +
    1.21 +  url.href = 'http://www.example.org';
    1.22 +  ok(true, "url.href should not throw");
    1.23 +
    1.24 +  status = false
    1.25 +  try {
    1.26 +    new URL('42');
    1.27 +  } catch(e) {
    1.28 +    status = true;
    1.29 +  }
    1.30 +  ok(status, "new URL(42) should throw");
    1.31 +
    1.32 +  status = false
    1.33 +  try {
    1.34 +    new URL('http://www.example.com', '42');
    1.35 +  } catch(e) {
    1.36 +    status = true;
    1.37 +  }
    1.38 +  ok(status, "new URL(something, 42) should throw");
    1.39 +
    1.40 +  postMessage({type: 'finish' });
    1.41 +}

mercurial