url_exceptions_worker.js (744B)
1 function ok(a, msg) { 2 postMessage({ type: "status", status: !!a, msg }); 3 } 4 5 onmessage = function () { 6 // URL.href throws 7 var url = new URL("http://www.example.com"); 8 ok(url, "URL created"); 9 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"); 17 18 url.href = "http://www.example.org"; 19 ok(true, "url.href should not throw"); 20 21 status = false; 22 try { 23 new URL("42"); 24 } catch (e) { 25 status = true; 26 } 27 ok(status, "new URL(42) should throw"); 28 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"); 36 37 postMessage({ type: "finish" }); 38 };