Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-postmessage-arrays.html
blob3ca1c4d5a0a98919612f45d6caeb648e6573ef10
1 <html>
2 <head/>
3 <body>
4 <div id="description"/>
5 <div id="console"/>
6 <script>
7 if (window.testRunner) {
8 testRunner.dumpAsText();
9 testRunner.waitUntilDone();
12 var console = document.getElementById("console");
13 var maxCount = 30;
15 function recieveMessage(evt) {
16 try {
17 var data = evt.data;
18 if (data.i == 0) {
19 console.innerHTML += "Done."
20 if (window.testRunner)
21 testRunner.notifyDone();
23 else {
24 if (data.i < maxCount) {
25 var success = true;
26 for (var j = data.i; j < maxCount; j++) {
27 success = success && data.a[j] == j;
28 if (data.a[j] != j) {
29 console.innerHTML += "Failure: data.i = " + data.i + " j = " + j + " data.a[j] = " + data.a[j] + "<br>";
30 break;
33 if (data.a.foobar != "FooBar")
34 success = false;
35 if (data.a.length != maxCount) {
36 success = false;
37 console.innerHTML += "FAIL: i = " + data.i + " length = " + data.a.length;
39 if (success)
40 console.innerHTML += "PASS: i = " + data.i + "<br>";
41 else
42 console.innerHTML += "FAIL: i = " + data.i + " array: " + JSON.stringify(data.a) + "<br>";
44 var a = [];
45 for (var j = data.i - 1; j < maxCount; j++) {
46 a[j] = j;
48 a.foobar = "FooBar";
49 window.postMessage({i:data.i - 1, a:a}, '*');
51 } catch (e) {
52 console.innerHTML += "Exception " + e + "<br>";
53 if (window.testRunner)
54 testRunner.notifyDone();
57 window.addEventListener('message', recieveMessage, false);
59 window.postMessage({i:maxCount}, '*');
60 </script>
61 </body>
62 </html>