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

Unified Diff: LayoutTests/fast/events/custom-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: Large set of fixes from adamk and haraken. 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/custom-event-isolated-world.html
diff --git a/LayoutTests/fast/events/custom-event-isolated-world.html b/LayoutTests/fast/events/custom-event-isolated-world.html
new file mode 100644
index 0000000000000000000000000000000000000000..abc3004fc9293b82c2a3febedb8e0477fe3827a9
--- /dev/null
+++ b/LayoutTests/fast/events/custom-event-isolated-world.html
@@ -0,0 +1,56 @@
+<script>
+// Tests that the detail property of custom events does not leak between
+// isolated worlds (checks bug 85158)
+
+// This test is meaningless without testRunner.
+function log(m)
+{
+ var results = document.getElementById('results');
+ results.innerHTML += m + '<br>';
+}
+
+function shouldBe(aDescription, a, b)
haraken 2013/06/25 02:06:58 You can use fast/js/resources/js-test-pre.js.
jww 2013/06/26 02:27:06 Done.
+{
+ if (a === b) {
+ log("PASS: " + aDescription + " should be '" + b + "' and is.");
+ } else {
+ log("FAIL: " + aDescription + " should be '" + b + "' but instead is '" + a + "'.");
+ }
+}
+
+if (window.testRunner) {
+
+ testRunner.dumpAsText();
haraken 2013/06/25 02:06:58 Nit: This isn't needed. js-test-pre.js will call i
jww 2013/06/26 02:27:06 Done.
+ testRunner.waitUntilDone();
+
+ window.addEventListener("message", function(message)
+ {
+ testRunner.notifyDone();
+ }, false);
+
+ document.addEventListener("sendDocumentObject", function(event) {
+ var documentObject = event.detail;
+ var testResult;
+
+ shouldBe("Object passed into isolated world", String(documentObject), String(undefined));
+
+ shouldBe("The property defined in isolated world ", String(document.pageDefinedVar), String(undefined));
+
+ window.postMessage("done", "*");
+ });
+
+ function sendDocumentObject() {
+ var customEvent = document.createEvent("CustomEvent");
+ customEvent.initCustomEvent("sendDocumentObject", true, true, document);
+ document.dispatchEvent(customEvent);
+ }
+
+ function runTests() {
+ var script = "document.pageDefinedVar = 1;(" + sendDocumentObject.toString() + ")()";
+ testRunner.evaluateScriptInIsolatedWorld(1, script);
+ }
+}
+</script>
+<body onload="runTests()">
haraken 2013/06/25 02:06:58 Nit: You can simply write: <!DOCTYPE html> <html>
jww 2013/06/26 02:27:06 Done.
+ <div id="results"></div>
haraken 2013/06/25 02:06:58 Nit: This isn't needed.
jww 2013/06/26 02:27:06 Done.
+</body>

Powered by Google App Engine
This is Rietveld 408576698