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