Bug 579540: Wait for focus before accepting extension installs. r=gavin, a=tests

This commit is contained in:
Dave Townsend 2010-11-03 11:23:18 -07:00
parent cab155a5dd
commit ae7a168044
2 changed files with 11 additions and 23 deletions

View File

@ -33,26 +33,21 @@ function wait_for_install_dialog(aCallback) {
info("Waiting for install dialog");
Services.wm.addListener({
onOpenWindow: function(aXULWindow) {
info("Install dialog opened, waiting for load");
info("Install dialog opened, waiting for focus");
Services.wm.removeListener(this);
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowInternal);
domwindow.addEventListener("load", function() {
domwindow.removeEventListener("load", arguments.callee, false);
waitForFocus(function() {
info("Saw install dialog");
is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open");
// Allow other window load listeners to execute before passing to callback
executeSoon(function() {
info("Saw install dialog");
// Override the countdown timer on the accept button
var button = domwindow.document.documentElement.getButton("accept");
button.disabled = false;
// Override the countdown timer on the accept button
var button = domwindow.document.documentElement.getButton("accept");
button.disabled = false;
aCallback(domwindow);
});
}, false);
aCallback(domwindow);
}, domwindow);
},
onCloseWindow: function(aXULWindow) {

View File

@ -139,12 +139,6 @@ var Harness = {
},
// Window open handling
windowLoad: function(window) {
// Allow any other load handlers to execute
var self = this;
executeSoon(function() { self.windowReady(window); } );
},
windowReady: function(window) {
if (window.document.location.href == XPINSTALL_URL) {
if (this.installBlockedCallback)
@ -224,10 +218,9 @@ var Harness = {
var domwindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowInternal);
var self = this;
domwindow.addEventListener("load", function() {
domwindow.removeEventListener("load", arguments.callee, false);
self.windowLoad(domwindow);
}, false);
waitForFocus(function() {
self.windowReady(domwindow);
}, domwindow);
},
onCloseWindow: function(window) {