diff --git a/devtools/client/inspector/test/shared-head.js b/devtools/client/inspector/test/shared-head.js index 9e82d7e0870e..6d46be3f4d31 100644 --- a/devtools/client/inspector/test/shared-head.js +++ b/devtools/client/inspector/test/shared-head.js @@ -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", {},