Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: LayoutTests/fast/dom/Window/window-postmessage-args.html

Issue 1033443002: Revert of Have postMessage()s throw TypeError on failed arity checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head></head>
3 <script src="../../../resources/js-test.js"></script>
4 </head>
5 <body> 3 <body>
4 <div id="description"></div>
5 <div id="console"></div>
6 <script> 6 <script>
7 description("Test window.postMessage() argument handling.");
8
9 self.jsTestIsAsync = true;
10
11 if (window.testRunner) { 7 if (window.testRunner) {
12 testRunner.dumpAsText(); 8 testRunner.dumpAsText();
13 testRunner.waitUntilDone(); 9 testRunner.waitUntilDone();
14 } 10 }
15 11
12 var console = document.getElementById("console");
13
16 function onmessage(evt) { 14 function onmessage(evt) {
17 if (evt.ports) 15 if (evt.ports)
18 debug("Received message '" + evt.data + "' with " + evt.ports.length + " ports."); 16 console.innerHTML += "Received message '" + evt.data + "' with " + evt.p orts.length + " ports.<br>";
19 else 17 else
20 debug("Received message '" + evt.data); 18 console.innerHTML += "Received message '" + evt.data + "'<br>";
21 19
22 if (evt.data == 'done') 20 if (evt.data == 'done' && window.testRunner)
23 finishJSTest(); 21 testRunner.notifyDone();
24 } 22 }
25 23
26 window.addEventListener('message', onmessage, false); 24 window.addEventListener('message', onmessage, false);
27 25
28 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul dFail) { 26 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul dFail) {
29 var pass, reason; 27 var pass, reason;
30 try { 28 try {
31 postMessageFunction(first, second, third); 29 postMessageFunction(first, second, third);
32 pass = !shouldFail; 30 pass = !shouldFail;
33 reason = " did not throw an exception"; 31 reason = " did not throw an exception";
34 } catch (e) { 32 } catch (e) {
35 pass = shouldFail; 33 pass = shouldFail;
36 reason = ": threw exception " + e; 34 reason = ": threw exception " + e;
37 } 35 }
38 if (pass) 36 console.innerHTML += (pass ? "PASS" : "FAIL") + ": Posting message ('" + fir st + "', " + third + ")" + reason + "<br>";
39 testPassed("Posting message ('" + first + "', " + third + ")" + reason);
40 else
41 testFailed("Posting message ('" + first + "', " + third + ")" + reason);
42 } 37 }
43 38
44 function tryPostMessage(first, second, third, shouldFail) { 39 function tryPostMessage(first, second, third, shouldFail) {
45 tryPostMessageFunction(window.postMessage, first, second, third, shouldFail) ; 40 tryPostMessageFunction(window.postMessage, first, second, third, shouldFail) ;
46 } 41 }
47 42
48 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>";
49 44
50 tryPostMessage('1', '*', 1, true); 45 tryPostMessage('1', '*', 1, true);
51 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 15 matching lines...) Expand all
67 var channel4 = new MessageChannel; 62 var channel4 = new MessageChannel;
68 tryPostMessageFunction(window.postMessage, channel4.port1, '*', [channel4.port1, channel4.port2]); 63 tryPostMessageFunction(window.postMessage, channel4.port1, '*', [channel4.port1, channel4.port2]);
69 var channel5 = new MessageChannel; 64 var channel5 = new MessageChannel;
70 tryPostMessageFunction(window.postMessage, [channel5.port1, channel5.port2], '*' , [channel5.port1, channel5.port2]); 65 tryPostMessageFunction(window.postMessage, [channel5.port1, channel5.port2], '*' , [channel5.port1, channel5.port2]);
71 tryPostMessageFunction(window.postMessage, 'data', '*', [channel5.port1, channel 5.port2], true); 66 tryPostMessageFunction(window.postMessage, 'data', '*', [channel5.port1, channel 5.port2], true);
72 tryPostMessageFunction(window.postMessage, [channel5.port1, channel5.port2], '*' , [], true); 67 tryPostMessageFunction(window.postMessage, [channel5.port1, channel5.port2], '*' , [], true);
73 68
74 var arrayBuffer = new ArrayBuffer(30); 69 var arrayBuffer = new ArrayBuffer(30);
75 var int8View = new Int8Array(arrayBuffer, 2, 10); 70 var int8View = new Int8Array(arrayBuffer, 2, 10);
76 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [arrayBuffer]); 71 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [arrayBuffer]);
77 if (!(arrayBuffer.byteLength === 0)) 72 if (!(arrayBuffer.byteLength === 0)) {
78 testFailed("arrayBuffer not neutered; byteLength = " + arrayBuffer.byteLengt h); 73 console.innerHTML += "FAIL: arrayBuffer not neutered; byteLength = " + array Buffer.byteLength + "<br>";
79 else 74 }
80 testPassed("arrayBuffer neutered"); 75 else {
76 console.innerHTML += "PASS: arrayBuffer neutered<br>";
77 }
81 78
82 if (!(int8View.length == 0)) 79 if (!(int8View.length == 0)) {
83 testFailed("view was not neutered; length = " + int8View.length); 80 console.innerHTML += "FAIL: view was not neutered; length = " + int8View.len gth + "<br>";
84 else 81 }
85 testPassed("view neutered"); 82 else {
86 83 console.innerHTML += "PASS: view neutered<br>"
84 }
87 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [], true); 85 tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [], true);
88 tryPostMessageFunction(window.postMessage, 'data', '*', [arrayBuffer], true); 86 tryPostMessageFunction(window.postMessage, 'data', '*', [arrayBuffer], true);
89 87
90 tryPostMessageFunction(window.postMessage, int8View, '*', [], true); 88 tryPostMessageFunction(window.postMessage, int8View, '*', [], true);
91 tryPostMessageFunction(window.postMessage, 'data', '*', [int8View], true); 89 tryPostMessageFunction(window.postMessage, 'data', '*', [int8View], true);
92 90
93 tryPostMessageFunction(window.postMessage, 'data', '*', {length:1}, true); 91 tryPostMessageFunction(window.postMessage, 'data', '*', {length:1}, true);
94 tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true); 92 tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true);
95 tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessag e], true); 93 tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessag e], true);
96 94
97 shouldThrow("window.postMessage()");
98 shouldThrow("window.postMessage('a')");
99
100 tryPostMessageFunction(window.postMessage, 'done', '*'); 95 tryPostMessageFunction(window.postMessage, 'done', '*');
101 </script> 96 </script>
102 </body> 97 </body>
103 </html> 98 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698