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

Side by Side 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 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 description("Tests that properties of various events do not leak between isolate d worlds (bug 85158).");
9
10 // This test is meaningless without testRunner.
11 if (window.testRunner) {
12 testRunner.waitUntilDone();
13
14 function addListener(eventType, prop) {
15 document.addEventListener(eventType, function(event) {
16 documentObject = event[prop];
17
18 // Object passed into isolated world should be undefined.
19 shouldBe("documentObject", "undefined");
20
21 // The property defined in the isolated world should be undefined.
22 shouldBe("document.pageDefinedVar", "undefined");
23
24 window.postMessage("done", "*");
25 });
26 }
27
28 function sendDocumentObject(eventType, prop) {
29 var newEvent = eval("new " + eventType + "('" + eventType + "', { " + pr op + ": document })");
30 document.dispatchEvent(newEvent);
31 }
32
33 function runScript(eventType, prop) {
34 // Final string should have the form:
35 // document.pageDefinedVar = 1; (function sendDocumentObject(eventTy pe, prop) {...})(...);
36 // When evaluated in the isolated world, should initiate the event with
37 // the document object as the specificed property value.
38 var script = "document.pageDefinedVar = 1; " +
39 "(" + sendDocumentObject.toString() + ")('" + eventType + " ', '" + prop + "');";
40 addListener(eventType, prop);
41 testRunner.evaluateScriptInIsolatedWorld(1, script);
42 }
43
44 function finish() {
45 var script = document.createElement("script");
46 script.src = "../js/resources/js-test-post-async.js";
47 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.
48 }
49
50 // Run the tests whenever a notification arrives, which indicates that the
51 // previous test has finished.
52 window.addEventListener("message", function(message) {
53 runNextTest();
54 }, false);
55
56 // The events that we want to test for property leaks, with the properties
57 // that each one uses.
58 var events = [
59 { eventType: "CustomEvent", prop: "detail" },
60 { eventType: "MessageEvent", prop: "data" },
61 { eventType: "PopStateEvent", prop: "state" }
62 ];
63
64 function runNextTest () {
65 var evt = events.pop();
66 if (!evt) {
67 finish();
68 return;
69 }
70
71 runScript(evt.eventType, evt.prop);
72 };
73
74 runNextTest();
75 }
76 </script>
77 </body>
78 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698