|
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 type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/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"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 /** Test for Bug 569988 **/ |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 SimpleTest.waitForFocus(runTest); |
|
25 |
|
26 var gPromptInput = null; |
|
27 |
|
28 function runTest() |
|
29 { |
|
30 var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"]. |
|
31 getService(SpecialPowers.Ci.nsIObserverService); |
|
32 |
|
33 os.addObserver(onPromptLoad, "common-dialog-loaded", false); |
|
34 os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false); |
|
35 |
|
36 info("opening prompt..."); |
|
37 prompt("summary", "text"); |
|
38 info("prompt is closed"); |
|
39 |
|
40 os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded"); |
|
41 os.removeObserver(onPromptLoad, "common-dialog-loaded"); |
|
42 SimpleTest.finish(); |
|
43 } |
|
44 |
|
45 function onPromptLoad(subject, topic, data) |
|
46 { |
|
47 ok(true, "onPromptLoad is called"); |
|
48 gPromptInput = subject.Dialog.ui.loginTextbox; |
|
49 gPromptInput.addEventListener("focus", onPromptFocus, false); |
|
50 // shift focus to ensure it fires. |
|
51 subject.Dialog.ui.button0.focus(); |
|
52 gPromptInput.focus(); |
|
53 } |
|
54 |
|
55 function onPromptFocus() { |
|
56 ok(true, "onPromptFocus is called"); |
|
57 gPromptInput.removeEventListener("focus", onPromptFocus, false); |
|
58 |
|
59 var listener = { |
|
60 handleEvent: function _hv(aEvent) |
|
61 { |
|
62 var isPrevented = aEvent.defaultPrevented; |
|
63 ok(!isPrevented, "ESC key event is prevented by editor"); |
|
64 SpecialPowers.removeSystemEventListener(gPromptInput, "keypress", |
|
65 listener, false); |
|
66 } |
|
67 }; |
|
68 SpecialPowers.addSystemEventListener(gPromptInput, "keypress", listener, |
|
69 false); |
|
70 info("sending key"); |
|
71 synthesizeKey("VK_ESCAPE", { }, gPromptInput.ownerDocument.defaultView); |
|
72 } |
|
73 |
|
74 </script> |
|
75 </pre> |
|
76 </body> |
|
77 </html> |