Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / tests / test_bug569988.html
blob219c97ba3b8815574ff7bbd6cb0bc440df92ffab
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=569988
5 -->
6 <head>
7 <title>Test for Bug 569988</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 569988 **/
23 SimpleTest.waitForExplicitFinish();
24 SimpleTest.waitForFocus(runTest);
27 function runTest() {
28 /* eslint-env mozilla/frame-script */
29 var script = SpecialPowers.loadChromeScript(function() {
30 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
31 var gPromptInput = null;
32 var os = Services.obs;
34 os.addObserver(onPromptLoad, "common-dialog-loaded");
35 os.addObserver(onPromptLoad, "tabmodal-dialog-loaded");
37 function onPromptLoad(subject, topic, data) {
38 let ui = subject.Dialog ? subject.Dialog.ui : undefined;
39 if (!ui) {
40 // subject is an tab prompt, find the elements ourselves
41 ui = {
42 loginTextbox: subject.querySelector(".tabmodalprompt-loginTextbox"),
43 button0: subject.querySelector(".tabmodalprompt-button0"),
46 sendAsyncMessage("ok", [true, "onPromptLoad is called"]);
47 gPromptInput = ui.loginTextbox;
48 gPromptInput.addEventListener("focus", onPromptFocus);
49 // shift focus to ensure it fires.
50 ui.button0.focus();
51 gPromptInput.focus();
54 function onPromptFocus() {
55 sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
56 gPromptInput.removeEventListener("focus", onPromptFocus);
58 var listenerService = Services.els;
60 var listener = {
61 handleEvent: function _hv(aEvent) {
62 var isPrevented = aEvent.defaultPrevented;
63 sendAsyncMessage("ok", [!isPrevented,
64 "ESC key event is prevented by editor"]);
65 listenerService.removeSystemEventListener(gPromptInput, "keypress",
66 listener, false);
69 listenerService.addSystemEventListener(gPromptInput, "keypress",
70 listener, false);
72 sendAsyncMessage("info", "sending key");
73 var EventUtils = {};
74 EventUtils.window = {};
75 EventUtils._EU_Ci = Ci;
76 EventUtils._EU_Cc = Cc;
77 Services.scriptloader
78 .loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
79 EventUtils);
80 EventUtils.synthesizeKey("VK_ESCAPE", {},
81 gPromptInput.ownerGlobal);
84 addMessageListener("destroy", function() {
85 os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
86 os.removeObserver(onPromptLoad, "common-dialog-loaded");
87 });
88 });
89 script.addMessageListener("ok", ([val, msg]) => ok(val, msg));
90 script.addMessageListener("info", msg => info(msg));
92 info("opening prompt...");
93 prompt("summary", "text");
94 info("prompt is closed");
96 script.sendAsyncMessage("destroy");
98 SimpleTest.finish();
101 </script>
102 </pre>
103 </body>
104 </html>