2008-11-07 13:28:31 -08:00
|
|
|
// 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;
|
|
|
|
|
2010-04-02 00:20:42 -07:00
|
|
|
Services.wm.addListener(this);
|
2008-11-07 13:28:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-04-02 00:20:42 -07:00
|
|
|
Services.wm.removeListener(this);
|
2008-11-07 13:28:31 -08:00
|
|
|
this.opencallback = null;
|
|
|
|
this.window = null;
|
|
|
|
this.domwindow = null;
|
|
|
|
|
|
|
|
// Let the window close complete
|
|
|
|
executeSoon(this.closecallback);
|
|
|
|
this.closecallback = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-07-14 14:13:51 -07:00
|
|
|
function test() {
|
|
|
|
ok(Application, "Check global access to Application");
|
|
|
|
|
|
|
|
// I'd test these against a specific value, but that is bound to flucuate
|
|
|
|
ok(Application.id, "Check to see if an ID exists for the Application");
|
|
|
|
ok(Application.name, "Check to see if a name exists for the Application");
|
|
|
|
ok(Application.version, "Check to see if a version exists for the Application");
|
2007-08-21 12:59:46 -07:00
|
|
|
|
|
|
|
var wMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
|
|
|
|
var console = wMediator.getMostRecentWindow("global:console");
|
2007-09-19 07:01:59 -07:00
|
|
|
waitForExplicitFinish();
|
2008-11-07 13:28:31 -08:00
|
|
|
ok(!console, "Console should not already be open");
|
|
|
|
|
|
|
|
new WindowOpenListener("chrome://global/content/console.xul", consoleOpened, consoleClosed);
|
|
|
|
Application.console.open();
|
2007-08-21 12:59:46 -07:00
|
|
|
}
|
|
|
|
|
2008-11-07 13:28:31 -08:00
|
|
|
function consoleOpened(win) {
|
|
|
|
win.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function consoleClosed() {
|
2007-09-19 07:01:59 -07:00
|
|
|
finish();
|
2007-07-14 14:13:51 -07:00
|
|
|
}
|