editor/libeditor/text/tests/test_bug569988.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial