2010-07-01 09:23:11 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
const TESTROOT = "http://example.com/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
2010-07-29 15:59:39 -07:00
|
|
|
const TESTROOT2 = "http://example.org/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
2010-07-01 09:23:11 -07:00
|
|
|
const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
|
|
|
|
|
2010-09-10 10:20:38 -07:00
|
|
|
var rootDir = getRootDirectory(gTestPath);
|
|
|
|
var path = rootDir.split('/');
|
|
|
|
var chromeName = path[0] + '//' + path[2];
|
|
|
|
var croot = chromeName + "/content/browser/toolkit/mozapps/extensions/test/xpinstall/";
|
|
|
|
var jar = getJar(croot);
|
|
|
|
if (jar) {
|
|
|
|
var tmpdir = extractJarToTmp(jar);
|
|
|
|
croot = 'file://' + tmpdir.path + '/';
|
|
|
|
}
|
|
|
|
const CHROMEROOT = croot;
|
|
|
|
|
2010-07-29 15:59:39 -07:00
|
|
|
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
|
|
|
|
var gVersion = Services.appinfo.version;
|
|
|
|
|
2010-07-01 09:23:11 -07:00
|
|
|
function wait_for_notification(aCallback) {
|
2010-10-14 16:15:26 -07:00
|
|
|
info("Waiting for notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
PopupNotifications.panel.addEventListener("popupshown", function() {
|
|
|
|
PopupNotifications.panel.removeEventListener("popupshown", arguments.callee, false);
|
2010-10-14 16:15:26 -07:00
|
|
|
info("Saw notification");
|
2011-01-03 11:40:47 -08:00
|
|
|
is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
aCallback(PopupNotifications.panel);
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function wait_for_install_dialog(aCallback) {
|
2010-10-14 16:15:26 -07:00
|
|
|
info("Waiting for install dialog");
|
2010-07-01 09:23:11 -07:00
|
|
|
Services.wm.addListener({
|
|
|
|
onOpenWindow: function(aXULWindow) {
|
2010-11-03 11:23:18 -07:00
|
|
|
info("Install dialog opened, waiting for focus");
|
2010-07-01 09:23:11 -07:00
|
|
|
Services.wm.removeListener(this);
|
|
|
|
|
|
|
|
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindowInternal);
|
2010-11-03 11:23:18 -07:00
|
|
|
waitForFocus(function() {
|
|
|
|
info("Saw install dialog");
|
2010-07-01 09:23:11 -07:00
|
|
|
is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open");
|
|
|
|
|
2010-11-03 11:23:18 -07:00
|
|
|
// Override the countdown timer on the accept button
|
|
|
|
var button = domwindow.document.documentElement.getButton("accept");
|
|
|
|
button.disabled = false;
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-11-03 11:23:18 -07:00
|
|
|
aCallback(domwindow);
|
|
|
|
}, domwindow);
|
2010-07-01 09:23:11 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
onCloseWindow: function(aXULWindow) {
|
|
|
|
},
|
|
|
|
|
|
|
|
onWindowTitleChange: function(aXULWindow, aNewTitle) {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var TESTS = [
|
2010-11-24 12:37:28 -08:00
|
|
|
function test_disabled_install() {
|
|
|
|
Services.prefs.setBoolPref("xpinstall.enabled", false);
|
|
|
|
|
|
|
|
// Wait for the disabled notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "xpinstall-disabled-notification", "Should have seen installs disabled");
|
|
|
|
is(notification.button.label, "Enable", "Should have seen the right button");
|
|
|
|
is(notification.getAttribute("label"),
|
|
|
|
"Software installation is currently disabled. Click Enable and try again.");
|
|
|
|
|
|
|
|
// Click on Enable
|
|
|
|
EventUtils.synthesizeMouseAtCenter(notification.button, {});
|
|
|
|
|
|
|
|
try {
|
|
|
|
Services.prefs.getBoolPref("xpinstall.disabled");
|
|
|
|
ok(false, "xpinstall.disabled should not be set");
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
ok(true, "xpinstall.disabled should not be set");
|
|
|
|
}
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
|
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should have been one install created");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"XPI": "unsigned.xpi"
|
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
|
|
|
},
|
|
|
|
|
2010-07-01 09:23:11 -07:00
|
|
|
function test_blocked_install() {
|
|
|
|
// Wait for the blocked notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2010-08-27 19:41:41 -07:00
|
|
|
is(notification.id, "addon-install-blocked-notification", "Should have seen the install blocked");
|
2010-07-01 09:23:11 -07:00
|
|
|
is(notification.button.label, "Allow", "Should have seen the right button");
|
2010-07-29 15:59:39 -07:00
|
|
|
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");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
|
|
|
// Click on Allow
|
|
|
|
EventUtils.synthesizeMouse(notification.button, 20, 10, {});
|
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Notification should have changed to progress notification
|
2011-01-07 09:16:35 -08:00
|
|
|
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
|
2011-01-03 11:40:47 -08:00
|
|
|
notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
|
|
|
|
2010-07-01 09:23:11 -07:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2010-08-27 19:41:41 -07:00
|
|
|
is(notification.id, "addon-install-complete-notification", "Should have seen the install complete");
|
2010-07-01 09:23:11 -07:00
|
|
|
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.getAttribute("label"),
|
2010-07-29 15:59:39 -07:00
|
|
|
"XPI Test will be installed after you restart " + gApp + ".",
|
|
|
|
"Should have seen the right message");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending install");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
|
|
|
aWindow.document.documentElement.acceptDialog();
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"XPI": "unsigned.xpi"
|
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_whitelisted_install() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending install");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"XPI": "unsigned.xpi"
|
2010-07-01 09:23:11 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_failed_download() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
2010-07-01 09:23:11 -07:00
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the failed notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-failed-notification", "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");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"XPI": "missing.xpi"
|
2010-07-01 09:23:11 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_corrupt_file() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
2010-07-01 09:23:11 -07:00
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the failed notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-failed-notification", "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");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"XPI": "corrupt.xpi"
|
2010-07-01 09:23:11 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_incompatible() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
2010-07-01 09:23:11 -07:00
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the failed notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-failed-notification", "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");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"XPI": "incompatible.xpi"
|
2010-07-01 09:23:11 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_restartless() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 0, "Should be no pending installs");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(aAddon) {
|
|
|
|
aAddon.uninstall();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"XPI": "restartless.xpi"
|
2010-07-01 09:23:11 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_multiple() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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");
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending install");
|
|
|
|
aInstalls[0].cancel();
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(aAddon) {
|
|
|
|
aAddon.uninstall();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-07-01 09:23:11 -07:00
|
|
|
});
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"Unsigned XPI": "unsigned.xpi",
|
|
|
|
"Restartless XPI": "restartless.xpi"
|
|
|
|
}));
|
2010-07-29 15:59:39 -07:00
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
2010-10-21 14:44:02 -07:00
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
|
|
|
},
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_url() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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");
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending install");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-29 15:59:39 -07:00
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-07-29 15:59:39 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
2010-10-21 14:44:02 -07:00
|
|
|
gBrowser.loadURI(TESTROOT + "unsigned.xpi");
|
|
|
|
},
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_localfile() {
|
2010-07-29 15:59:39 -07:00
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2010-08-27 19:41:41 -07:00
|
|
|
is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
|
2010-07-29 15:59:39 -07:00
|
|
|
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();
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
|
|
|
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
|
|
|
.getService(Components.interfaces.nsIChromeRegistry);
|
|
|
|
try {
|
|
|
|
var path = cr.convertChromeURL(makeURI(CHROMEROOT + "corrupt.xpi")).spec;
|
|
|
|
} catch (ex) {
|
|
|
|
var path = CHROMEROOT + "corrupt.xpi";
|
|
|
|
}
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(path);
|
2010-07-29 15:59:39 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
2010-07-29 15:59:39 -07:00
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-failed-notification", "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");
|
2010-07-29 15:59:39 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-07-29 15:59:39 -07:00
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
|
|
|
gBrowser.loadURI(TESTROOT + "corrupt.xpi");
|
2010-07-29 15:59:39 -07:00
|
|
|
}, true);
|
|
|
|
gBrowser.loadURI(TESTROOT2 + "enabled.html");
|
2010-07-30 08:36:35 -07:00
|
|
|
},
|
2010-07-29 15:59:55 -07:00
|
|
|
|
|
|
|
function test_reload() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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");
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
function test_fail() {
|
|
|
|
ok(false, "Reloading should not have hidden the notification");
|
|
|
|
}
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
PopupNotifications.panel.addEventListener("popuphiding", test_fail, false);
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.addEventListener("load", function() {
|
|
|
|
if (gBrowser.currentURI.spec != TESTROOT2 + "enabled.html")
|
|
|
|
return;
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.removeEventListener("load", arguments.callee, true);
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
PopupNotifications.panel.removeEventListener("popuphiding", test_fail, false);
|
2010-07-29 15:59:55 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending install");
|
|
|
|
aInstalls[0].cancel();
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
}, true);
|
|
|
|
gBrowser.loadURI(TESTROOT2 + "enabled.html");
|
|
|
|
});
|
|
|
|
|
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-07-29 15:59:55 -07:00
|
|
|
});
|
2010-08-13 10:47:17 -07:00
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"Unsigned XPI": "unsigned.xpi"
|
2010-08-13 10:47:17 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-08-13 10:47:17 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_theme() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-08-13 10:47:17 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "Should have seen the install complete");
|
|
|
|
is(notification.button.label, "Restart Now", "Should have seen the right button");
|
|
|
|
is(notification.getAttribute("label"),
|
|
|
|
"Theme Test will be installed after you restart " + gApp + ".",
|
|
|
|
"Should have seen the right message");
|
2010-09-07 12:20:12 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
2010-09-07 12:20:12 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAddonByID("{972ce4c6-7e08-4474-a285-3208198ce6fd}", function(aAddon) {
|
|
|
|
ok(aAddon.userDisabled, "Should be switching away from the default theme.");
|
|
|
|
// Undo the pending theme switch
|
|
|
|
aAddon.userDisabled = false;
|
2010-09-07 12:20:12 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
AddonManager.getAddonByID("theme-xpi@tests.mozilla.org", function(aAddon) {
|
|
|
|
isnot(aAddon, null, "Test theme will have been installed");
|
|
|
|
aAddon.uninstall();
|
|
|
|
|
|
|
|
runNextTest();
|
|
|
|
});
|
2010-09-07 12:20:12 -07:00
|
|
|
});
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
2010-08-13 10:47:17 -07:00
|
|
|
});
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
2010-08-26 16:01:28 -07:00
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
2010-10-21 14:44:02 -07:00
|
|
|
"Theme XPI": "theme.xpi"
|
2010-08-26 16:01:28 -07:00
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_renotify_blocked() {
|
2010-08-26 16:01:28 -07:00
|
|
|
// Wait for the blocked notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2010-08-27 19:41:41 -07:00
|
|
|
is(notification.id, "addon-install-blocked-notification", "Should have seen the install blocked");
|
2010-08-26 16:01:28 -07:00
|
|
|
|
|
|
|
aPanel.addEventListener("popuphidden", function () {
|
|
|
|
aPanel.removeEventListener("popuphidden", arguments.callee, false);
|
|
|
|
info("Timeouts after this probably mean bug 589954 regressed");
|
|
|
|
executeSoon(function () {
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2010-08-27 19:41:41 -07:00
|
|
|
is(notification.id, "addon-install-blocked-notification",
|
2010-08-26 16:01:28 -07:00
|
|
|
"Should have seen the install blocked - 2nd time");
|
|
|
|
|
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 2, "Should be two pending installs");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
aInstalls[1].cancel();
|
|
|
|
|
|
|
|
info("Closing browser tab");
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-08-26 16:01:28 -07:00
|
|
|
});
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
// hide the panel (this simulates the user dismissing it)
|
|
|
|
aPanel.hidePopup();
|
|
|
|
});
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"XPI": "unsigned.xpi"
|
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-10-21 14:44:02 -07:00
|
|
|
},
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
function test_renotify_installed() {
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "Should have seen the install complete");
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Dismiss the notification
|
|
|
|
aPanel.addEventListener("popuphidden", function () {
|
|
|
|
aPanel.removeEventListener("popuphidden", arguments.callee, false);
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Install another
|
|
|
|
executeSoon(function () {
|
|
|
|
// Wait for the progress notification
|
2010-08-26 16:01:28 -07:00
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
2011-01-03 11:40:47 -08:00
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
info("Timeouts after this probably mean bug 589954 regressed");
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "Should have seen the second install complete");
|
|
|
|
|
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 1, "Should be one pending installs");
|
|
|
|
aInstalls[0].cancel();
|
|
|
|
|
|
|
|
gBrowser.removeTab(gBrowser.selectedTab);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
aWindow.document.documentElement.acceptDialog();
|
2010-08-26 16:01:28 -07:00
|
|
|
});
|
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-08-26 16:01:28 -07:00
|
|
|
});
|
2011-01-03 11:40:47 -08:00
|
|
|
}, false);
|
2010-08-26 16:01:28 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// hide the panel (this simulates the user dismissing it)
|
|
|
|
aPanel.hidePopup();
|
|
|
|
});
|
|
|
|
|
|
|
|
aWindow.document.documentElement.acceptDialog();
|
2010-08-26 16:01:28 -07:00
|
|
|
});
|
2011-01-03 11:40:47 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"XPI": "unsigned.xpi"
|
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
|
|
|
},
|
|
|
|
|
|
|
|
function test_cancel_restart() {
|
|
|
|
// Wait for the progress notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
2011-01-07 09:16:35 -08:00
|
|
|
|
|
|
|
// 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");
|
2011-01-03 11:40:47 -08:00
|
|
|
let button = document.getAnonymousElementByAttribute(notification, "anonid", "cancel");
|
2010-10-21 14:44:02 -07:00
|
|
|
|
2011-01-03 11:40:47 -08:00
|
|
|
// Cancel the download
|
|
|
|
EventUtils.synthesizeMouse(button, 2, 2, {});
|
|
|
|
|
|
|
|
// Downloads cannot be restarted synchronously, bug 611755
|
|
|
|
executeSoon(function() {
|
|
|
|
// Notification should have changed to cancelled
|
|
|
|
notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-cancelled-notification", "Should have seen the cancelled notification");
|
|
|
|
|
|
|
|
// Restart the download
|
|
|
|
EventUtils.synthesizeMouse(notification.button, 20, 10, {});
|
|
|
|
|
|
|
|
// Should be back to a progress notification
|
2011-01-07 09:16:35 -08:00
|
|
|
ok(PopupNotifications.isPanelOpen, "Notification should still be open");
|
|
|
|
is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
|
2011-01-03 11:40:47 -08:00
|
|
|
notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-progress-notification", "Should have seen the progress notification");
|
|
|
|
|
|
|
|
// Wait for the install confirmation dialog
|
|
|
|
wait_for_install_dialog(function(aWindow) {
|
|
|
|
// Wait for the complete notification
|
|
|
|
wait_for_notification(function(aPanel) {
|
|
|
|
let notification = aPanel.childNodes[0];
|
|
|
|
is(notification.id, "addon-install-complete-notification", "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);
|
|
|
|
Services.perms.remove("example.com", "install");
|
|
|
|
runNextTest();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
aWindow.document.documentElement.acceptDialog();
|
|
|
|
});
|
|
|
|
});
|
2010-08-26 16:01:28 -07:00
|
|
|
});
|
2010-10-21 14:44:02 -07:00
|
|
|
|
|
|
|
var pm = Services.perms;
|
|
|
|
pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
|
|
|
|
|
|
|
|
var triggers = encodeURIComponent(JSON.stringify({
|
|
|
|
"XPI": "unsigned.xpi"
|
|
|
|
}));
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
2010-07-01 09:23:11 -07:00
|
|
|
}
|
2010-07-30 08:36:35 -07:00
|
|
|
];
|
|
|
|
|
2010-10-14 16:15:26 -07:00
|
|
|
var gTestStart = null;
|
|
|
|
|
2010-07-30 08:36:35 -07:00
|
|
|
function runNextTest() {
|
2010-10-14 16:15:26 -07:00
|
|
|
if (gTestStart)
|
|
|
|
info("Test part took " + (Date.now() - gTestStart) + "ms");
|
|
|
|
|
2010-07-30 08:36:35 -07:00
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
is(aInstalls.length, 0, "Should be no active installs");
|
|
|
|
|
|
|
|
if (TESTS.length == 0) {
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info("Running " + TESTS[0].name);
|
2010-10-14 16:15:26 -07:00
|
|
|
gTestStart = Date.now();
|
2010-07-30 08:36:35 -07:00
|
|
|
TESTS.shift()();
|
|
|
|
});
|
|
|
|
};
|
2010-07-01 09:23:11 -07:00
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
var XPInstallObserver = {
|
|
|
|
observe: function (aSubject, aTopic, aData) {
|
|
|
|
var installInfo = aSubject.QueryInterface(Components.interfaces.amIWebInstallInfo);
|
|
|
|
info("Observed " + aTopic + " for " + installInfo.installs.length + " installs");
|
|
|
|
installInfo.installs.forEach(function(aInstall) {
|
|
|
|
info("Install of " + aInstall.sourceURI.spec + " was in state " + aInstall.state);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-01 09:23:11 -07:00
|
|
|
function test() {
|
2010-11-01 11:50:34 -07:00
|
|
|
requestLongerTimeout(4);
|
2010-07-01 09:23:11 -07:00
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2010-07-29 15:59:39 -07:00
|
|
|
Services.prefs.setBoolPref("extensions.logging.enabled", true);
|
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
|
|
|
|
Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
|
|
|
|
Services.obs.addObserver(XPInstallObserver, "addon-install-failed", false);
|
|
|
|
Services.obs.addObserver(XPInstallObserver, "addon-install-complete", false);
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
2010-10-26 11:46:05 -07:00
|
|
|
// Make sure no more test parts run in case we were timed out
|
|
|
|
TESTS = [];
|
|
|
|
|
|
|
|
AddonManager.getAllInstalls(function(aInstalls) {
|
|
|
|
aInstalls.forEach(function(aInstall) {
|
|
|
|
aInstall.cancel();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-10-21 14:44:02 -07:00
|
|
|
Services.prefs.clearUserPref("extensions.logging.enabled");
|
|
|
|
|
|
|
|
Services.obs.removeObserver(XPInstallObserver, "addon-install-started");
|
|
|
|
Services.obs.removeObserver(XPInstallObserver, "addon-install-blocked");
|
|
|
|
Services.obs.removeObserver(XPInstallObserver, "addon-install-failed");
|
|
|
|
Services.obs.removeObserver(XPInstallObserver, "addon-install-complete");
|
|
|
|
});
|
|
|
|
|
2010-07-01 09:23:11 -07:00
|
|
|
runNextTest();
|
|
|
|
}
|