4 <script src=
"../../resources/js-test.js"></script>
8 window
.jsTestIsAsync
= true;
9 description("Tests that properties of various events do not leak between isolated worlds (bug 85158).");
11 function addListener(eventType
, prop
) {
12 document
.addEventListener(eventType
, function(event
) {
13 documentObject
= event
[prop
];
15 // Object passed into isolated world should be undefined.
16 shouldBeNull("documentObject");
18 // The property defined in the isolated world should be undefined.
19 shouldBeUndefined("document.pageDefinedVar");
21 window
.postMessage("done", "*");
25 function sendDocumentObject(eventType
, prop
) {
26 var newEvent
= eval("new " + eventType
+ "('" + eventType
+ "', { " + prop
+ ": document })");
27 document
.dispatchEvent(newEvent
);
30 function runScript(eventType
, prop
) {
31 // Final string should have the form:
32 // document.pageDefinedVar = 1; (function sendDocumentObject(eventType, prop) {...})(...);
33 // When evaluated in the isolated world, should initiate the event with the
34 // document object as the specificed property value.
35 var script
= "document.pageDefinedVar = 1; " +
36 "(" + sendDocumentObject
.toString() + ")('" + eventType
+ "', '" + prop
+ "');";
37 addListener(eventType
, prop
);
38 testRunner
.evaluateScriptInIsolatedWorld(1, script
);
41 // Run the tests whenever a notification arrives, which indicates that the
42 // previous test has finished.
43 window
.addEventListener("message", function(message
) {
47 // The events that we want to test, with the properties that each one uses.
49 { eventType
: "CustomEvent", prop
: "detail" },
50 { eventType
: "MessageEvent", prop
: "data" },
51 { eventType
: "PopStateEvent", prop
: "state" }
54 function runNextTest () {
55 var evt
= events
.pop();
61 runScript(evt
.eventType
, evt
.prop
);
64 // This test is meaningless without testRunner.
65 if (window
.testRunner
) {