blob: ccf3cb623ec7d8ceca01eb2cca7f27e47d1b344f [file] [log] [blame]
<!DOCTYPE html>
<p>Tests that properties of CustomEvent initialized with initCustomEvent() 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("CustomEvent", function(event) {
console.log("CustomEvent received in " + worldType + " world");
console.log("detail was " + JSON.stringify(event.detail));
});
}
function sendCloneableObject(targetWorldType) {
var newEvent = document.createEvent("CustomEvent");
newEvent.initCustomEvent("CustomEvent", 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>