2 <p>Tests that properties of MessageEvents initialized with initMessageEvent() are cloned when accessed in isolated worlds.
</p>
4 <div id=
"isolated"></div>
6 testRunner
.dumpAsText();
8 function addListener(worldType
) {
9 document
.getElementById(worldType
).addEventListener("MessageEvent", function(event
) {
10 console
.log("MessageEvent received in " + worldType
+ " world");
11 console
.log("detail was " + JSON
.stringify(event
.data
));
15 function sendCloneableObject(targetWorldType
) {
16 var newEvent
= document
.createEvent("MessageEvent");
17 newEvent
.initMessageEvent("MessageEvent", false, false, { foo
: 5, bar
: 'hello', targetWorld
: targetWorldType
});
18 document
.getElementById(targetWorldType
).dispatchEvent(newEvent
);
21 var sendScript
= "(" + sendCloneableObject
.toString() + ")('main');";
23 testRunner
.evaluateScriptInIsolatedWorld(1, sendScript
);
24 var receiveScript
= "(" + addListener
.toString() + ")('isolated');";
25 testRunner
.evaluateScriptInIsolatedWorld(1, receiveScript
);
26 sendCloneableObject("isolated");