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> |