diff --git a/devtools/client/markupview/test/browser_markupview_keybindings_04.js b/devtools/client/markupview/test/browser_markupview_keybindings_04.js index c36c271e4b16..2529641b3e87 100644 --- a/devtools/client/markupview/test/browser_markupview_keybindings_04.js +++ b/devtools/client/markupview/test/browser_markupview_keybindings_04.js @@ -20,10 +20,7 @@ add_task(function*() { info("Press arrowUp to focus " + "(which works if the node was focused properly)"); - let onNodeHighlighted = toolbox.once("node-highlight"); - EventUtils.synthesizeKey("VK_UP", {}); - yield waitForChildrenUpdated(inspector); - yield onNodeHighlighted; + yield selectPreviousNodeWithArrowUp(inspector); assertNodeSelected(inspector, "body"); info("Select the test node with the element picker"); @@ -32,10 +29,7 @@ add_task(function*() { info("Press arrowUp to focus " + "(which works if the node was focused properly)"); - onNodeHighlighted = toolbox.once("node-highlight"); - EventUtils.synthesizeKey("VK_UP", {}); - yield waitForChildrenUpdated(inspector); - yield onNodeHighlighted; + yield selectPreviousNodeWithArrowUp(inspector); assertNodeSelected(inspector, "body"); }); @@ -44,6 +38,13 @@ function assertNodeSelected(inspector, tagName) { `The <${tagName}> node is selected`); } +function selectPreviousNodeWithArrowUp(inspector) { + let onNodeHighlighted = inspector.toolbox.once("node-highlight"); + let onUpdated = inspector.once("inspector-updated"); + EventUtils.synthesizeKey("VK_UP", {}); + return Promise.all([onUpdated, onNodeHighlighted]); +} + function* selectWithBrowserMenu(inspector) { yield BrowserTestUtils.synthesizeMouseAtCenter("div", { type: "contextmenu",