blob: 875b830a1e0cb4d9440e0e32adc2f9ba99aded4c [file] [log] [blame]
<!DOCTYPE html>
<p>Tests that properties of MessageEvents initialized with initMessageEvent() are cloned when accessed in isolated worlds.</p>
<div id="main"></div>
<div id="isolated"></div>
<script>
testRunner.dumpAsText();
function addListener(worldType) {
document.getElementById(worldType).addEventListener("MessageEvent", function(event) {
console.log("MessageEvent received in " + worldType + " world");
console.log("detail was " + JSON.stringify(event.data));
});
}
function sendCloneableObject(targetWorldType) {
var newEvent = document.createEvent("MessageEvent");
newEvent.initMessageEvent("MessageEvent", false, false, { foo: 5, bar: 'hello', targetWorld: targetWorldType });
document.getElementById(targetWorldType).dispatchEvent(newEvent);
}
var sendScript = "(" + sendCloneableObject.toString() + ")('main');";
addListener("main");
testRunner.evaluateScriptInIsolatedWorld(1, sendScript);
var receiveScript = "(" + addListener.toString() + ")('isolated');";
testRunner.evaluateScriptInIsolatedWorld(1, receiveScript);
sendCloneableObject("isolated");
</script>