1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/inputmethod/mochitest/test_sendkey_cancel.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=952080 1.8 +--> 1.9 +<head> 1.10 + <title>SendKey with canceled keydown test for InputMethod API.</title> 1.11 + <script type="application/javascript;version=1.7" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript;version=1.7" src="inputmethod_common.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=952080">Mozilla Bug 952080</a> 1.17 +<p id="display"></p> 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="application/javascript;version=1.7"> 1.20 + 1.21 +// The input context. 1.22 +var gContext = null; 1.23 + 1.24 +inputmethod_setup(function() { 1.25 + runTest(); 1.26 +}); 1.27 + 1.28 +function runTest() { 1.29 + let im = navigator.mozInputMethod; 1.30 + 1.31 + im.oninputcontextchange = function() { 1.32 + ok(true, 'inputcontextchange event was fired.'); 1.33 + im.oninputcontextchange = null; 1.34 + 1.35 + gContext = im.inputcontext; 1.36 + if (!gContext) { 1.37 + ok(false, 'Should have a non-null inputcontext.'); 1.38 + inputmethod_cleanup(); 1.39 + return; 1.40 + } 1.41 + 1.42 + test(); 1.43 + }; 1.44 + 1.45 + // Set current page as an input method. 1.46 + SpecialPowers.wrap(im).setActive(true); 1.47 + 1.48 + let iframe = document.createElement('iframe'); 1.49 + iframe.src = 'file_test_sendkey_cancel.html'; 1.50 + iframe.setAttribute('mozbrowser', true); 1.51 + document.body.appendChild(iframe); 1.52 +} 1.53 + 1.54 +function test() { 1.55 + gContext.sendKey(0, 'j', 0).then(function() { 1.56 + ok(false, 'sendKey was incorrectly resolved'); 1.57 + 1.58 + inputmethod_cleanup(); 1.59 + }, function(e) { 1.60 + ok(true, 'sendKey was rejected'); 1.61 + 1.62 + inputmethod_cleanup(); 1.63 + }); 1.64 +} 1.65 + 1.66 +</script> 1.67 +</pre> 1.68 +</body> 1.69 +</html> 1.70 +