|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for SpecialPowers extension</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
7 </head> |
|
8 <body> |
|
9 |
|
10 <pre id="test"> |
|
11 <script class="testbody" type="text/javascript"> |
|
12 SimpleTest.waitForExplicitFinish(); |
|
13 |
|
14 var url = SimpleTest.getTestFileURL("SpecialPowersLoadChromeScript.js"); |
|
15 var script = SpecialPowers.loadChromeScript(url); |
|
16 |
|
17 var MESSAGE = { bar: true }; |
|
18 script.addMessageListener("bar", function (message) { |
|
19 is(JSON.stringify(message), JSON.stringify(MESSAGE), |
|
20 "received back message from the chrome script"); |
|
21 |
|
22 checkAssert(); |
|
23 }); |
|
24 |
|
25 function checkAssert() { |
|
26 script.sendAsyncMessage("valid-assert"); |
|
27 script.addMessageListener("valid-assert-done", endOfTest); |
|
28 } |
|
29 |
|
30 function endOfTest() { |
|
31 script.destroy(); |
|
32 SimpleTest.finish(); |
|
33 } |
|
34 |
|
35 script.sendAsyncMessage("foo", MESSAGE); |
|
36 </script> |
|
37 </pre> |
|
38 </body> |
|
39 </html> |