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

Unified Diff: LayoutTests/fast/events/event-isolated-world-clone.html

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/event-isolated-world-clone.html
diff --git a/LayoutTests/fast/events/event-isolated-world-clone.html b/LayoutTests/fast/events/event-isolated-world-clone.html
new file mode 100644
index 0000000000000000000000000000000000000000..c7b955c10196545d17a4c3e693d0f16e97c308c6
--- /dev/null
+++ b/LayoutTests/fast/events/event-isolated-world-clone.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<p>Tests that properties of various events are cloned between isolated worlds.</p>
+<div id="main"></div>
+<div id="isolated"></div>
+<script>
+testRunner.dumpAsText();
+
+function addListener(eventType, prop, worldType) {
+ document.getElementById(worldType).addEventListener(eventType, function(event) {
+ console.log(eventType + " received in " + worldType + " world");
+ console.log(prop + " was " + JSON.stringify(event[prop]));
+ });
+}
+
+function sendCloneableObject(eventType, prop, targetWorldType) {
+ var newEvent = eval("new " + eventType + "('" + eventType + "', { " + prop + ": { foo: 5, bar: 'hello', targetWorld: targetWorldType } })");
+ document.getElementById(targetWorldType).dispatchEvent(newEvent);
+}
+
+function runScript(eventType, prop) {
+ var sendScript = "(" + sendCloneableObject.toString() + ")('" + eventType + "', '" + prop + "', 'main');";
+ addListener(eventType, prop, "main");
+ testRunner.evaluateScriptInIsolatedWorld(1, sendScript);
+ var receiveScript = "(" + addListener.toString() + ")('" + eventType + "', '" + prop + "', 'isolated');";
+ testRunner.evaluateScriptInIsolatedWorld(1, receiveScript);
+ sendCloneableObject(eventType, prop, "isolated");
+
+}
+
+// The events that we want to test, with the properties that each one uses.
+var events = [
+ { eventType: "CustomEvent", prop: "detail" },
+ { eventType: "MessageEvent", prop: "data" },
+ { eventType: "PopStateEvent", prop: "state" }
+];
+
+for (var i = 0; i < events.length; ++i) {
+ runScript(events[i].eventType, events[i].prop);
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698