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

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

Issue 17063016: Remove leak of objects between isolated worlds on custom events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed some test failures, fixed some nits, and generalized the new events test. Created 7 years, 6 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.html
diff --git a/LayoutTests/fast/events/event-isolated-world.html b/LayoutTests/fast/events/event-isolated-world.html
new file mode 100644
index 0000000000000000000000000000000000000000..c443d588070789e9ba271ad8abf2804b4c4c417e
--- /dev/null
+++ b/LayoutTests/fast/events/event-isolated-world.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that properties of various events do not leak between isolated worlds (bug 85158).");
+
+// This test is meaningless without testRunner.
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+
+ function addListener(eventType, prop) {
+ document.addEventListener(eventType, function(event) {
+ documentObject = event[prop];
+
+ // Object passed into isolated world should be undefined.
+ shouldBe("documentObject", "undefined");
+
+ // The property defined in the isolated world should be undefined.
+ shouldBe("document.pageDefinedVar", "undefined");
+
+ window.postMessage("done", "*");
+ });
+ }
+
+ function sendDocumentObject(eventType, prop) {
+ var newEvent = eval("new " + eventType + "('" + eventType + "', { " + prop + ": document })");
+ document.dispatchEvent(newEvent);
+ }
+
+ function runScript(eventType, prop) {
+ // Final string should have the form:
+ // document.pageDefinedVar = 1; (function sendDocumentObject(eventType, prop) {...})(...);
+ // When evaluated in the isolated world, should initiate the event with
+ // the document object as the specificed property value.
+ var script = "document.pageDefinedVar = 1; " +
+ "(" + sendDocumentObject.toString() + ")('" + eventType + "', '" + prop + "');";
+ addListener(eventType, prop);
+ testRunner.evaluateScriptInIsolatedWorld(1, script);
+ }
+
+ function finish() {
+ var script = document.createElement("script");
+ script.src = "../js/resources/js-test-post-async.js";
+ document.body.appendChild(script);
haraken 2013/06/26 04:02:31 I don't think this is needed. I guess that you can
jww 2013/06/26 17:19:08 Done.
+ }
+
+ // Run the tests whenever a notification arrives, which indicates that the
+ // previous test has finished.
+ window.addEventListener("message", function(message) {
+ runNextTest();
+ }, false);
+
+ // The events that we want to test for property leaks, with the properties
+ // that each one uses.
+ var events = [
+ { eventType: "CustomEvent", prop: "detail" },
+ { eventType: "MessageEvent", prop: "data" },
+ { eventType: "PopStateEvent", prop: "state" }
+ ];
+
+ function runNextTest () {
+ var evt = events.pop();
+ if (!evt) {
+ finish();
+ return;
+ }
+
+ runScript(evt.eventType, evt.prop);
+ };
+
+ runNextTest();
+}
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698