Backed out changeset 65e66c0b9eee (bug 1772841) for causing failures at test_input_datetime_disabled_focus.html. CLOSED TREE

This commit is contained in:
Butkovits Atila 2022-06-16 01:40:32 +03:00
parent b16c4d741f
commit f6d593afa9
4 changed files with 8 additions and 49 deletions

View File

@ -37,7 +37,6 @@ support-files = file_double_submit.html
[test_input_date_bad_input.html] [test_input_date_bad_input.html]
[test_input_date_key_events.html] [test_input_date_key_events.html]
[test_input_datetime_input_change_events.html] [test_input_datetime_input_change_events.html]
[test_input_datetime_disabled_focus.html]
[test_input_datetime_focus_blur.html] [test_input_datetime_focus_blur.html]
[test_input_datetime_focus_blur_events.html] [test_input_datetime_focus_blur_events.html]
[test_input_datetime_focus_state.html] [test_input_datetime_focus_state.html]

View File

@ -1,42 +0,0 @@
<!DOCTYPE html>
<title>Test for bug 1772841</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1772841">Mozilla Bug 1772841</a>
<div id="content">
<input type="date" id="date" disabled>
<input type="time" id="time" disabled>
<input type="datetime-local" id="datetime-local" disabled>
<input type="date" id="date1">
<input type="time" id="time1">
<input type="datetime-local" id="datetime-local1">
</div>
<script>
/*
* Test for bug 1772841
* This test checks that when a datetime input element is disabled,
* it should not be focusable by click.
**/
add_task(async function() {
await SimpleTest.promiseFocus(window);
for (let inputType of ["time", "date", "datetime-local"]) {
testFocusState(inputType);
testDynamicChange(inputType);
}
})
function testFocusState(inputType) {
let input = document.getElementById(inputType);
input.click();
isnot(document.activeElement, input, "disabled element should not be focusable by click");
EventUtils.synthesizeMouseAtCenter(input, {});
isnot(document.activeElement, input, "disabled element should not be focusable by click");
}
function testDynamicChange(inputType) {
document.getElementById(inputType + "1").disabled = true;
testFocusState(inputType + "1");
}
</script>

View File

@ -79,6 +79,7 @@ function testTabindex(type) {
checkInnerTextboxTabindex(input1, 0); checkInnerTextboxTabindex(input1, 0);
checkInnerTextboxTabindex(input2, -1); checkInnerTextboxTabindex(input2, -1);
checkInnerTextboxTabindex(input3, 0); checkInnerTextboxTabindex(input3, 0);
checkInnerTextboxTabindex(input4, -1);
// Changing the tabindex attribute dynamically. // Changing the tabindex attribute dynamically.
input3.setAttribute("tabindex", "-1"); input3.setAttribute("tabindex", "-1");
@ -91,6 +92,7 @@ function testTabindex(type) {
"disabled element should not be tabbable"); "disabled element should not be tabbable");
checkInnerTextboxTabindex(input3, -1); checkInnerTextboxTabindex(input3, -1);
checkInnerTextboxTabindex(input4, -1);
} }
function test() { function test() {

View File

@ -346,7 +346,7 @@ this.DateTimeBoxWidget = class {
field.textContent = aPlaceHolder; field.textContent = aPlaceHolder;
field.placeholder = aPlaceHolder; field.placeholder = aPlaceHolder;
field.setAttribute("aria-valuetext", ""); field.setAttribute("aria-valuetext", "");
this.setFieldTabIndexAttribute(field); field.tabIndex = this.editFieldTabIndex();
field.setAttribute("readonly", this.mInputElement.readOnly); field.setAttribute("readonly", this.mInputElement.readOnly);
field.setAttribute("disabled", this.mInputElement.disabled); field.setAttribute("disabled", this.mInputElement.disabled);
@ -447,12 +447,11 @@ this.DateTimeBoxWidget = class {
this.mIsPickerOpen = aIsOpen; this.mIsPickerOpen = aIsOpen;
} }
setFieldTabIndexAttribute(field) { editFieldTabIndex() {
if (this.mInputElement.disabled) { if (this.mInputElement.disabled) {
field.removeAttribute("tabindex"); return -1;
} else {
field.tabIndex = this.mInputElement.tabIndex;
} }
return this.mInputElement.tabIndex;
} }
updateEditAttributes() { updateEditAttributes() {
@ -473,7 +472,8 @@ this.DateTimeBoxWidget = class {
child.disabled = this.mInputElement.disabled; child.disabled = this.mInputElement.disabled;
child.readOnly = this.mInputElement.readOnly; child.readOnly = this.mInputElement.readOnly;
this.setFieldTabIndexAttribute(child); // tabIndex as a property works on all relevant elements.
child.tabIndex = this.editFieldTabIndex();
} }
this.mResetButton.disabled = this.mResetButton.disabled =