Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / init-custom-event-isolated-world.html
blobccf3cb623ec7d8ceca01eb2cca7f27e47d1b344f
1 <!DOCTYPE html>
2 <p>Tests that properties of CustomEvent initialized with initCustomEvent() are cloned when accessed in isolated worlds.</p>
3 <div id="main"></div>
4 <div id="isolated"></div>
5 <script>
6 testRunner.dumpAsText();
8 function addListener(worldType) {
9 document.getElementById(worldType).addEventListener("CustomEvent", function(event) {
10 console.log("CustomEvent received in " + worldType + " world");
11 console.log("detail was " + JSON.stringify(event.detail));
12 });
15 function sendCloneableObject(targetWorldType) {
16 var newEvent = document.createEvent("CustomEvent");
17 newEvent.initCustomEvent("CustomEvent", false, false, { foo: 5, bar: 'hello', targetWorld: targetWorldType });
18 document.getElementById(targetWorldType).dispatchEvent(newEvent);
21 var sendScript = "(" + sendCloneableObject.toString() + ")('main');";
22 addListener("main");
23 testRunner.evaluateScriptInIsolatedWorld(1, sendScript);
24 var receiveScript = "(" + addListener.toString() + ")('isolated');";
25 testRunner.evaluateScriptInIsolatedWorld(1, receiveScript);
26 sendCloneableObject("isolated");
27 </script>