Bug 577048: Notifications about add-on installs and errors aren't shown if the source tab has no host. r=gavin
This commit is contained in:
@@ -643,7 +643,6 @@ const gXPInstallObserver = {
|
||||
const anchorID = "addons-notification-icon";
|
||||
var messageString, action;
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var host = installInfo.originatingURI ? installInfo.originatingURI.host : browser.currentURI.host;
|
||||
|
||||
var notificationID = aTopic;
|
||||
|
||||
@@ -666,8 +665,7 @@ const gXPInstallObserver = {
|
||||
buttons = [];
|
||||
}
|
||||
else {
|
||||
messageString = gNavigatorBundle.getFormattedString("xpinstallDisabledMessage",
|
||||
[brandShortName, host]);
|
||||
messageString = gNavigatorBundle.getString("xpinstallDisabledMessage");
|
||||
|
||||
action = {
|
||||
label: gNavigatorBundle.getString("xpinstallDisabledButton"),
|
||||
@@ -683,7 +681,7 @@ const gXPInstallObserver = {
|
||||
return;
|
||||
|
||||
messageString = gNavigatorBundle.getFormattedString("xpinstallPromptWarning",
|
||||
[brandShortName, host]);
|
||||
[brandShortName, installInfo.originatingURI.host]);
|
||||
|
||||
action = {
|
||||
label: gNavigatorBundle.getString("xpinstallPromptAllowButton"),
|
||||
@@ -700,7 +698,13 @@ const gXPInstallObserver = {
|
||||
case "addon-install-failed":
|
||||
// TODO This isn't terribly ideal for the multiple failure case
|
||||
installInfo.installs.forEach(function(aInstall) {
|
||||
var error = "addonError";
|
||||
var host = (installInfo.originatingURI instanceof Ci.nsIStandardURL) &&
|
||||
installInfo.originatingURI.host;
|
||||
if (!host)
|
||||
host = (aInstall.sourceURI instanceof Ci.nsIStandardURL) &&
|
||||
aInstall.sourceURI.host;
|
||||
|
||||
var error = (host || aInstall.error == 0) ? "addonError" : "addonLocalError";
|
||||
if (aInstall.error != 0)
|
||||
error += aInstall.error;
|
||||
else if (aInstall.addon.blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED)
|
||||
@@ -710,7 +714,8 @@ const gXPInstallObserver = {
|
||||
|
||||
messageString = gNavigatorBundle.getString(error);
|
||||
messageString = messageString.replace("#1", aInstall.name);
|
||||
messageString = messageString.replace("#2", host);
|
||||
if (host)
|
||||
messageString = messageString.replace("#2", host);
|
||||
messageString = messageString.replace("#3", brandShortName);
|
||||
messageString = messageString.replace("#4", Services.appinfo.version);
|
||||
|
||||
|
||||
@@ -3,8 +3,13 @@
|
||||
*/
|
||||
|
||||
const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
||||
const TESTROOT2 = "http://example.org/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
||||
const CHROMEROOT = "chrome://mochikit/content/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
||||
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
|
||||
|
||||
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
|
||||
var gVersion = Services.appinfo.version;
|
||||
|
||||
function wait_for_notification(aCallback) {
|
||||
PopupNotifications.panel.addEventListener("popupshown", function() {
|
||||
PopupNotifications.panel.removeEventListener("popupshown", arguments.callee, false);
|
||||
@@ -56,6 +61,10 @@ function test_blocked_install() {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-blocked", "Should have seen the install blocked");
|
||||
is(notification.button.label, "Allow", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
gApp + " prevented this site (example.com) from asking you to install " +
|
||||
"software on your computer.",
|
||||
"Should have seen the right message");
|
||||
|
||||
// Click on Allow
|
||||
EventUtils.synthesizeMouse(notification.button, 20, 10, {});
|
||||
@@ -69,6 +78,9 @@ function test_blocked_install() {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-complete", "Should have seen the install complete");
|
||||
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
"XPI Test will be installed after you restart " + gApp + ".",
|
||||
"Should have seen the right message");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
@@ -101,6 +113,9 @@ function test_whitelisted_install() {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-complete", "Should have seen the install complete");
|
||||
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
"XPI Test will be installed after you restart " + gApp + ".",
|
||||
"Should have seen the right message");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
@@ -128,6 +143,10 @@ function test_failed_download() {
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-failed", "Should have seen the install fail");
|
||||
is(notification.getAttribute("label"),
|
||||
"The add-on could not be downloaded because of a connection failure " +
|
||||
"on example.com.",
|
||||
"Should have seen the right message");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
Services.perms.remove("example.com", "install");
|
||||
@@ -149,6 +168,10 @@ function test_corrupt_file() {
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-failed", "Should have seen the install fail");
|
||||
is(notification.getAttribute("label"),
|
||||
"The add-on downloaded from example.com could not be installed " +
|
||||
"because it appears to be corrupt.",
|
||||
"Should have seen the right message");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
Services.perms.remove("example.com", "install");
|
||||
@@ -170,6 +193,10 @@ function test_incompatible() {
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-failed", "Should have seen the install fail");
|
||||
is(notification.getAttribute("label"),
|
||||
"XPI Test could not be installed because it is not compatible with " +
|
||||
gApp + " " + gVersion + ".",
|
||||
"Should have seen the right message");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
Services.perms.remove("example.com", "install");
|
||||
@@ -196,6 +223,9 @@ function test_restartless() {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-complete", "Should have seen the install complete");
|
||||
is(notification.button.label, "Open Add-ons Manager", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
"XPI Test has been installed successfully.",
|
||||
"Should have seen the right message");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 0, "Should be no pending installs");
|
||||
@@ -232,6 +262,9 @@ function test_multiple() {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-complete", "Should have seen the install complete");
|
||||
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
"2 add-ons will be installed after you restart " + gApp + ".",
|
||||
"Should have seen the right message");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
@@ -247,6 +280,81 @@ function test_multiple() {
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
function test_url() {
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.loadURI(TESTROOT + "unsigned.xpi");
|
||||
|
||||
// Wait for the install confirmation dialog
|
||||
wait_for_install_dialog(function(aWindow) {
|
||||
aWindow.document.documentElement.acceptDialog();
|
||||
|
||||
// Wait for the complete notification
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-complete", "Should have seen the install complete");
|
||||
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
||||
is(notification.getAttribute("label"),
|
||||
"XPI Test will be installed after you restart " + gApp + ".",
|
||||
"Should have seen the right message");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
aInstalls[0].cancel();
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
runNextTest();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
function test_localfile() {
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIChromeRegistry);
|
||||
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.loadURI(path);
|
||||
|
||||
// Wait for the complete notification
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-failed", "Should have seen the install fail");
|
||||
is(notification.getAttribute("label"),
|
||||
"This add-on could not be installed because it appears to be corrupt.",
|
||||
"Should have seen the right message");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
runNextTest();
|
||||
});
|
||||
},
|
||||
|
||||
function test_wronghost() {
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.addEventListener("load", function() {
|
||||
if (gBrowser.currentURI.spec != TESTROOT2 + "enabled.html")
|
||||
return;
|
||||
|
||||
gBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
gBrowser.loadURI(TESTROOT + "corrupt.xpi");
|
||||
|
||||
// Wait for the complete notification
|
||||
wait_for_notification(function(aPanel) {
|
||||
let notification = aPanel.childNodes[0];
|
||||
is(notification.id, "addon-install-failed", "Should have seen the install fail");
|
||||
is(notification.getAttribute("label"),
|
||||
"The add-on downloaded from example.com could not be installed " +
|
||||
"because it appears to be corrupt.",
|
||||
"Should have seen the right message");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
runNextTest();
|
||||
});
|
||||
}, true);
|
||||
gBrowser.loadURI(TESTROOT2 + "enabled.html");
|
||||
}
|
||||
];
|
||||
|
||||
@@ -255,10 +363,13 @@ function runNextTest() {
|
||||
is(aInstalls.length, 0, "Should be no active installs");
|
||||
|
||||
if (TESTS.length == 0) {
|
||||
Services.prefs.setBoolPref("extensions.logging.enabled", false);
|
||||
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
info("Running " + TESTS[0].name);
|
||||
TESTS.shift()();
|
||||
});
|
||||
}
|
||||
@@ -266,5 +377,7 @@ function runNextTest() {
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
Services.prefs.setBoolPref("extensions.logging.enabled", true);
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
@@ -44,13 +44,20 @@ addonInstallRestartButton.accesskey=R
|
||||
addonInstallManage=Open Add-ons Manager
|
||||
addonInstallManage.accesskey=O
|
||||
|
||||
# LOCALIZATION NOTE (addonError-1, addonError-2, addonError-3, addonError-4, addonErrorIncompatible, addonErrorBlocklisted):
|
||||
# LOCALIZATION NOTE (addonError-1, addonError-2, addonError-3, addonError-4):
|
||||
# #1 is the add-on name, #2 is the host name, #3 is the application name
|
||||
# #4 is the application version
|
||||
addonError-1=The add-on could not be downloaded because of a connection failure on #2.
|
||||
addonError-2=The add-on from #2 could not be installed because it does not match the add-on #3 expected.
|
||||
addonError-3=The add-on downloaded from #2 could not be installed because it appears to be corrupt.
|
||||
addonError-4=#1 could not be installed because #3 cannot modify the needed file.
|
||||
|
||||
# LOCALIZATION NOTE (addonLocalError-1, addonLocalError-2, addonLocalError-3, addonLocalError-4, addonErrorIncompatible, addonErrorBlocklisted):
|
||||
# #1 is the add-on name, #3 is the application name, #4 is the application version
|
||||
addonLocalError-1=This add-on could not be installed because of a filesystem error.
|
||||
addonLocalError-2=This add-on could not be installed because it does not match the add-on #3 expected.
|
||||
addonLocalError-3=This add-on could not be installed because it appears to be corrupt.
|
||||
addonLocalError-4=#1 could not be installed because #3 cannot modify the needed file.
|
||||
addonErrorIncompatible=#1 could not be installed because it is not compatible with #3 #4.
|
||||
addonErrorBlocklisted=#1 could not be installed because it has a high risk of causing stability or security problems.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user