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.

     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">
    17 </div>
    18 <pre id="test">
    19 <script type="application/javascript">
    21 /** Test for Bug 569988 **/
    23 SimpleTest.waitForExplicitFinish();
    24 SimpleTest.waitForFocus(runTest);
    26 var gPromptInput = null;
    28 function runTest()
    29 {
    30   var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"].
    31              getService(SpecialPowers.Ci.nsIObserverService);
    33   os.addObserver(onPromptLoad, "common-dialog-loaded", false);
    34   os.addObserver(onPromptLoad, "tabmodal-dialog-loaded", false);
    36   info("opening prompt...");
    37   prompt("summary", "text");
    38   info("prompt is closed");
    40   os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
    41   os.removeObserver(onPromptLoad, "common-dialog-loaded");
    42   SimpleTest.finish();
    43 }
    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 }
    55 function onPromptFocus() {
    56   ok(true, "onPromptFocus is called");
    57   gPromptInput.removeEventListener("focus", onPromptFocus, false);
    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 }
    74 </script>
    75 </pre>
    76 </body>
    77 </html>

mercurial