forked from unicorn-wg/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1057898 - Add a test for tapping between two inputs. r=yxl
- Loading branch information
Showing
3 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<!-- | ||
https://bugzilla.mozilla.org/show_bug.cgi?id=1057898 | ||
--> | ||
<head> | ||
<title>Test switching between two inputs</title> | ||
<script type="application/javascript;version=1.7" src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<script type="application/javascript;version=1.7" src="inputmethod_common.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> | ||
</head> | ||
<body> | ||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=932145">Mozilla Bug 932145</a> | ||
<p id="display"></p> | ||
<pre id="test"> | ||
<script class="testbody" type="application/javascript;version=1.7"> | ||
|
||
// The input context. | ||
var gContext = null; | ||
|
||
inputmethod_setup(function() { | ||
runTest(); | ||
}); | ||
|
||
let appFrameScript = function appFrameScript() { | ||
let input1 = content.document.body.firstElementChild; | ||
let input2 = content.document.body.children[1]; | ||
|
||
let i = 0; | ||
|
||
input1.focus(); | ||
|
||
addMessageListener('test:next', function() { | ||
i++; | ||
switch (i) { | ||
case 1: | ||
input2.focus(); | ||
|
||
break; | ||
|
||
case 2: | ||
input2.blur(); | ||
|
||
break; | ||
} | ||
}); | ||
}; | ||
|
||
function runTest() { | ||
let im = navigator.mozInputMethod; | ||
|
||
let i = 0; | ||
im.oninputcontextchange = function(evt) { | ||
var inputcontext = navigator.mozInputMethod.inputcontext; | ||
|
||
i++; | ||
switch (i) { | ||
case 1: | ||
ok(!!inputcontext, 'Receving the first input context'); | ||
is(inputcontext.textAfterCursor, 'First'); | ||
|
||
mm.sendAsyncMessage('test:next'); | ||
break; | ||
|
||
case 2: | ||
ok(!!inputcontext, 'Receving the second input context'); | ||
is(inputcontext.textAfterCursor, 'Second'); | ||
|
||
|
||
mm.sendAsyncMessage('test:next'); | ||
break; | ||
|
||
case 3: | ||
is(inputcontext, null, 'Receving null inputcontext'); | ||
|
||
inputmethod_cleanup(); | ||
break; | ||
|
||
default: | ||
ok(false, 'Receving extra inputcontextchange calls'); | ||
inputmethod_cleanup(); | ||
|
||
break; | ||
} | ||
}; | ||
|
||
// Set current page as an input method. | ||
SpecialPowers.wrap(im).setActive(true); | ||
|
||
let iframe = document.createElement('iframe'); | ||
iframe.src = 'data:text/html,<html><body><input value="First"><input value="Second"></body></html>'; | ||
iframe.setAttribute('mozbrowser', true); | ||
document.body.appendChild(iframe); | ||
|
||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); | ||
|
||
iframe.addEventListener('mozbrowserloadend', function() { | ||
mm.loadFrameScript('data:,(' + encodeURIComponent(appFrameScript.toString()) + ')();', false); | ||
}); | ||
} | ||
|
||
</script> | ||
</pre> | ||
</body> | ||
</html> | ||
|