| <html> |
| <head></head> |
| <body> |
| <div id="description"></div> |
| <div id="console"></div> |
| <script> |
| if (window.layoutTestController) { |
| layoutTestController.dumpAsText(); |
| layoutTestController.waitUntilDone(); |
| } |
| |
| var console = document.getElementById("console"); |
| |
| function onmessage(evt) { |
| console.innerHTML += "Received message '" + evt.data + "'<br>"; |
| |
| if (evt.data == 'done' && window.layoutTestController) |
| layoutTestController.notifyDone(); |
| } |
| |
| window.addEventListener('message', onmessage, false); |
| |
| function tryPostMessage(first, second, third) { |
| try { |
| if (!third) |
| window.postMessage(first, second); |
| else |
| window.postMessage(first, second, third); |
| } catch (e) { |
| console.innerHTML += "FAIL: Posting message (" + first + ", " + second + "): threw exception " + e + "<br>"; |
| } |
| } |
| |
| document.getElementById("description").innerHTML = "Test that the second argument of window.postMessage is ignored if it is not a message port. You should see messages '1' through '6', followed by 'done', received below.<br><br>Note that the HTML5 spec implies that an exception should be raised instead, so this test will need updating once that new behavior is implemented.<br><br>"; |
| |
| tryPostMessage('1', 1, '*'); |
| tryPostMessage('2', "", '*'); |
| tryPostMessage('3', window, '*'); |
| tryPostMessage('4', { x: 1 }, '*'); |
| tryPostMessage('5', null, '*'); |
| tryPostMessage('6', void 0, '*'); |
| tryPostMessage('done', '*'); |
| </script> |
| </body> |
| </html> |