Bug 1199180 - Wait for the inspector-updated event after selecting nodes with UP key. r=pbrosset

The likely steps that lead to intermittent failures in
browser_markupview_keybindings_04.js are:
1) UP key is pressed, the test waits for child updates and
   node-highlight event.
2) Once those have finished, the selection has changed to <body> BUT
   the inspector-updated event for the change has not been emitted
   (child node update finishes before the event is emitted).
3) The test calls selectWithElementPicker() presses ENTER to pick the
   <div> element and starts to wait for an inspector-updated event.
4) The inspector-updated event from (1) is finally emitted and the test
   continues BUT the selection change at (3) has not yet completed.
   This means <body> is still selected and the assertion fails.

Since a new selection will always cause the inspector-updated event to
be emitted it makes sense to wait for it after pressing UP.

--HG--
extra : transplant_source : %09%05O%3D%01P%FEI%27j-%8C%15%5D%A5%00%03%23U%3F
This commit is contained in:
Sami Jaktholm 2015-11-07 08:27:16 +02:00
Родитель b658863623
Коммит 6952252fea
1 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -20,10 +20,7 @@ add_task(function*() {
info("Press arrowUp to focus <body> " +
"(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 <body> " +
"(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",