| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head></head> | 2 <head></head> |
| 3 <body> | 3 <body> |
| 4 <div id="description"></div> | 4 <div id="description"></div> |
| 5 <div id="console"></div> | 5 <div id="console"></div> |
| 6 <script> | 6 <script> |
| 7 if (window.testRunner) { | 7 if (window.testRunner) { |
| 8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
| 9 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
| 10 } | 10 } |
| 11 | 11 |
| 12 var console = document.getElementById("console"); | 12 var console = document.getElementById("console"); |
| 13 | 13 |
| 14 function onmessage(evt) { | 14 function onmessage(evt) { |
| 15 if (evt.ports) | 15 if (evt.ports) |
| 16 console.innerHTML += "Received message '" + evt.data + "' with " + evt.p
orts.length + " ports.<br>"; | 16 console.innerHTML += "Received message '" + evt.data + "' with " + evt.p
orts.length + " ports.<br>"; |
| 17 else | 17 else |
| 18 console.innerHTML += "Received message '" + evt.data + "'<br>"; | 18 console.innerHTML += "Received message '" + evt.data + "'<br>"; |
| 19 | 19 |
| 20 if (evt.data == 'done' && window.testRunner) | 20 if (evt.data == 'done' && window.testRunner) |
| 21 testRunner.notifyDone(); | 21 testRunner.notifyDone(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 window.addEventListener('message', onmessage, false); | 24 window.addEventListener('message', onmessage, false); |
| 25 | 25 |
| 26 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul
dFail) { | 26 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul
dFail) { |
| 27 try { | 27 var pass, reason; |
| 28 if (!third) | 28 try { |
| 29 postMessageFunction(first, second); | 29 postMessageFunction(first, second, third); |
| 30 else | 30 pass = !shouldFail; |
| 31 postMessageFunction(first, second, third); | 31 reason = " did not throw an exception"; |
| 32 console.innerHTML += (shouldFail ? "FAIL" : "PASS") + ": Posting message
('" + first + "', " + third + ") did not throw an exception<br>"; | 32 } catch (e) { |
| 33 } catch (e) { | 33 pass = shouldFail; |
| 34 console.innerHTML += (shouldFail ? "PASS" : "FAIL") + ": Posting message
('" + first + "', " + third + "): threw exception " + e + "<br>"; | 34 reason = ": threw exception " + e; |
| 35 } | 35 } |
| 36 console.innerHTML += (pass ? "PASS" : "FAIL") + ": Posting message ('" + fir
st + "', " + third + ")" + reason + "<br>"; |
| 36 } | 37 } |
| 37 | 38 |
| 38 function tryPostMessage(first, second, third, shouldFail) { | 39 function tryPostMessage(first, second, third, shouldFail) { |
| 39 tryPostMessageFunction(window.postMessage, first, second, third, shouldFail)
; | 40 tryPostMessageFunction(window.postMessage, first, second, third, shouldFail)
; |
| 40 } | 41 } |
| 41 | 42 |
| 42 document.getElementById("description").innerHTML = "Test that the second argumen
t of window.postMessage is ignored or triggers an error if it is not a message p
ort. You should see PASS message '1' through '7', followed by 'done', with messa
ges 4-7 received below.<br><br>"; | 43 document.getElementById("description").innerHTML = "Test that the second argumen
t of window.postMessage is ignored or triggers an error if it is not a message p
ort. You should see PASS message '1' through '7', followed by 'done', with messa
ges 4-7 received below.<br><br>"; |
| 43 | 44 |
| 44 tryPostMessage('1', '*', 1, true); | 45 tryPostMessage('1', '*', 1, true); |
| 45 tryPostMessage('2', '*', 'c', true); // Legacy overload resolution will consider
3rd argument to be the (string) origin. | 46 tryPostMessage('2', '*', 'c', true); // Legacy overload resolution will consider
3rd argument to be the (string) origin. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 81 } |
| 81 else { | 82 else { |
| 82 console.innerHTML += "PASS: view neutered<br>" | 83 console.innerHTML += "PASS: view neutered<br>" |
| 83 } | 84 } |
| 84 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [], true); | 85 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [], true); |
| 85 tryPostMessageFunction(window.postMessage, 'data', '*', [arrayBuffer], true); | 86 tryPostMessageFunction(window.postMessage, 'data', '*', [arrayBuffer], true); |
| 86 | 87 |
| 87 tryPostMessageFunction(window.postMessage, int8View, '*', [], true); | 88 tryPostMessageFunction(window.postMessage, int8View, '*', [], true); |
| 88 tryPostMessageFunction(window.postMessage, 'data', '*', [int8View], true); | 89 tryPostMessageFunction(window.postMessage, 'data', '*', [int8View], true); |
| 89 | 90 |
| 91 tryPostMessageFunction(window.postMessage, 'data', '*', {length:1}, true); |
| 92 tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true); |
| 93 tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessag
e], true); |
| 94 |
| 90 tryPostMessageFunction(window.postMessage, 'done', '*'); | 95 tryPostMessageFunction(window.postMessage, 'done', '*'); |
| 91 </script> | 96 </script> |
| 92 </body> | 97 </body> |
| 93 </html> | 98 </html> |
| OLD | NEW |