Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_bug569988.html
blob2ff84d9d057a7c00820ba85e8e2131edcb919dd6
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 var script = SpecialPowers.loadChromeScript(function() {
29 /* eslint-env mozilla/chrome-script */
30 var gPromptInput = null;
31 var os = Services.obs;
33 os.addObserver(onPromptLoad, "common-dialog-loaded");
35 function onPromptLoad(subject) {
36 let ui = subject.Dialog.ui;
37 sendAsyncMessage("ok", [true, "onPromptLoad is called"]);
38 gPromptInput = ui.loginTextbox;
39 gPromptInput.addEventListener("focus", onPromptFocus);
40 // shift focus to ensure it fires.
41 ui.button0.focus();
42 gPromptInput.focus();
45 function onPromptFocus() {
46 sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
47 gPromptInput.removeEventListener("focus", onPromptFocus);
49 var listener = {
50 handleEvent: function _hv(aEvent) {
51 var isPrevented = aEvent.defaultPrevented;
52 sendAsyncMessage("ok", [!isPrevented,
53 "ESC key event is prevented by editor"]);
54 gPromptInput.removeEventListener("keypress", listener, { mozSystemGroup: true });
57 gPromptInput.addEventListener("keypress", listener, { mozSystemGroup: true });
59 sendAsyncMessage("info", "sending key");
60 var EventUtils = {};
61 EventUtils.window = {};
62 EventUtils._EU_Ci = Ci;
63 EventUtils._EU_Cc = Cc;
64 Services.scriptloader
65 .loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
66 EventUtils);
67 EventUtils.synthesizeKey("VK_ESCAPE", {},
68 gPromptInput.ownerGlobal);
71 addMessageListener("destroy", function() {
72 os.removeObserver(onPromptLoad, "common-dialog-loaded");
73 });
74 });
75 script.addMessageListener("ok", ([val, msg]) => ok(val, msg));
76 script.addMessageListener("info", msg => info(msg));
78 info("opening prompt...");
79 prompt("summary", "text");
80 info("prompt is closed");
82 script.sendAsyncMessage("destroy");
84 SimpleTest.finish();
87 </script>
88 </pre>
89 </body>
90 </html>