Chromium Code Reviews| 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> |