Backed out changeset e464e1369480 from bug 596336 due to test failures

This commit is contained in:
Dave Townsend 2010-10-11 17:17:55 -07:00
parent d83ee0af56
commit 3688e026d9
9 changed files with 52 additions and 495 deletions

View File

@ -310,11 +310,12 @@ var gEventManager = {
},
delegateInstallEvent: function(aEvent, aParams) {
var existingAddon = aEvent == "onExternalInstall" ? aParams[1] : aParams[0].existingAddon;
// If the install is an update then send the event to all listeners
// registered for the existing add-on
if (existingAddon)
this.delegateAddonEvent(aEvent, [existingAddon].concat(aParams));
var install = aParams[0];
if (install.existingAddon) {
// install is an update
let addon = install.existingAddon;
this.delegateAddonEvent(aEvent, [addon].concat(aParams));
}
for (let i = 0; i < this._installListeners.length; i++) {
let listener = this._installListeners[i];
@ -1799,10 +1800,6 @@ var gListView = {
if (this._types.indexOf(aAddon.type) == -1)
return;
// The existing list item will take care of upgrade installs
if (aExistingAddon)
return;
var item = createItem(aAddon, false);
this._listBox.insertBefore(item, this._listBox.firstChild);
},
@ -1888,7 +1885,8 @@ var gDetailView = {
this._addon = aAddon;
gEventManager.registerAddonListener(this, aAddon.id);
gEventManager.registerInstallListener(this);
if (aAddon.install)
gEventManager.registerInstallListener(this);
this.node.setAttribute("type", aAddon.type);
@ -2189,17 +2187,6 @@ var gDetailView = {
}
},
onExternalInstall: function(aAddon, aExistingAddon, aNeedsRestart) {
// Only care about upgrades for the currently displayed add-on
if (!aExistingAddon || aExistingAddon.id != this._addon.id)
return;
if (!aNeedsRestart)
this._updateView(aAddon, false);
else
this.updateState();
},
onInstallCancelled: function(aInstall) {
if (aInstall.addon.id == this._addon.id)
gViewController.popState();

View File

@ -844,12 +844,50 @@
<implementation>
<constructor><![CDATA[
this._installStatus.mControl = this;
this._installStatus.mAddon = this.mAddon;
this.setAttribute("contextmenu", "addonitem-popup");
this._showStatus("none");
this._updateDates();
this._updateState();
this._initWithAddon(this.mAddon);
var iconURL = this.mAddon.iconURL;
if (iconURL)
this._icon.src = iconURL;
if (this.mAddon.version)
this._version.value = this.mAddon.version;
else
this._version.hidden = true;
this._creator.setCreator(this.mAddon.creator);
if (this.mAddon.description)
this._description.value = this.mAddon.description;
else
this._description.hidden = true;
if (this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DISABLE ||
(this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DEFAULT &&
!AddonManager.autoUpdateDefault)) {
var self = this;
AddonManager.getAllInstalls(function(aInstallsList) {
// This can return after the binding has been destroyed,
// so try to detect that and return early
if (!("onNewInstall" in self))
return;
for (let i = 0; i < aInstallsList.length; i++) {
let install = aInstallsList[i];
if (install.existingAddon &&
install.existingAddon.id == self.mAddon.id &&
install.state == AddonManager.STATE_AVAILABLE) {
self.onNewInstall(install);
self.onIncludeUpdateChanged();
}
}
});
}
gEventManager.registerAddonListener(this, this.mAddon.id);
]]></constructor>
@ -998,63 +1036,6 @@
]]></setter>
</property>
<method name="_initWithAddon">
<parameter name="aAddon"/>
<body><![CDATA[
this.mAddon = aAddon;
this._installStatus.mAddon = this.mAddon;
this._updateDates();
this._updateState();
this.setAttribute("name", aAddon.name);
if (aAddon.size)
this.setAttribute("size", aAddon.size);
else
this.removeAttribute("size");
var iconURL = this.mAddon.iconURL;
if (iconURL)
this._icon.src = iconURL;
else
this._icon.src = null;
if (this.mAddon.version)
this._version.value = this.mAddon.version;
else
this._version.hidden = true;
this._creator.setCreator(this.mAddon.creator);
if (this.mAddon.description)
this._description.value = this.mAddon.description;
else
this._description.hidden = true;
if (this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DISABLE ||
(this.mAddon.applyBackgroundUpdates == AddonManager.AUTOUPDATE_DEFAULT &&
!AddonManager.autoUpdateDefault)) {
var self = this;
AddonManager.getAllInstalls(function(aInstallsList) {
// This can return after the binding has been destroyed,
// so try to detect that and return early
if (!("onNewInstall" in self))
return;
for (let i = 0; i < aInstallsList.length; i++) {
let install = aInstallsList[i];
if (install.existingAddon &&
install.existingAddon.id == self.mAddon.id &&
install.state == AddonManager.STATE_AVAILABLE) {
self.onNewInstall(install);
self.onIncludeUpdateChanged();
}
}
});
}
]]></body>
</method>
<method name="_showStatus">
<parameter name="aType"/>
<body><![CDATA[
@ -1085,13 +1066,10 @@
);
}
if (this.mAddon.updateDate) {
if (this.mAddon.updateDate)
this._dateUpdated.value = formatDate(this.mAddon.updateDate);
this.setAttribute("dateUpdated", this.mAddon.updateDate.getTime() / 1000);
} else {
else
this._dateUpdated.value = this._dateUpdated.getAttribute("unknown");
this.removeAttribute("dateUpdated");
}
]]></body>
</method>
@ -1434,23 +1412,6 @@
]]></body>
</method>
<method name="onExternalInstall">
<parameter name="aAddon"/>
<parameter name="aExistingAddon"/>
<parameter name="aNeedsRestart"/>
<body><![CDATA[
if (aExistingAddon.id != this.mAddon.id)
return;
// If the install completed without needing a restart then switch to
// using the new Addon
if (!aNeedsRestart)
this._initWithAddon(aAddon);
else
this._updateState();
]]></body>
</method>
<method name="onNewInstall">
<parameter name="aInstall"/>
<body><![CDATA[
@ -1483,15 +1444,8 @@
</method>
<method name="onInstallEnded">
<parameter name="aInstall"/>
<parameter name="aAddon"/>
<body><![CDATA[
// If the install completed without needing a restart then switch to
// using the new Addon
if (!(aAddon.pendingOperations & AddonManager.PENDING_INSTALL))
this._initWithAddon(aAddon);
else
this._updateState();
this._updateState();
]]></body>
</method>
</implementation>
@ -1505,6 +1459,7 @@
<!-- Addon - uninstalled - An uninstalled addon that can be re-installed. -->
<!-- XXXunf this doesn't take into account restart-less uninstalls. bug 561263 -->
<binding id="addon-uninstalled"
extends="chrome://mozapps/content/extensions/extensions.xml#addon-base">
<content>
@ -1567,51 +1522,6 @@
this.removeAttribute("pending");
]]></body>
</method>
<method name="onExternalInstall">
<parameter name="aAddon"/>
<parameter name="aExistingAddon"/>
<parameter name="aNeedsRestart"/>
<body><![CDATA[
if (aExistingAddon.id != this.mAddon.id)
return;
// Make sure any newly installed add-on has the correct disabled state
if (this.hasAttribute("wasDisabled"))
aAddon.userDisabled = this.getAttribute("wasDisabled") == "true";
// If the install completed without needing a restart then switch to
// using the new Addon
if (!aNeedsRestart)
this.mAddon = aAddon;
this.removeAttribute("restartrequired");
this.removeAttribute("pending");
]]></body>
</method>
<method name="onInstallStarted">
<parameter name="aInstall"/>
<body><![CDATA[
// Make sure any newly installed add-on has the correct disabled state
if (this.hasAttribute("wasDisabled"))
aInstall.addon.userDisabled = this.getAttribute("wasDisabled") == "true";
]]></body>
</method>
<method name="onInstallEnded">
<parameter name="aInstall"/>
<parameter name="aAddon"/>
<body><![CDATA[
// If the install completed without needing a restart then switch to
// using the new Addon
if (!(aAddon.pendingOperations & AddonManager.PENDING_INSTALL))
this.mAddon = aAddon;
this.removeAttribute("restartrequired");
this.removeAttribute("pending");
]]></body>
</method>
</implementation>
</binding>

View File

@ -64,7 +64,6 @@ _TEST_FILES = \
browser_bug587970.js \
browser_bug591465.js \
browser_bug591465.xml \
browser_bug596336.js \
browser_details.js \
browser_discovery.js \
browser_dragdrop.js \

View File

@ -1,23 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:bootstrap>true</em:bootstrap>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Bootstrap upgrade test</em:name>
</Description>
</RDF>

View File

@ -1,23 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon1@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:bootstrap>true</em:bootstrap>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Bootstrap upgrade test</em:name>
</Description>
</RDF>

View File

@ -1,192 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that upgrading bootstrapped add-ons behaves correctly while the
// manager is open
var gManagerWindow;
var gCategoryUtilities;
function test() {
waitForExplicitFinish();
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
run_next_test();
});
}
function end_test() {
close_manager(gManagerWindow, function() {
finish();
});
}
function get_list_item_count() {
let view = gManagerWindow.document.getElementById("view-port").selectedPanel;
let listid = view.id == "search-view" ? "search-list" : "addon-list";
let list = gManagerWindow.document.getElementById(listid);
let count = list.childNodes.length;
// Remove the show all results item
if (view.id == "search-view")
count--;
return count;
}
function get_node(parent, anonid) {
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
}
function get_class_node(parent, cls) {
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "class", cls);
}
function install_addon(aXpi, aCallback) {
AddonManager.getInstallForURL(TESTROOT + "addons/" + aXpi + ".xpi",
function(aInstall) {
aInstall.addListener({
onInstallEnded: function(aInstall) {
executeSoon(aCallback);
}
});
aInstall.install();
}, "application/x-xpinstall");
}
function check_addon(aAddon, version) {
is(get_list_item_count(), 1, "Should be one item in the list");
is(aAddon.version, version, "Add-on should have the right version");
let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
ok(!!item, "Should see the add-on in the list");
// Force XBL to apply
item.clientTop;
is(get_node(item, "version").value, version, "Version should be correct");
if (aAddon.userDisabled)
is_element_visible(get_class_node(item, "disabled-postfix"), "Disabled postfix should be hidden");
else
is_element_hidden(get_class_node(item, "disabled-postfix"), "Disabled postfix should be hidden");
}
// Install version 1 then upgrade to version 2 with the manager open
add_test(function() {
install_addon("browser_bug596336_1", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "1.0");
ok(!aAddon.userDisabled, "Add-on should not be disabled");
install_addon("browser_bug596336_2", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "2.0");
ok(!aAddon.userDisabled, "Add-on should not be disabled");
aAddon.uninstall();
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
});
});
});
// Install version 1 mark it as disabled then upgrade to version 2 with the
// manager open
add_test(function() {
install_addon("browser_bug596336_1", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
aAddon.userDisabled = true;
check_addon(aAddon, "1.0");
ok(aAddon.userDisabled, "Add-on should be disabled");
install_addon("browser_bug596336_2", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "2.0");
ok(aAddon.userDisabled, "Add-on should be disabled");
aAddon.uninstall();
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
});
});
});
// Install version 1 click the remove button and then upgrade to version 2 with
// the manager open
add_test(function() {
install_addon("browser_bug596336_1", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "1.0");
ok(!aAddon.userDisabled, "Add-on should not be disabled");
let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
EventUtils.synthesizeMouse(get_node(item, "remove-btn"), 2, 2, { }, gManagerWindow);
// Force XBL to apply
item.clientTop;
ok(aAddon.userDisabled, "Add-on should be disabled");
ok(!aAddon.pendingUninstall, "Add-on should not be pending uninstall");
is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
install_addon("browser_bug596336_2", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "2.0");
ok(!aAddon.userDisabled, "Add-on should not be disabled");
aAddon.uninstall();
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
});
});
});
// Install version 1, disable it, click the remove button and then upgrade to
// version 2 with the manager open
add_test(function() {
install_addon("browser_bug596336_1", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
aAddon.userDisabled = true;
check_addon(aAddon, "1.0");
ok(aAddon.userDisabled, "Add-on should be disabled");
let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
EventUtils.synthesizeMouse(get_node(item, "remove-btn"), 2, 2, { }, gManagerWindow);
// Force XBL to apply
item.clientTop;
ok(aAddon.userDisabled, "Add-on should be disabled");
ok(!aAddon.pendingUninstall, "Add-on should not be pending uninstall");
is_element_visible(get_class_node(item, "pending"), "Pending message should be visible");
install_addon("browser_bug596336_2", function() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
check_addon(aAddon, "2.0");
ok(aAddon.userDisabled, "Add-on should be disabled");
aAddon.uninstall();
is(get_list_item_count(), 0, "Should be no items in the list");
run_next_test();
});
});
});
});
});

View File

@ -639,59 +639,3 @@ add_test(function() {
});
});
});
// Tests that upgrades with onExternalInstall apply immediately
add_test(function() {
open_details("addon1@tests.mozilla.org", "extension", function() {
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "Test add-on replacement",
version: "2.5",
description: "Short description replacement",
fullDescription: "Longer description replacement",
type: "extension",
iconURL: "chrome://foo/skin/icon.png",
icon64URL: "chrome://foo/skin/icon264.png",
sourceURI: Services.io.newURI("http://example.com/foo", null, null),
averageRating: 2,
optionsURL: "chrome://foo/content/options.xul",
applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE,
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}]);
is(get("detail-name").value, "Test add-on replacement", "Name should be correct");
is_element_visible(get("detail-version"), "Version should not be hidden");
is(get("detail-version").value, "2.5", "Version should be correct");
is(get("detail-icon").src, "chrome://foo/skin/icon264.png", "Icon should be correct");
is_element_hidden(get("detail-creator"), "Creator should be hidden");
is_element_hidden(get("detail-screenshot"), "Screenshot should be hidden");
is(get("detail-desc").textContent, "Longer description replacement", "Description should be correct");
is_element_hidden(get("detail-contributions"), "Contributions section should be hidden");
is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden");
is_element_visible(get("detail-rating-row"), "Rating row should not be hidden");
is_element_visible(get("detail-rating"), "Rating should not be hidden");
is(get("detail-rating").averageRating, 2, "Rating should be correct");
is_element_hidden(get("detail-reviews"), "Reviews should be hidden");
is_element_hidden(get("detail-homepage-row"), "Homepage should be hidden");
is_element_hidden(get("detail-size"), "Size should be hidden");
is_element_hidden(get("detail-downloads"), "Downloads should be hidden");
is_element_visible(get("detail-prefs"), "Preferences button should be visible");
is_element_hidden(get("detail-enable"), "Enable button should be hidden");
is_element_visible(get("detail-disable"), "Disable button should be visible");
is_element_visible(get("detail-uninstall"), "Remove button should be visible");
is_element_hidden(get("detail-warning"), "Warning message should be hidden");
is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
is_element_hidden(get("detail-error"), "Error message should be hidden");
is_element_hidden(get("detail-pending"), "Pending message should be hidden");
run_next_test();
});
});

View File

@ -536,43 +536,3 @@ add_test(function() {
run_next_test();
});
});
// Check that upgrades with onExternalInstall take effect immediately
add_test(function() {
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "Test add-on replacement",
version: "2.0",
description: "A test add-on with a new description",
updateDate: gDate,
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}]);
let items = get_test_items();
is(items.length, 7, "Should be seven add-ons installed");
let addon = items[0];
addon.parentNode.ensureElementIsVisible(addon);
is(get_node(addon, "name").value, "Test add-on replacement", "Name should be correct");
is_element_visible(get_node(addon, "version"), "Version should be visible");
is(get_node(addon, "version").value, "2.0", "Version should be correct");
is_element_visible(get_node(addon, "description"), "Description should be visible");
is(get_node(addon, "description").value, "A test add-on with a new description", "Description should be correct");
is_element_hidden(get_node(addon, "creator"), "Creator should be hidden");
is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
is(Date.parse(get_node(addon, "date-updated").value), gDate.getTime(), "Update date should be correct");
is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
run_next_test();
});

View File

@ -400,11 +400,6 @@ MockProvider.prototype = {
* The add-on to add
*/
addAddon: function MP_addAddon(aAddon) {
var oldAddons = this.addons.filter(function(aOldAddon) aOldAddon.id == aAddon.id);
var oldAddon = oldAddons.length > 0 ? oldAddons[0] : null;
this.addons = this.addons.filter(function(aOldAddon) aOldAddon.id != aAddon.id);
this.addons.push(aAddon);
aAddon._provider = this;
@ -414,7 +409,7 @@ MockProvider.prototype = {
let requiresRestart = (aAddon.operationsRequiringRestart &
AddonManager.OP_NEEDS_RESTART_INSTALL) != 0;
AddonManagerPrivate.callInstallListeners("onExternalInstall", null, aAddon,
oldAddon, requiresRestart)
null, requiresRestart)
},
/**