| |
1 function postMsg(message) |
| |
2 { |
| |
3 var l = SpecialPowers.wrap(parent.window.location); |
| |
4 parent.postMessage(message, l.protocol + "//" + l.host); |
| |
5 } |
| |
6 |
| |
7 window.addEventListener("message", onMessageReceived, false); |
| |
8 |
| |
9 function onMessageReceived(event) |
| |
10 { |
| |
11 if (event.data == "step") { |
| |
12 var performed = false; |
| |
13 try { |
| |
14 performed = doStep(); |
| |
15 } |
| |
16 catch (ex) { |
| |
17 postMsg("FAILURE: exception threw at "+ location +":\n" + ex); |
| |
18 finishTest(); |
| |
19 } |
| |
20 |
| |
21 if (performed) |
| |
22 postMsg("perf"); |
| |
23 |
| |
24 return; |
| |
25 } |
| |
26 |
| |
27 if (parent) |
| |
28 postMsg(event.data); |
| |
29 } |
| |
30 |
| |
31 function ok(a, message) |
| |
32 { |
| |
33 if (!a) |
| |
34 postMsg("FAILURE: " + message); |
| |
35 else |
| |
36 postMsg(message); |
| |
37 } |
| |
38 |
| |
39 function is(a, b, message) |
| |
40 { |
| |
41 if (a != b) |
| |
42 postMsg("FAILURE: " + message + ", expected "+b+" got "+a); |
| |
43 else |
| |
44 postMsg(message + ", expected "+b+" got "+a); |
| |
45 } |
| |
46 |
| |
47 function todo(a, b, message) |
| |
48 { |
| |
49 postMsg("TODO: " + message + ", expected "+b+" got "+a); |
| |
50 } |
| |
51 |
| |
52 function finishTest() |
| |
53 { |
| |
54 postMsg("done"); |
| |
55 return false; |
| |
56 } |