Bug 623192: Restarting download of add-on completely removes progress notification. r=gavin, a=blocks-final

This commit is contained in:
Dave Townsend 2011-01-07 09:16:35 -08:00
parent 028607619c
commit 7c6599530e
3 changed files with 22 additions and 4 deletions

View File

@ -719,6 +719,12 @@ const gXPInstallObserver = {
options.installs = installInfo.installs;
options.contentWindow = browser.contentWindow;
options.sourceURI = browser.currentURI;
options.eventCallback = function(aNotification, aEvent) {
if (aEvent != "removed")
return;
aNotification.options.contentWindow = null;
aNotification.options.sourceURI = null;
};
PopupNotifications.show(browser, notificationID, messageString, anchorID,
null, null, options);
break;

View File

@ -114,6 +114,7 @@ function test_blocked_install() {
EventUtils.synthesizeMouse(notification.button, 20, 10, {});
// Notification should have changed to progress notification
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
notification = aPanel.childNodes[0];
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
@ -681,6 +682,18 @@ function test_cancel_restart() {
wait_for_notification(function(aPanel) {
let notification = aPanel.childNodes[0];
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
// Close the notification
let anchor = document.getElementById("addons-notification-icon");
EventUtils.synthesizeMouseAtCenter(anchor, {});
// Reopen the notification
EventUtils.synthesizeMouseAtCenter(anchor, {});
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
isnot(notification, aPanel.childNodes[0], "Should have reconstructed the notification UI");
notification = aPanel.childNodes[0];
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
let button = document.getAnonymousElementByAttribute(notification, "anonid", "cancel");
// Cancel the download
@ -696,6 +709,8 @@ function test_cancel_restart() {
EventUtils.synthesizeMouse(notification.button, 20, 10, {});
// Should be back to a progress notification
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
notification = aPanel.childNodes[0];
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");

View File

@ -1165,9 +1165,6 @@
<method name="destroy">
<body><![CDATA[
this.notification.options.browser = null;
this.notification.options.contentWindow = null;
this.notification.options.sourceURI = null;
this.notification.options.installs.forEach(function(aInstall) {
aInstall.removeListener(this);
}, this);
@ -1218,7 +1215,7 @@
<method name="cancel">
<body><![CDATA[
// Cache these as cancelling the installs will remove this
// notification and call destroy
// notification which will drop these references
let browser = this.notification.browser;
let contentWindow = this.notification.options.contentWindow;
let sourceURI = this.notification.options.sourceURI;