Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: LayoutTests/fast/events/init-serviceworker-message-event-isolated-world.html

Issue 1130113006: ServiceWorker: Introduce ServiceWorkerMessageEvent to replace MessageEvent (3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add initEvent tests Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <p>Tests that properties of MessageEvents initialized with initMessageEvent() ar e cloned when accessed in isolated worlds.</p> 2 <p>Tests that properties of ServiceWorkerMessageEvents initialized with initServ iceWorkerMessageEvent() are cloned when accessed in isolated worlds.</p>
3 <div id="main"></div> 3 <div id="main"></div>
4 <div id="isolated"></div> 4 <div id="isolated"></div>
5 <script> 5 <script>
6 testRunner.dumpAsText(); 6 testRunner.dumpAsText();
7 7
8 function addListener(worldType) { 8 function addListener(worldType) {
9 document.getElementById(worldType).addEventListener("MessageEvent", function (event) { 9 document.getElementById(worldType).addEventListener("ServiceWorkerMessageEve nt", function(event) {
10 console.log("MessageEvent received in " + worldType + " world"); 10 console.log("ServiceWorkerMessageEvent received in " + worldType + " wor ld");
11 console.log("detail was " + JSON.stringify(event.data)); 11 console.log("detail was " + JSON.stringify(event.data));
12 }); 12 });
13 } 13 }
14 14
15 function sendCloneableObject(targetWorldType) { 15 function sendCloneableObject(targetWorldType) {
16 var newEvent = document.createEvent("MessageEvent"); 16 var newEvent = document.createEvent("ServiceWorkerMessageEvent");
17 newEvent.initMessageEvent("MessageEvent", false, false, { foo: 5, bar: 'hell o', targetWorld: targetWorldType }); 17 newEvent.initServiceWorkerMessageEvent("ServiceWorkerMessageEvent", false, f alse, { foo: 5, bar: 'hello', targetWorld: targetWorldType });
18 document.getElementById(targetWorldType).dispatchEvent(newEvent); 18 document.getElementById(targetWorldType).dispatchEvent(newEvent);
19 } 19 }
20 20
21 var sendScript = "(" + sendCloneableObject.toString() + ")('main');"; 21 var sendScript = "(" + sendCloneableObject.toString() + ")('main');";
22 addListener("main"); 22 addListener("main");
23 testRunner.evaluateScriptInIsolatedWorld(1, sendScript); 23 testRunner.evaluateScriptInIsolatedWorld(1, sendScript);
24 var receiveScript = "(" + addListener.toString() + ")('isolated');"; 24 var receiveScript = "(" + addListener.toString() + ")('isolated');";
25 testRunner.evaluateScriptInIsolatedWorld(1, receiveScript); 25 testRunner.evaluateScriptInIsolatedWorld(1, receiveScript);
26 sendCloneableObject("isolated"); 26 sendCloneableObject("isolated");
27 </script> 27 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698