blob: c7b9d25b91358125df1b9d54b323e2287c5217f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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>
|