Skip to content

Commit

Permalink
Expand site isolation postMessage testing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=262590
rdar://116436305

Reviewed by Pascoe.

RemoteDOMWindow::postMessage has some branches that weren't tested.

* LayoutTests/http/tests/site-isolation/post-message-expected.txt:
* LayoutTests/http/tests/site-isolation/post-message.html:

Canonical link: https://commits.webkit.org/268827@main
  • Loading branch information
achristensen07 committed Oct 4, 2023
1 parent e9c11a1 commit c18f49f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
PASS posting a message to about:blank threw an exception: SyntaxError: The string did not match the expected pattern.
PASS posting a non-serializable message threw an exception: DataCloneError: The object can not be cloned.
PASS successfullyParsed is true

TEST COMPLETE
PASS received 'iframe received hello'
PASS received 'iframe received world'

22 changes: 20 additions & 2 deletions LayoutTests/http/tests/site-isolation/post-message.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@
testRunner.waitUntilDone();
}

let messageCount = 0;
addEventListener("message", (event) => {
testPassed("received '" + event.data + "'");
testRunner.notifyDone();
messageCount = messageCount + 1;
if (messageCount == 2) { testRunner.notifyDone() }
});

onload = ()=>{ frame.contentWindow.postMessage("hello", "*") }
onload = ()=>{
frame.contentWindow.postMessage("hello", "*")
frame.contentWindow.postMessage("should not be received", "http://webkit.org")
frame.contentWindow.postMessage("world", "http://localhost:8000")

try {
frame.contentWindow.postMessage("should throw", "about:blank")
} catch (e) {
testPassed("posting a message to about:blank threw an exception: " + e)
}

try {
frame.contentWindow.postMessage(window.performance, "/")
} catch (e) {
testPassed("posting a non-serializable message threw an exception: " + e)
}
}

</script>
<iframe src="http://localhost:8000/site-isolation/resources/post-message-to-parent.html" id="frame"></iframe>

0 comments on commit c18f49f

Please sign in to comment.