4 <script src=
"../../resources/js-test.js"></script>
8 window
.jsTestIsAsync
= true;
9 description("Tests that properties passed to events are not garbage collected prematurely.");
11 function addListener(eventType
, prop
) {
12 document
.addEventListener(eventType
, function(event
) {
14 // Despite the earlier assignement of the local variable to null and
15 // the following garabage collection, the property should still be
17 shouldBeEqualToString("event[prop]", "foo");
19 window
.prop
= undefined;
20 window
.postMessage("done", "*");
24 // Run the tests whenever a notification arrives, which indicates that the
25 // previous test has finished.
26 window
.addEventListener("message", function(message
) {
30 function newEvent(eventType
, prop
, value
) {
31 return eval("new " + eventType
+ "('" + eventType
+ "', { " + prop
+ ": value })");
34 // The events that we want to test, with the properties that each one uses.
36 { eventType
: "CustomEvent", prop
: "detail" },
37 { eventType
: "MessageEvent", prop
: "data" },
38 { eventType
: "PopStateEvent", prop
: "state" }
41 function runNextTest () {
42 var evt
= events
.pop();
49 var eventToDispatch
= newEvent(evt
.eventType
, evt
.prop
, value
);
53 addListener(evt
.eventType
, evt
.prop
);
54 document
.dispatchEvent(eventToDispatch
);
57 // This test is meaningless without testRunner.
58 if (window
.testRunner
) {