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

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: Reverted to version that expects GetHiddenValue to not return an empty Handle for undefined 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 window.jsTestIsAsync = true;
9 description("Tests that properties of various events do not leak between isolate d worlds (bug 85158).");
10
11 function addListener(eventType, prop) {
12 document.addEventListener(eventType, function(event) {
13 documentObject = event[prop];
14
15 // Object passed into isolated world should be undefined.
16 shouldBe("documentObject", "undefined");
haraken 2013/06/27 04:50:27 shouldBeUndefined
jww 2013/06/27 17:44:42 Done.
17
18 // The property defined in the isolated world should be undefined.
19 shouldBe("document.pageDefinedVar", "undefined");
haraken 2013/06/27 04:50:27 Ditto.
jww 2013/06/27 17:44:42 Done.
20
21 window.postMessage("done", "*");
22 });
23 }
24
25 function sendDocumentObject(eventType, prop) {
26 var newEvent = eval("new " + eventType + "('" + eventType + "', { " + prop + ": document })");
27 document.dispatchEvent(newEvent);
28 }
29
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);
39 }
40
41 // Run the tests whenever a notification arrives, which indicates that the
42 // previous test has finished.
43 window.addEventListener("message", function(message) {
44 runNextTest();
45 }, false);
46
47 // The events that we want to test, with the properties that each one uses.
48 var events = [
49 { eventType: "CustomEvent", prop: "detail" },
50 { eventType: "MessageEvent", prop: "data" },
51 { eventType: "PopStateEvent", prop: "state" }
52 ];
53
54 function runNextTest () {
55 var evt = events.pop();
56 if (!evt) {
57 finishJSTest();
58 return;
59 }
60
61 runScript(evt.eventType, evt.prop);
62 };
63
64 // This test is meaningless without testRunner.
65 if (window.testRunner) {
66 runNextTest();
67 }
68 </script>
69 </body>
70 <script src="../js/resources/js-test-post.js"></script>
71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698