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

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

Issue 2810543002: [tests] Convert a detached typed array to a null string (Closed)
Patch Set: Created 3 years, 8 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 | « AUTHORS ('k') | no next file » | 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>
3 <script src="../../../resources/js-test.js"></script> 3 <script src="../../../resources/js-test.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <script> 6 <script>
7 description("Test window.postMessage() argument handling."); 7 description("Test window.postMessage() argument handling.");
8 8
9 self.jsTestIsAsync = true; 9 self.jsTestIsAsync = true;
10 10
(...skipping 17 matching lines...) Expand all
28 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul dFail) { 28 function tryPostMessageFunction(postMessageFunction, first, second, third, shoul dFail) {
29 var pass, reason; 29 var pass, reason;
30 try { 30 try {
31 postMessageFunction(first, second, third); 31 postMessageFunction(first, second, third);
32 pass = !shouldFail; 32 pass = !shouldFail;
33 reason = " did not throw an exception"; 33 reason = " did not throw an exception";
34 } catch (e) { 34 } catch (e) {
35 pass = shouldFail; 35 pass = shouldFail;
36 reason = ": threw exception " + e; 36 reason = ": threw exception " + e;
37 } 37 }
38 // we cannot convert detached typed arrays into strings, thus
39 // manually convert detached typed arrays into a null string.
40 if (first instanceof Int8Array && first.byteLength === 0)
41 first = "";
42 for (var i = 0; third && i < third.length; i++) {
43 if (third[i] instanceof Int8Array && third[i].byteLength === 0)
44 third[i] = "";
45 }
Dan Ehrenberg 2017/04/11 10:20:22 Nit: this code could be slightly cleaned up, and c
Choongwoo Han 2017/04/11 12:48:23 Done.
38 if (pass) 46 if (pass)
39 testPassed("Posting message ('" + first + "', " + third + ")" + reason); 47 testPassed("Posting message ('" + first + "', " + third + ")" + reason);
40 else 48 else
41 testFailed("Posting message ('" + first + "', " + third + ")" + reason); 49 testFailed("Posting message ('" + first + "', " + third + ")" + reason);
42 } 50 }
43 51
44 function tryPostMessage(first, second, third, shouldFail) { 52 function tryPostMessage(first, second, third, shouldFail) { tryPostMessageFuncti on(window.postMessage, first, second, third, shouldFail);
Dan Ehrenberg 2017/04/11 10:20:22 Nit: Undo this whitespace change.
Choongwoo Han 2017/04/11 12:48:23 Done.
45 tryPostMessageFunction(window.postMessage, first, second, third, shouldFail) ;
46 } 53 }
47 54
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>"; 55 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 56
50 tryPostMessage('1', '*', 1, true); 57 tryPostMessage('1', '*', 1, true);
51 tryPostMessage('2', '*', 'c', true); 58 tryPostMessage('2', '*', 'c', true);
52 tryPostMessage('3', '*', { x: 1 }, true); 59 tryPostMessage('3', '*', { x: 1 }, true);
53 tryPostMessage('4', '*', window); // Passes because window has a "length" attri bute of value '0', so it looks like an array 60 tryPostMessage('4', '*', window); // Passes because window has a "length" attri bute of value '0', so it looks like an array
54 tryPostMessage('5', '*', undefined); 61 tryPostMessage('5', '*', undefined);
55 tryPostMessage('5a', '*', null, true); 62 tryPostMessage('5a', '*', null, true);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true); 99 tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true);
93 tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessag e], true); 100 tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessag e], true);
94 101
95 shouldThrow("window.postMessage()"); 102 shouldThrow("window.postMessage()");
96 shouldThrow("window.postMessage('a')"); 103 shouldThrow("window.postMessage('a')");
97 104
98 tryPostMessageFunction(window.postMessage, 'done', '*'); 105 tryPostMessageFunction(window.postMessage, 'done', '*');
99 </script> 106 </script>
100 </body> 107 </body>
101 </html> 108 </html>
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698