Bug 880101: fix intermittent orange in browser_locationBarCommand.js, r=margaret

--HG--
extra : transplant_source : Y%B2%A3%D5i%2C%8F%CB%FA%82%B1%83%A2%BB%96%99q%C8%B7%FA
This commit is contained in:
Gavin Sharp 2013-06-17 14:00:10 -04:00
parent 18684641d4
commit a127fa57c5

View File

@ -34,7 +34,7 @@ function runAltLeftClickTest() {
function runShiftLeftClickTest() {
let listener = new WindowListener(getBrowserURL(), function(aWindow) {
Services.wm.removeListener(listener);
addPageShowListener(aWindow.gBrowser, function() {
addPageShowListener(aWindow.gBrowser.selectedBrowser, function() {
info("URL should be loaded in a new window");
is(gURLBar.value, "", "Urlbar reverted to original value");
is(gFocusManager.focusedElement, null, "There should be no focused element");
@ -43,7 +43,7 @@ function runShiftLeftClickTest() {
aWindow.close();
runNextTest();
});
}, "http://example.com/");
});
Services.wm.addListener(listener);
@ -61,7 +61,7 @@ function runNextTest() {
info("Running test: " + test.desc);
// Tab will be blank if test.startValue is null
let tab = gBrowser.selectedTab = gBrowser.addTab(test.startValue);
addPageShowListener(gBrowser, function() {
addPageShowListener(gBrowser.selectedBrowser, function() {
triggerCommand(test.click, test.event);
test.check(tab);
@ -163,10 +163,13 @@ function checkNewTab(aTab) {
isnot(gBrowser.selectedTab, aTab, "New URL was loaded in a new tab");
}
function addPageShowListener(aBrowser, aFunc) {
aBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
aBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
aFunc();
function addPageShowListener(browser, cb, expectedURL) {
browser.addEventListener("pageshow", function pageShowListener() {
info("pageshow: " + browser.currentURI.spec);
if (expectedURL && browser.currentURI.spec != expectedURL)
return; // ignore pageshows for non-expected URLs
browser.removeEventListener("pageshow", pageShowListener, false);
cb();
});
}