forked from mirrors/gecko-dev
Bug 1845152 - [devtools] Make sure the input is focused before triggering keyboard event in setProperty. r=devtools-reviewers,ochameau a=test-only
Differential Revision: https://phabricator.services.mozilla.com/D233821
This commit is contained in:
parent
81d6efa641
commit
cd9b1a656c
1 changed files with 12 additions and 4 deletions
|
|
@ -565,9 +565,7 @@ var focusEditableField = async function (
|
|||
await onFocus;
|
||||
|
||||
info("Editable field gained focus, returning the input field now");
|
||||
const onEdit = inplaceEditor(editable.ownerDocument.activeElement);
|
||||
|
||||
return onEdit;
|
||||
return inplaceEditor(editable.ownerDocument.activeElement);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1083,7 +1081,7 @@ async function setProperty(
|
|||
{ blurNewProperty = true, flushCount = 1 } = {}
|
||||
) {
|
||||
info("Set property to: " + value);
|
||||
await focusEditableField(ruleView, textProp.editor.valueSpan);
|
||||
const editor = await focusEditableField(ruleView, textProp.editor.valueSpan);
|
||||
|
||||
// Because of the manual flush approach used for tests, we might have an
|
||||
// unknown number of debounced "preview" requests . Each preview should
|
||||
|
|
@ -1104,6 +1102,11 @@ async function setProperty(
|
|||
await onPopupOpened;
|
||||
} else {
|
||||
await wait(500);
|
||||
// Since some time have passed since we made the input visible and focused it,
|
||||
// we might have some previous async work that causes the input to be blurred
|
||||
// (see intermittent Bug 1845152).
|
||||
// Make sure the input is focused before triggering the keyboard event.
|
||||
editor.input.focus();
|
||||
EventUtils.sendString(value, ruleView.styleWindow);
|
||||
}
|
||||
|
||||
|
|
@ -1138,6 +1141,11 @@ async function setProperty(
|
|||
onPopupClosed = once(ruleView.popup, "popup-closed");
|
||||
}
|
||||
|
||||
// Since some time have passed since we made the input visible and focused it,
|
||||
// we might have some previous async work that causes the input to be blurred
|
||||
// (see intermittent Bug 1845152).
|
||||
// Make sure the input is focused before triggering the keyboard event.
|
||||
editor.input.focus();
|
||||
EventUtils.synthesizeKey(
|
||||
blurNewProperty ? "VK_RETURN" : "VK_TAB",
|
||||
{},
|
||||
|
|
|
|||
Loading…
Reference in a new issue