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

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

Issue 1025203002: Have postMessage()s throw TypeError on failed arity checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tidy up incorrect postMessage() usage 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/Window/window-postmessage-args.html
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-args.html b/LayoutTests/fast/dom/Window/window-postmessage-args.html
index 805c582fa98ef55c350390dbe2b96696ae1fb37f..97155c3d15785043cd5a979c36a1e07665a660eb 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-args.html
+++ b/LayoutTests/fast/dom/Window/window-postmessage-args.html
@@ -1,24 +1,26 @@
<html>
-<head></head>
+<head>
+<script src="../../../resources/js-test.js"></script>
+</head>
<body>
-<div id="description"></div>
-<div id="console"></div>
<script>
+description("Test window.postMessage() argument handling.");
+
+self.jsTestIsAsync = true;
+
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
-var console = document.getElementById("console");
-
function onmessage(evt) {
if (evt.ports)
- console.innerHTML += "Received message '" + evt.data + "' with " + evt.ports.length + " ports.<br>";
+ debug("Received message '" + evt.data + "' with " + evt.ports.length + " ports.");
else
- console.innerHTML += "Received message '" + evt.data + "'<br>";
+ debug("Received message '" + evt.data);
- if (evt.data == 'done' && window.testRunner)
- testRunner.notifyDone();
+ if (evt.data == 'done')
+ finishJSTest();
}
window.addEventListener('message', onmessage, false);
@@ -33,7 +35,10 @@ function tryPostMessageFunction(postMessageFunction, first, second, third, shoul
pass = shouldFail;
reason = ": threw exception " + e;
}
- console.innerHTML += (pass ? "PASS" : "FAIL") + ": Posting message ('" + first + "', " + third + ")" + reason + "<br>";
+ if (pass)
+ testPassed("Posting message ('" + first + "', " + third + ")" + reason);
+ else
+ testFailed("Posting message ('" + first + "', " + third + ")" + reason);
}
function tryPostMessage(first, second, third, shouldFail) {
@@ -69,19 +74,16 @@ tryPostMessageFunction(window.postMessage, [channel5.port1, channel5.port2], '*'
var arrayBuffer = new ArrayBuffer(30);
var int8View = new Int8Array(arrayBuffer, 2, 10);
tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [arrayBuffer]);
-if (!(arrayBuffer.byteLength === 0)) {
- console.innerHTML += "FAIL: arrayBuffer not neutered; byteLength = " + arrayBuffer.byteLength + "<br>";
-}
-else {
- console.innerHTML += "PASS: arrayBuffer neutered<br>";
-}
+if (!(arrayBuffer.byteLength === 0))
+ testFailed("arrayBuffer not neutered; byteLength = " + arrayBuffer.byteLength);
+else
+ testPassed("arrayBuffer neutered");
+
+if (!(int8View.length == 0))
+ testFailed("view was not neutered; length = " + int8View.length);
+else
+ testPassed("view neutered");
-if (!(int8View.length == 0)) {
- console.innerHTML += "FAIL: view was not neutered; length = " + int8View.length + "<br>";
-}
-else {
- console.innerHTML += "PASS: view neutered<br>"
-}
tryPostMessageFunction(window.postMessage, arrayBuffer, '*', [], true);
tryPostMessageFunction(window.postMessage, 'data', '*', [arrayBuffer], true);
@@ -92,6 +94,9 @@ tryPostMessageFunction(window.postMessage, 'data', '*', {length:1}, true);
tryPostMessageFunction(window.postMessage, 'data', '*', [1,,2], true);
tryPostMessageFunction(window.postMessage, 'data', '*', [null, window.postMessage], true);
+shouldThrow("window.postMessage()");
+shouldThrow("window.postMessage('a')");
+
tryPostMessageFunction(window.postMessage, 'done', '*');
</script>
</body>
« 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