diff options
Diffstat (limited to 'dom/html/test/dialog/test_dialog_cancel_events.html')
-rw-r--r-- | dom/html/test/dialog/test_dialog_cancel_events.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/html/test/dialog/test_dialog_cancel_events.html b/dom/html/test/dialog/test_dialog_cancel_events.html new file mode 100644 index 0000000000..c7b9d25b91 --- /dev/null +++ b/dom/html/test/dialog/test_dialog_cancel_events.html @@ -0,0 +1,57 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1322947 +--> +<head> + <title>Test for Bug 1322947</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body onload="runTest()"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">Test cancel event + is fired when the dialog is closed by user interaction</a> +<p id="display"></p> +<dialog> + <p>Hello World</p> +</dialog> +<pre id="test"> +<script type="application/javascript"> +SimpleTest.waitForExplicitFinish(); + +var hasCancelEventFired = false; +var hasCloseEventFired = false; + +function runTest() { + const dialog = document.querySelector("dialog"); + + dialog.addEventListener("cancel", function(event) { + ok(true, "cancel event is fired"); + ok(event.cancelable, "cancel event should be cancelable"); + ok(!hasCancelEventFired, "cancel event should only be fired once"); + ok(!hasCloseEventFired, "close event should be fired after cancel event"); + hasCancelEventFired = true; + }); + + dialog.addEventListener("close", function() { + ok(true, "close event is fired"); + ok(!hasCloseEventFired, "close event should only be fired once"); + ok(hasCancelEventFired, "cancel event should be fired before close event"); + hasCloseEventFired = true; + done(); + }); + + dialog.showModal(); + synthesizeKey("VK_ESCAPE", {}, window); +} + +function done() { + SimpleTest.finish(); +} +</script> +</pre> +</body> +</html> + |