dom/inputmethod/mochitest/test_sendkey_cancel.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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

mercurial