4 https://bugzilla.mozilla.org/show_bug.cgi?id=569988
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">
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug
569988</a>
15 <div id=
"content" style=
"display: none">
19 <script type=
"application/javascript">
21 /** Test for Bug
569988 **/
23 SimpleTest.waitForExplicitFinish();
24 SimpleTest.waitForFocus(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;
40 // subject is an tab prompt, find the elements ourselves
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.
54 function onPromptFocus() {
55 sendAsyncMessage(
"ok", [true,
"onPromptFocus is called"]);
56 gPromptInput.removeEventListener(
"focus", onPromptFocus);
58 var listenerService = Services.els;
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",
69 listenerService.addSystemEventListener(gPromptInput,
"keypress",
72 sendAsyncMessage(
"info",
"sending key");
74 EventUtils.window = {};
75 EventUtils._EU_Ci = Ci;
76 EventUtils._EU_Cc = Cc;
78 .loadSubScript(
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
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");
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");