mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 463595 - browser_Application.js uses timeouts and fails intermittently
r=gavin This should make tinderbox a little more green from time to time.
This commit is contained in:
parent
e18c31f9da
commit
635632ddcc
@ -1,6 +1,65 @@
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
|
||||
// This listens for the next opened window and checks it is of the right url.
|
||||
// opencallback is called when the new window is fully loaded
|
||||
// closecallback is called when the window is closed
|
||||
function WindowOpenListener(url, opencallback, closecallback) {
|
||||
this.url = url;
|
||||
this.opencallback = opencallback;
|
||||
this.closecallback = closecallback;
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
wm.addListener(this);
|
||||
}
|
||||
|
||||
WindowOpenListener.prototype = {
|
||||
url: null,
|
||||
opencallback: null,
|
||||
closecallback: null,
|
||||
window: null,
|
||||
domwindow: null,
|
||||
|
||||
handleEvent: function(event) {
|
||||
is(this.domwindow.document.location.href, this.url, "Should have opened the correct window");
|
||||
|
||||
this.domwindow.removeEventListener("load", this, false);
|
||||
// Allow any other load handlers to execute
|
||||
var self = this;
|
||||
executeSoon(function() { self.opencallback(self.domwindow); } );
|
||||
},
|
||||
|
||||
onWindowTitleChange: function(window, title) {
|
||||
},
|
||||
|
||||
onOpenWindow: function(window) {
|
||||
if (this.window)
|
||||
return;
|
||||
|
||||
this.window = window;
|
||||
this.domwindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowInternal);
|
||||
this.domwindow.addEventListener("load", this, false);
|
||||
},
|
||||
|
||||
onCloseWindow: function(window) {
|
||||
if (this.window != window)
|
||||
return;
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
wm.removeListener(this);
|
||||
this.opencallback = null;
|
||||
this.window = null;
|
||||
this.domwindow = null;
|
||||
|
||||
// Let the window close complete
|
||||
executeSoon(this.closecallback);
|
||||
this.closecallback = null;
|
||||
}
|
||||
};
|
||||
|
||||
function test() {
|
||||
ok(Application, "Check global access to Application");
|
||||
|
||||
@ -12,17 +71,16 @@ function test() {
|
||||
var wMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
||||
var console = wMediator.getMostRecentWindow("global:console");
|
||||
waitForExplicitFinish();
|
||||
if (!console) {
|
||||
Application.console.open();
|
||||
}
|
||||
setTimeout(checkConsole, 500);
|
||||
ok(!console, "Console should not already be open");
|
||||
|
||||
new WindowOpenListener("chrome://global/content/console.xul", consoleOpened, consoleClosed);
|
||||
Application.console.open();
|
||||
}
|
||||
|
||||
function checkConsole() {
|
||||
var wMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
||||
var console = wMediator.getMostRecentWindow("global:console");
|
||||
ok(console, "Check to see if the console window opened");
|
||||
if (console)
|
||||
console.close();
|
||||
function consoleOpened(win) {
|
||||
win.close();
|
||||
}
|
||||
|
||||
function consoleClosed() {
|
||||
finish();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user