mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 897943 - Fix focus issues and wait for delayed startup in browser_locationBarCommand.js; f=margaret r=gavin
This commit is contained in:
parent
4d643986d1
commit
1f880434bc
@ -32,7 +32,7 @@ function runAltLeftClickTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runShiftLeftClickTest() {
|
function runShiftLeftClickTest() {
|
||||||
let listener = new WindowListener(getBrowserURL(), function(aWindow) {
|
let listener = new BrowserWindowListener(getBrowserURL(), function(aWindow) {
|
||||||
Services.wm.removeListener(listener);
|
Services.wm.removeListener(listener);
|
||||||
addPageShowListener(aWindow.gBrowser.selectedBrowser, function() {
|
addPageShowListener(aWindow.gBrowser.selectedBrowser, function() {
|
||||||
executeSoon(function () {
|
executeSoon(function () {
|
||||||
@ -43,7 +43,9 @@ function runShiftLeftClickTest() {
|
|||||||
is(aWindow.gURLBar.value, TEST_VALUE, "New URL is loaded in new window");
|
is(aWindow.gURLBar.value, TEST_VALUE, "New URL is loaded in new window");
|
||||||
|
|
||||||
aWindow.close();
|
aWindow.close();
|
||||||
runNextTest();
|
|
||||||
|
// Continue testing when the original window has focus again.
|
||||||
|
whenWindowActivated(window, runNextTest);
|
||||||
});
|
});
|
||||||
}, "http://example.com/");
|
}, "http://example.com/");
|
||||||
});
|
});
|
||||||
@ -175,26 +177,36 @@ function addPageShowListener(browser, cb, expectedURL) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function WindowListener(aURL, aCallback) {
|
function whenWindowActivated(win, cb) {
|
||||||
|
if (Services.focus.activeWindow == win) {
|
||||||
|
executeSoon(cb);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
win.addEventListener("activate", function onActivate() {
|
||||||
|
win.removeEventListener("activate", onActivate);
|
||||||
|
executeSoon(cb);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function BrowserWindowListener(aURL, aCallback) {
|
||||||
this.callback = aCallback;
|
this.callback = aCallback;
|
||||||
this.url = aURL;
|
this.url = aURL;
|
||||||
}
|
}
|
||||||
WindowListener.prototype = {
|
BrowserWindowListener.prototype = {
|
||||||
onOpenWindow: function(aXULWindow) {
|
onOpenWindow: function(aXULWindow) {
|
||||||
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
let cb = () => this.callback(domwindow);
|
||||||
|
let domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDOMWindow);
|
.getInterface(Ci.nsIDOMWindow);
|
||||||
var self = this;
|
|
||||||
domwindow.addEventListener("load", function() {
|
|
||||||
domwindow.removeEventListener("load", arguments.callee, false);
|
|
||||||
|
|
||||||
if (domwindow.document.location.href != self.url)
|
let numWait = 2;
|
||||||
return;
|
function maybeRunCallback() {
|
||||||
|
if (--numWait == 0)
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
// Allow other window load listeners to execute before passing to callback
|
whenWindowActivated(domwindow, maybeRunCallback);
|
||||||
executeSoon(function() {
|
whenDelayedStartupFinished(domwindow, maybeRunCallback);
|
||||||
self.callback(domwindow);
|
|
||||||
});
|
|
||||||
}, false);
|
|
||||||
},
|
},
|
||||||
onCloseWindow: function(aXULWindow) {},
|
onCloseWindow: function(aXULWindow) {},
|
||||||
onWindowTitleChange: function(aXULWindow, aNewTitle) {}
|
onWindowTitleChange: function(aXULWindow, aNewTitle) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user