dom/workers/test/WorkerTest_subworker.js

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:637dcd5f94cf
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("test_chromeWorkerJSM.xul",
7 "WorkerTest_badworker.js");
8
9 let mochitestURL = event.data.replace("test_chromeWorkerJSM.xul",
10 "WorkerTest_badworker.js")
11 .replace("chrome://mochitests/content/chrome",
12 "http://mochi.test:8888/tests");
13
14 // We should be able to XHR to anything we want, including a chrome URL.
15 let xhr = new XMLHttpRequest();
16 xhr.open("GET", mochitestURL, false);
17 xhr.send();
18
19 if (!xhr.responseText) {
20 throw "Can't load script file via XHR!";
21 }
22
23 // We shouldn't be able to make a ChromeWorker to a non-chrome URL.
24 let worker = new ChromeWorker(mochitestURL);
25 worker.onmessage = function(event) {
26 throw event.data;
27 };
28 worker.onerror = function(event) {
29 event.preventDefault();
30
31 // And we shouldn't be able to make a regular Worker to a non-chrome URL.
32 worker = new Worker(mochitestURL);
33 worker.onmessage = function(event) {
34 throw event.data;
35 };
36 worker.onerror = function(event) {
37 event.preventDefault();
38 postMessage("Done");
39 };
40 worker.postMessage("Hi");
41 };
42 worker.postMessage("Hi");
43 };

mercurial