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

Unified Diff: LayoutTests/fast/events/event-properties-gc.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: Minor rebase nits. 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-properties-gc.html
diff --git a/LayoutTests/fast/events/event-properties-gc.html b/LayoutTests/fast/events/event-properties-gc.html
new file mode 100644
index 0000000000000000000000000000000000000000..fe196ac8808676b9b52da6d3aa9c6bd6acde141c
--- /dev/null
+++ b/LayoutTests/fast/events/event-properties-gc.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+description("Tests that properties passed to events are not garbage collected prematurely.");
+
+function addListener(eventType, prop) {
+ document.addEventListener(eventType, function(event) {
+ window.prop = prop;
+ // Despite the earlier assignement of the local variable to null and
+ // the following garabage collection, the property should still be
+ // present here.
+ shouldBeEqualToString("event[prop]", "foo");
+
+ window.prop = undefined;
+ window.postMessage("done", "*");
+ });
+}
+
+// Run the tests whenever a notification arrives, which indicates that the
+// previous test has finished.
+window.addEventListener("message", function(message) {
+ runNextTest();
+}, false);
+
+function newEvent(eventType, prop, value) {
+ return eval("new " + eventType + "('" + eventType + "', { " + prop + ": value })");
+}
+
+// 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" }
+];
+
+function runNextTest () {
+ var evt = events.pop();
+ if (!evt) {
+ finishJSTest();
+ return;
+ }
+
+ var value = "foo";
+ var eventToDispatch = newEvent(evt.eventType, evt.prop, value);
+ value = null;
+ gc();
+
+ addListener(evt.eventType, evt.prop);
+ document.dispatchEvent(eventToDispatch);
+};
+
+// This test is meaningless without testRunner.
+if (window.testRunner) {
+ runNextTest();
+}
+</script>
+</body>
+<script src="../js/resources/js-test-post.js"></script>
+</html>
« no previous file with comments | « LayoutTests/fast/events/event-isolated-world-expected.txt ('k') | LayoutTests/fast/events/event-properties-gc-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698