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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 window.jsTestIsAsync = true;
9 description("Tests that properties passed to events are not garbage collected pr ematurely.");
10
11 function addListener(eventType, prop) {
12 document.addEventListener(eventType, function(event) {
13 window.prop = prop;
14 // Despite the earlier assignement of the local variable to null and
15 // the following garabage collection, the property should still be
16 // present here.
17 shouldBeEqualToString("event[prop]", "foo");
18
19 window.prop = undefined;
20 window.postMessage("done", "*");
21 });
22 }
23
24 // Run the tests whenever a notification arrives, which indicates that the
25 // previous test has finished.
26 window.addEventListener("message", function(message) {
27 runNextTest();
28 }, false);
29
30 function newEvent(eventType, prop, value) {
31 return eval("new " + eventType + "('" + eventType + "', { " + prop + ": valu e })");
32 }
33
34 // The events that we want to test, with the properties that each one uses.
35 var events = [
36 { eventType: "CustomEvent", prop: "detail" },
37 { eventType: "MessageEvent", prop: "data" },
38 { eventType: "PopStateEvent", prop: "state" }
39 ];
40
41 function runNextTest () {
42 var evt = events.pop();
43 if (!evt) {
44 finishJSTest();
45 return;
46 }
47
48 var value = "foo";
49 var eventToDispatch = newEvent(evt.eventType, evt.prop, value);
50 value = null;
51 gc();
52
53 addListener(evt.eventType, evt.prop);
54 document.dispatchEvent(eventToDispatch);
55 };
56
57 // This test is meaningless without testRunner.
58 if (window.testRunner) {
59 runNextTest();
60 }
61 </script>
62 </body>
63 <script src="../js/resources/js-test-post.js"></script>
64 </html>
OLDNEW
« 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