mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952741 - Mochitest for Keyboard/IME API to test focused element deletion. r=fabrice
This commit is contained in:
parent
6bb9ea150f
commit
ab4f07d599
@ -9,3 +9,4 @@ support-files =
|
||||
[test_bug944397.html]
|
||||
[test_bug949059.html]
|
||||
[test_sendkey_cancel.html]
|
||||
[test_delete_focused_element.html]
|
||||
|
107
dom/inputmethod/mochitest/test_delete_focused_element.html
Normal file
107
dom/inputmethod/mochitest/test_delete_focused_element.html
Normal file
@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=952741
|
||||
-->
|
||||
<head>
|
||||
<title>Test focused element deletion for InputMethod API.</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=952741">Mozilla Bug 952741</a>
|
||||
<input type="text" />
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="application/javascript;version=1.7">
|
||||
|
||||
inputmethod_setup(function() {
|
||||
runTest();
|
||||
});
|
||||
|
||||
// The frame script running in file_test_app.html.
|
||||
function appFrameScript() {
|
||||
let input = content.document.getElementById('test-input');
|
||||
let textarea = content.document.createElement('textarea');
|
||||
textarea.lang = 'en';
|
||||
|
||||
content.document.body.appendChild(textarea);
|
||||
|
||||
textarea.onfocus = function() {
|
||||
textarea.parentNode.removeChild(textarea);
|
||||
sendAsyncMessage('test:InputMethod:finished', {});
|
||||
};
|
||||
|
||||
content.setTimeout(function() {
|
||||
textarea.focus();
|
||||
input.parentNode.removeChild(input);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var timeoutId = null;
|
||||
|
||||
// Create an app frame to recieve keyboard inputs.
|
||||
let app = document.createElement('iframe');
|
||||
app.src = 'file_test_app.html';
|
||||
app.setAttribute('mozbrowser', true);
|
||||
document.body.appendChild(app);
|
||||
app.addEventListener('mozbrowserloadend', function() {
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(app);
|
||||
mm.loadFrameScript('data:,(' + appFrameScript.toString() + ')();', false);
|
||||
mm.addMessageListener("test:InputMethod:finished", function() {
|
||||
timeoutId = setTimeout(function() {
|
||||
ok(false, 'No inputcontextchange event when textarea is deleted.');
|
||||
inputmethod_cleanup();
|
||||
}, 20000);
|
||||
});
|
||||
});
|
||||
|
||||
let im = navigator.mozInputMethod;
|
||||
let count = 0;
|
||||
im.oninputcontextchange = function() {
|
||||
switch (count++) {
|
||||
case 0:
|
||||
if (!im.inputcontext) {
|
||||
break;
|
||||
}
|
||||
is(im.inputcontext.lang, 'zh', 'input was focused.');
|
||||
return;
|
||||
case 1:
|
||||
if (im.inputcontext) {
|
||||
break;
|
||||
}
|
||||
ok(true, 'input was blurred.');
|
||||
return;
|
||||
case 2:
|
||||
if (!im.inputcontext) {
|
||||
break;
|
||||
}
|
||||
is(im.inputcontext.lang, 'en', 'textarea was focused.');
|
||||
return;
|
||||
case 3:
|
||||
if (im.inputcontext) {
|
||||
break;
|
||||
}
|
||||
ok(true, 'textarea was removed.');
|
||||
clearTimeout(timeoutId);
|
||||
inputmethod_cleanup();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
count = 100;
|
||||
ok(false, 'Should not arrive here.');
|
||||
inputmethod_cleanup();
|
||||
};
|
||||
|
||||
// Set current page as an input method.
|
||||
SpecialPowers.wrap(im).setActive(true);
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user