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 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.
45 function onPromptFocus() {
46 sendAsyncMessage(
"ok", [true,
"onPromptFocus is called"]);
47 gPromptInput.removeEventListener(
"focus", onPromptFocus);
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");
61 EventUtils.window = {};
62 EventUtils._EU_Ci = Ci;
63 EventUtils._EU_Cc = Cc;
65 .loadSubScript(
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
67 EventUtils.synthesizeKey(
"VK_ESCAPE", {},
68 gPromptInput.ownerGlobal);
71 addMessageListener(
"destroy", function() {
72 os.removeObserver(onPromptLoad,
"common-dialog-loaded");
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");