Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <body> |
michael@0 | 4 | <script type="application/javascript"> |
michael@0 | 5 | |
michael@0 | 6 | function ok(what, msg) { |
michael@0 | 7 | window.parent.postMessage({type: what ? 'OK' : 'KO', msg: msg }, '*'); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | window.addEventListener('message', receiveMessage, false); |
michael@0 | 11 | function receiveMessage(evt) { |
michael@0 | 12 | if (evt.data.type == 'PORT') { |
michael@0 | 13 | var port = evt.data.port; |
michael@0 | 14 | var counter = 0; |
michael@0 | 15 | port.onmessage = function(evt) { |
michael@0 | 16 | if (counter++ == 0) { |
michael@0 | 17 | ok(!(evt.data % 2), "The number " + evt.data + " has been received correctly by the iframe"); |
michael@0 | 18 | |
michael@0 | 19 | window.parent.postMessage({ type: 'PORT', port: port }, '*', [port]); |
michael@0 | 20 | } |
michael@0 | 21 | else { |
michael@0 | 22 | ok(false, "Wrong message!"); |
michael@0 | 23 | } |
michael@0 | 24 | } |
michael@0 | 25 | } else { |
michael@0 | 26 | ok(false, "Unknown message"); |
michael@0 | 27 | } |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | </script> |
michael@0 | 31 | </body> |
michael@0 | 32 | </html> |
michael@0 | 33 |