зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1147808 - Cancel add-on installation when the tab or window closes while waiting for the user to confirm the installation. r=dtownsend
This commit is contained in:
Родитель
d8eae22539
Коммит
27fb633b15
|
@ -54,6 +54,22 @@ const gXPInstallObserver = {
|
|||
// originatingURI might be missing or 'host' might throw for non-nsStandardURL nsIURIs.
|
||||
}
|
||||
|
||||
let cancelInstallation = () => {
|
||||
if (installInfo) {
|
||||
for (let install of installInfo.installs)
|
||||
install.cancel();
|
||||
}
|
||||
|
||||
if (aTopic == "addon-install-confirmation")
|
||||
this.acceptInstallation = null;
|
||||
|
||||
let tab = gBrowser.getTabForBrowser(browser);
|
||||
if (tab)
|
||||
tab.removeEventListener("TabClose", cancelInstallation);
|
||||
|
||||
window.removeEventListener("unload", cancelInstallation);
|
||||
};
|
||||
|
||||
switch (aTopic) {
|
||||
case "addon-install-disabled": {
|
||||
notificationID = "xpinstall-disabled";
|
||||
|
@ -170,11 +186,7 @@ const gXPInstallObserver = {
|
|||
options.eventCallback = (aEvent) => {
|
||||
switch (aEvent) {
|
||||
case "removed":
|
||||
if (installInfo) {
|
||||
for (let install of installInfo.installs)
|
||||
install.cancel();
|
||||
}
|
||||
this.acceptInstallation = null;
|
||||
cancelInstallation();
|
||||
break;
|
||||
case "shown":
|
||||
let addonList = document.getElementById("addon-install-confirmation-content");
|
||||
|
@ -247,8 +259,12 @@ const gXPInstallObserver = {
|
|||
|
||||
let showNotification = () => {
|
||||
let tab = gBrowser.getTabForBrowser(browser);
|
||||
if (tab)
|
||||
if (tab) {
|
||||
gBrowser.selectedTab = tab;
|
||||
tab.addEventListener("TabClose", cancelInstallation);
|
||||
}
|
||||
|
||||
window.addEventListener("unload", cancelInstallation);
|
||||
|
||||
if (PopupNotifications.isPanelOpen) {
|
||||
let rect = document.getElementById("addon-progress-notification").getBoundingClientRect();
|
||||
|
|
|
@ -620,6 +620,35 @@ function test_localfile() {
|
|||
gBrowser.loadURI(path);
|
||||
},
|
||||
|
||||
function test_tabclose() {
|
||||
if (!Preferences.get("xpinstall.customConfirmationUI", false)) {
|
||||
runNextTest();
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for the progress notification
|
||||
wait_for_progress_notification(aPanel => {
|
||||
// Wait for the install confirmation dialog
|
||||
wait_for_install_dialog(() => {
|
||||
AddonManager.getAllInstalls(aInstalls => {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
|
||||
wait_for_notification_close(() => {
|
||||
AddonManager.getAllInstalls(aInstalls => {
|
||||
is(aInstalls.length, 0, "Should be no pending install since the tab is closed");
|
||||
runNextTest();
|
||||
});
|
||||
});
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.loadURI(TESTROOT + "unsigned.xpi");
|
||||
},
|
||||
|
||||
function test_wronghost() {
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.addEventListener("load", function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче