2 <p>Tests that properties of various events are cloned between isolated worlds.
</p>
4 <div id=
"isolated"></div>
6 testRunner
.dumpAsText();
8 function addListener(eventType
, prop
, worldType
) {
9 document
.getElementById(worldType
).addEventListener(eventType
, function(event
) {
10 console
.log(eventType
+ " received in " + worldType
+ " world");
11 console
.log(prop
+ " was " + JSON
.stringify(event
[prop
]));
15 function sendCloneableObject(eventType
, prop
, targetWorldType
) {
16 var newEvent
= eval("new " + eventType
+ "('" + eventType
+ "', { " + prop
+ ": { foo: 5, bar: 'hello', targetWorld: targetWorldType } })");
17 document
.getElementById(targetWorldType
).dispatchEvent(newEvent
);
20 function runScript(eventType
, prop
) {
21 var sendScript
= "(" + sendCloneableObject
.toString() + ")('" + eventType
+ "', '" + prop
+ "', 'main');";
22 addListener(eventType
, prop
, "main");
23 testRunner
.evaluateScriptInIsolatedWorld(1, sendScript
);
24 var receiveScript
= "(" + addListener
.toString() + ")('" + eventType
+ "', '" + prop
+ "', 'isolated');";
25 testRunner
.evaluateScriptInIsolatedWorld(1, receiveScript
);
26 sendCloneableObject(eventType
, prop
, "isolated");
30 // The events that we want to test, with the properties that each one uses.
32 { eventType
: "CustomEvent", prop
: "detail" },
33 { eventType
: "MessageEvent", prop
: "data" },
34 { eventType
: "PopStateEvent", prop
: "state" }
37 for (var i
= 0; i
< events
.length
; ++i
) {
38 runScript(events
[i
].eventType
, events
[i
].prop
);