dom/workers/test/url_exceptions_worker.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 function ok(a, msg) {
     2   postMessage({type: 'status', status: !!a, msg: msg });
     3 }
     5 onmessage = function(event) {
     6   // URL.href throws
     7   var url = new URL('http://www.example.com');
     8   ok(url, "URL created");
    10   var status = false;
    11   try {
    12     url.href = '42';
    13   } catch(e) {
    14     status = true;
    15   }
    16   ok(status, "url.href = 42 should throw");
    18   url.href = 'http://www.example.org';
    19   ok(true, "url.href should not throw");
    21   status = false
    22   try {
    23     new URL('42');
    24   } catch(e) {
    25     status = true;
    26   }
    27   ok(status, "new URL(42) should throw");
    29   status = false
    30   try {
    31     new URL('http://www.example.com', '42');
    32   } catch(e) {
    33     status = true;
    34   }
    35   ok(status, "new URL(something, 42) should throw");
    37   postMessage({type: 'finish' });
    38 }

mercurial