WorkerTest_subworker.js (1000B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 onmessage = function (event) { 6 let chromeURL = event.data.replace( 7 "test_chromeWorkerJSM.xhtml", 8 "WorkerTest_badworker.js" 9 ); 10 11 let mochitestURL = event.data 12 .replace("test_chromeWorkerJSM.xhtml", "WorkerTest_badworker.js") 13 .replace( 14 "chrome://mochitests/content/chrome", 15 "http://mochi.test:8888/tests" 16 ); 17 18 // We should be able to XHR to anything we want, including a chrome URL. 19 let xhr = new XMLHttpRequest(); 20 xhr.open("GET", mochitestURL, false); 21 xhr.send(); 22 23 if (!xhr.responseText) { 24 throw "Can't load script file via XHR!"; 25 } 26 27 // We shouldn't be able to make a ChromeWorker to a non-chrome URL. 28 try { 29 new ChromeWorker(mochitestURL); 30 } catch (e) { 31 if (e.name === "SecurityError") { 32 postMessage("Done"); 33 return; 34 } 35 } 36 throw "creating a chrome worker with a bad URL should throw a SecurityError"; 37 };