From 73b694e4c19e9421a21651ce178f811d6f5919af Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Tue, 23 Jul 2013 15:46:13 +0300 Subject: [PATCH] Wait for the focus event before simulating a key press to fix an intermittent Mac-only test failure (bug 895426); r=me --- .../test/browser_dbg_break-on-dom-event.js | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js b/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js index 135e11cb081..6072c1e2b2b 100644 --- a/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js +++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js @@ -67,8 +67,21 @@ function testBreakOnAll() }); gThreadClient.resume(function() { + // Make sure that the focus is not on the input box so that a focus event + // will be triggered. + window.focus(); + gBrowser.selectedBrowser.focus(); + gButton.focus(); + + // Focus the element and wait for focus event. + gInput.addEventListener("focus", function onfocus() { + gInput.removeEventListener("focus", onfocus, false); + executeSoon(function() { + EventUtils.synthesizeKey("e", { shiftKey: 1 }, content); + }); + }, false); + gInput.focus(); - EventUtils.synthesizeKey("e", { shiftKey: 1 }, content); }); }); }); @@ -94,8 +107,21 @@ function testBreakOnDisabled() testBreakOnNone(); }, false); + // Make sure that the focus is not on the input box so that a focus event + // will be triggered. + window.focus(); + gBrowser.selectedBrowser.focus(); + gButton.focus(); + + // Focus the element and wait for focus event. + gInput.addEventListener("focus", function onfocus() { + gInput.removeEventListener("focus", onfocus, false); + executeSoon(function() { + EventUtils.synthesizeKey("e", { shiftKey: 1 }, content); + }); + }, false); + gInput.focus(); - EventUtils.synthesizeKey("e", { shiftKey: 1 }, content); }); } @@ -117,8 +143,21 @@ function testBreakOnNone() testBreakOnClick(); }, false); + // Make sure that the focus is not on the input box so that a focus event + // will be triggered. + window.focus(); + gBrowser.selectedBrowser.focus(); + gButton.focus(); + + // Focus the element and wait for focus event. + gInput.addEventListener("focus", function onfocus() { + gInput.removeEventListener("focus", onfocus, false); + executeSoon(function() { + EventUtils.synthesizeKey("g", { shiftKey: 1 }, content); + }); + }, false); + gInput.focus(); - EventUtils.synthesizeKey("g", { shiftKey: 1 }, content); }); }