Bug 1175399 - Move readonly detection into isFocusableElement. r=janjongboom

This commit is contained in:
Tim Chien 2015-07-03 01:42:00 +02:00
parent 91ddc465c0
commit 199cca088f
3 changed files with 67 additions and 10 deletions

View File

@ -671,7 +671,8 @@ let FormAssistant = {
target = target.parentNode;
this.setFocusedElement(target);
this.isHandlingFocus = this.sendInputState(target);
this.sendInputState(target);
this.isHandlingFocus = true;
},
unhandleFocus: function fa_unhandleFocus() {
@ -690,7 +691,8 @@ let FormAssistant = {
return true;
return (element instanceof HTMLInputElement &&
!this.ignoredInputTypes.has(element.type));
!this.ignoredInputTypes.has(element.type) &&
!element.readOnly);
},
getTopLevelEditable: function fa_getTopLevelEditable(element) {
@ -705,15 +707,7 @@ let FormAssistant = {
},
sendInputState: function(element) {
// FIXME/bug 729623: work around apparent bug in the IME manager
// in gecko.
let readonly = element.getAttribute("readonly");
if (readonly) {
return false;
}
sendAsyncMessage("Forms:Input", getJSON(element, this._focusCounter));
return true;
},
getSelectionInfo: function fa_getSelectionInfo() {

View File

@ -20,6 +20,7 @@ support-files =
[test_bug1043828.html]
[test_bug1059163.html]
[test_bug1066515.html]
[test_bug1175399.html]
[test_sendkey_cancel.html]
[test_sync_edit.html]
[test_two_inputs.html]

View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1175399
-->
<head>
<title>Test focus when page unloads</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=1175399">Mozilla Bug 1175399</a>
<p id="display"></p>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.7">
inputmethod_setup(function() {
runTest();
});
let appFrameScript = function appFrameScript() {
let input = content.document.body.firstElementChild;
input.focus();
content.setTimeout(function() {
sendAsyncMessage('test:step');
});
};
function runTest() {
let im = navigator.mozInputMethod;
// 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" readonly></body></html>';
iframe.setAttribute('mozbrowser', true);
document.body.appendChild(iframe);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
im.oninputcontextchange = function() {
is(false, 'should not receive inputcontextchange event');
};
iframe.addEventListener('mozbrowserloadend', function() {
mm.addMessageListener('test:step', function() {
let inputcontext = navigator.mozInputMethod.inputcontext;
is(inputcontext, null, 'inputcontext is null');
inputmethod_cleanup();
});
mm.loadFrameScript('data:,(' + encodeURIComponent(appFrameScript.toString()) + ')();', false);
});
}
</script>
</pre>
</body>
</html>