dom/inputmethod/mochitest/test_sendkey_cancel.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=952080
     5 -->
     6 <head>
     7   <title>SendKey with canceled keydown test for InputMethod API.</title>
     8   <script type="application/javascript;version=1.7" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="application/javascript;version=1.7" src="inputmethod_common.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=952080">Mozilla Bug 952080</a>
    14 <p id="display"></p>
    15 <pre id="test">
    16 <script class="testbody" type="application/javascript;version=1.7">
    18 // The input context.
    19 var gContext = null;
    21 inputmethod_setup(function() {
    22   runTest();
    23 });
    25 function runTest() {
    26   let im = navigator.mozInputMethod;
    28   im.oninputcontextchange = function() {
    29     ok(true, 'inputcontextchange event was fired.');
    30     im.oninputcontextchange = null;
    32     gContext = im.inputcontext;
    33     if (!gContext) {
    34       ok(false, 'Should have a non-null inputcontext.');
    35       inputmethod_cleanup();
    36       return;
    37     }
    39     test();
    40   };
    42   // Set current page as an input method.
    43   SpecialPowers.wrap(im).setActive(true);
    45   let iframe = document.createElement('iframe');
    46   iframe.src = 'file_test_sendkey_cancel.html';
    47   iframe.setAttribute('mozbrowser', true);
    48   document.body.appendChild(iframe);
    49 }
    51 function test() {
    52   gContext.sendKey(0, 'j', 0).then(function() {
    53     ok(false, 'sendKey was incorrectly resolved');
    55     inputmethod_cleanup();
    56   }, function(e) {
    57     ok(true, 'sendKey was rejected');
    59     inputmethod_cleanup();
    60   });
    61 }
    63 </script>
    64 </pre>
    65 </body>
    66 </html>

mercurial