|
1 <?xml version="1.0"?> |
|
2 <!-- |
|
3 Any copyright is dedicated to the Public Domain. |
|
4 http://creativecommons.org/publicdomain/zero/1.0/ |
|
5 --> |
|
6 <window title="DOM Worker Threads Test" |
|
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
8 onload="test();"> |
|
9 |
|
10 <script type="application/javascript" |
|
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
12 <script type="application/javascript" |
|
13 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
14 <script type="application/javascript" src="dom_worker_helper.js"/> |
|
15 |
|
16 <script type="application/javascript"> |
|
17 <![CDATA[ |
|
18 |
|
19 const Cc = Components.classes; |
|
20 const Ci = Components.interfaces; |
|
21 const Cu = Components.utils; |
|
22 |
|
23 Cu.import("resource://gre/modules/Services.jsm"); |
|
24 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
25 |
|
26 function test() { |
|
27 const message = "woohoo"; |
|
28 |
|
29 var workertest = |
|
30 Cc["@mozilla.org/test/workertest;1"].createInstance(Ci.nsIWorkerTest); |
|
31 |
|
32 workertest.callback = { |
|
33 onmessage: function(data) { |
|
34 is(data, message, "Correct message"); |
|
35 workertest.callback = null; |
|
36 workertest = null; |
|
37 SimpleTest.finish(); |
|
38 }, |
|
39 onerror: function(data) { |
|
40 ok(false, "Worker had an error: " + data); |
|
41 workertest.callback = null; |
|
42 workertest = null; |
|
43 SimpleTest.finish(); |
|
44 }, |
|
45 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerTestCallback]) |
|
46 }; |
|
47 |
|
48 workertest.postMessage(message); |
|
49 |
|
50 SimpleTest.waitForExplicitFinish(); |
|
51 } |
|
52 |
|
53 ]]> |
|
54 </script> |
|
55 |
|
56 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
57 <p id="display"></p> |
|
58 <div id="content" style="display:none;"></div> |
|
59 <pre id="test"></pre> |
|
60 </body> |
|
61 <label id="test-result"/> |
|
62 </window> |