importscripts.js (715B)
1 // Testing importScripts() 2 function log(w) { this.postMessage(w) } 3 function f() { log("FAIL") } 4 function p() { log("PASS") } 5 6 const get_url = (mime, outcome) => { 7 let url = "resources/js.py" 8 if (mime != null) { 9 url += "?type=" + encodeURIComponent(mime) 10 } 11 if (outcome) { 12 url += "&outcome=p" 13 } 14 return url 15 } 16 17 [null, "", "x", "x/x", "text/html", "text/json"].forEach(function(mime) { 18 try { 19 importScripts(get_url(mime)) 20 } catch(e) { 21 (e.name == "NetworkError") ? p() : log("FAIL (no NetworkError exception): " + mime) 22 } 23 24 }) 25 importScripts(get_url("text/javascript", true)) 26 importScripts(get_url("text/ecmascript", true)) 27 importScripts(get_url("text/ecmascript;blah", true)) 28 log("END")