Bug 557956: Update compatibility information for installed add-ons when the application is upgraded. r=robstrong, a=blocking-beta5

--HG--
rename : toolkit/mozapps/extensions/test/addons/test_bug542391_3/install.rdf => toolkit/mozapps/extensions/test/addons/test_bug542391_3_1/install.rdf
rename : toolkit/mozapps/extensions/test/addons/test_bug542391_3/install.rdf => toolkit/mozapps/extensions/test/addons/test_bug542391_3_2/install.rdf
rename : toolkit/mozapps/extensions/test/unit/test_bug542391.js => toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
This commit is contained in:
Dave Townsend 2010-08-17 12:08:33 -07:00
Родитель a43b78444b
Коммит 8a467c4514
29 изменённых файлов: 1442 добавлений и 669 удалений

Просмотреть файл

@ -1 +0,0 @@
<!ENTITY errors.title "Errors">

Просмотреть файл

@ -59,5 +59,3 @@
<!ENTITY clickFinish.label "Click Finish to continue starting &brandShortName;.">
<!ENTITY clickFinish.labelMac "Click Done to continue starting &brandShortName;.">
<!ENTITY enableChecking.label "Allow &brandShortName; to check for updates.">
<!ENTITY details.label "Details…">
<!ENTITY details.accesskey "D">

Просмотреть файл

@ -82,7 +82,6 @@
locale/@AB_CD@/mozapps/extensions/extensions.properties (%chrome/mozapps/extensions/extensions.properties)
locale/@AB_CD@/mozapps/extensions/blocklist.dtd (%chrome/mozapps/extensions/blocklist.dtd)
locale/@AB_CD@/mozapps/extensions/about.dtd (%chrome/mozapps/extensions/about.dtd)
locale/@AB_CD@/mozapps/extensions/errors.dtd (%chrome/mozapps/extensions/errors.dtd)
locale/@AB_CD@/mozapps/extensions/update.dtd (%chrome/mozapps/extensions/update.dtd)
locale/@AB_CD@/mozapps/extensions/update.properties (%chrome/mozapps/extensions/update.properties)
locale/@AB_CD@/mozapps/handling/handling.dtd (%chrome/mozapps/handling/handling.dtd)

Просмотреть файл

@ -64,11 +64,15 @@ const PREF_EM_UPDATE_URL = "extensions.update.url";
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_EM_DISABLED_ADDONS_LIST = "extensions.disabledAddons";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
const PREF_XPI_WHITELIST_PERMISSIONS = "xpinstall.whitelist.add";
const PREF_XPI_BLACKLIST_PERMISSIONS = "xpinstall.blacklist.add";
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const DIR_EXTENSIONS = "extensions";
const DIR_STAGE = "staged";
@ -979,8 +983,24 @@ var XPIProvider = {
bootstrappedAddons: {},
// A dictionary of JS scopes of loaded bootstrappable add-ons by ID
bootstrapScopes: {},
// True if the platform could have activated extensions
extensionsActive: false,
// True if all of the add-ons found during startup were installed in the
// application install location
allAppGlobal: true,
// A string listing the enabled add-ons for annotating crash reports
enabledAddons: null,
// An array of add-on IDs of add-ons that were inactive during startup
inactiveAddonIDs: [],
// A cache of the add-on IDs of add-ons that had changes performed to them
// during this session's startup. This is preliminary work, hopefully it will
// be expanded on in the future and an API made to get at it from the
// application.
startupChanges: {
// Add-ons that became disabled for compatibility reasons
appDisabled: []
},
/**
* Starts the XPI provider initializes the install locations and prefs.
@ -1091,6 +1111,24 @@ var XPIProvider = {
// Changes to installed extensions may have changed which theme is selected
this.applyThemeChange();
if (Services.prefs.prefHasUserValue(PREF_EM_DISABLED_ADDONS_LIST))
Services.prefs.clearUserPref(PREF_EM_DISABLED_ADDONS_LIST);
// If the application has been upgraded and there are add-ons outside the
// application directory then we may need to synchronize compatibility
// information
if (aAppChanged && !this.allAppGlobal) {
// Should we show a UI or just pass the list via a pref?
if (Prefs.getBoolPref(PREF_EM_SHOW_MISMATCH_UI, true)) {
this.showMismatchWindow();
}
else if (this.startupChanges.appDisabled.length > 0) {
// Remember the list of add-ons that were disabled this startup
Services.prefs.setCharPref(PREF_EM_DISABLED_ADDONS_LIST,
this.startupChanges.appDisabled.join(","));
}
}
this.enabledAddons = Prefs.getCharPref(PREF_EM_ENABLED_ADDONS, "");
if ("nsICrashReporter" in Ci &&
Services.appinfo instanceof Ci.nsICrashReporter) {
@ -1128,6 +1166,8 @@ var XPIProvider = {
Services.obs.removeObserver(this, "quit-application-granted");
}
}, "quit-application-granted", false);
this.extensionsActive = true;
},
/**
@ -1142,6 +1182,12 @@ var XPIProvider = {
this.bootstrappedAddons = {};
this.bootstrapScopes = {};
this.enabledAddons = null;
this.allAppGlobal = true;
for (let type in this.startupChanges)
this.startupChanges[type] = [];
this.inactiveAddonIDs = [];
// Get the list of IDs of add-ons that are pending update.
let updates = [i.addon.id for each (i in this.installs)
@ -1161,6 +1207,9 @@ var XPIProvider = {
this.installLocations = null;
this.installLocationsByName = null;
// This is needed to allow xpcshell tests to simulate a restart
this.extensionsActive = false;
},
/**
@ -1185,6 +1234,21 @@ var XPIProvider = {
Services.prefs.clearUserPref(PREF_DSS_SWITCHPENDING);
},
/**
* Shows the "Compatibility Updates" UI
*/
showMismatchWindow: function XPI_showMismatchWindow() {
var variant = Cc["@mozilla.org/variant;1"].
createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(this.inactiveAddonIDs);
// This *must* be modal as it has to block startup.
var features = "chrome,centerscreen,dialog,titlebar,modal";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
},
/**
* Adds a list of currently active add-ons to the next crash report.
*/
@ -1504,6 +1568,10 @@ var XPIProvider = {
let wasDisabled = aOldAddon.appDisabled || aOldAddon.userDisabled;
let isDisabled = appDisabled || userDisabled;
// Remember add-ons that became appDisabled by the application change
if (aOldAddon.visible && appDisabled && !aOldAddon.appDisabled)
XPIProvider.startupChanges.appDisabled.push(aOldAddon.id);
// If either property has changed update the database.
if (appDisabled != aOldAddon.appDisabled ||
userDisabled != aOldAddon.userDisabled) {
@ -1652,12 +1720,16 @@ var XPIProvider = {
return false;
}
// Visible bootstrapped add-ons need to have their install method called
if (newAddon.visible) {
// Note if any visible add-on is not in the application install location
if (newAddon._installLocation.name != KEY_APP_GLOBAL)
XPIProvider.allAppGlobal = false;
visibleAddons[newAddon.id] = newAddon;
if (!newAddon.bootstrap)
return true;
// Visible bootstrapped add-ons need to have their install method called
let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
dir.persistentDescriptor = aAddonState.descriptor;
XPIProvider.callBootstrapMethod(newAddon.id, newAddon.version, dir,
@ -1696,6 +1768,10 @@ var XPIProvider = {
let addonState = addonStates[aOldAddon.id];
delete addonStates[aOldAddon.id];
// Remember add-ons that were inactive during startup
if (aOldAddon.visible && !aOldAddon.active)
XPIProvider.inactiveAddonIDs.push(aOldAddon.id);
// The add-on has changed if the modification time has changed, or
// the directory it is installed in has changed or we have an
// updated manifest for it. Also reload the metadata for add-ons
@ -1713,6 +1789,8 @@ var XPIProvider = {
aOldAddon, addonState) ||
changed;
}
if (aOldAddon.visible && aOldAddon._installLocation.name != KEY_APP_GLOBAL)
XPIProvider.allAppGlobal = false;
}
else {
changed = removeMetadata(installLocation, aOldAddon) || changed;
@ -2165,6 +2243,11 @@ var XPIProvider = {
* @return true if the operation requires a restart
*/
enableRequiresRestart: function XPI_enableRequiresRestart(aAddon) {
// If the platform couldn't have activated extensions then we can make
// changes without any restart.
if (!this.extensionsActive)
return false;
// If the theme we're enabling is the skin currently selected then it doesn't
// require a restart to enable it.
if (aAddon.type == "theme")
@ -2182,6 +2265,11 @@ var XPIProvider = {
* @return true if the operation requires a restart
*/
disableRequiresRestart: function XPI_disableRequiresRestart(aAddon) {
// If the platform couldn't have activated up extensions then we can make
// changes without any restart.
if (!this.extensionsActive)
return false;
// This sounds odd but it is correct. Themes are only ever asked to disable
// after another theme has been enabled. Disabling the theme only requires
// a restart if enabling the other theme does too. If the selected skin doesn't
@ -2201,6 +2289,11 @@ var XPIProvider = {
* @return true if the operation requires a restart
*/
installRequiresRestart: function XPI_installRequiresRestart(aAddon) {
// If the platform couldn't have activated up extensions then we can make
// changes without any restart.
if (!this.extensionsActive)
return false;
// Themes not currently in use can be installed immediately
if (aAddon.type == "theme")
return aAddon.internalName == this.currentSkin ||
@ -2217,6 +2310,11 @@ var XPIProvider = {
* @return true if the operation requires a restart
*/
uninstallRequiresRestart: function XPI_uninstallRequiresRestart(aAddon) {
// If the platform couldn't have activated up extensions then we can make
// changes without any restart.
if (!this.extensionsActive)
return false;
// Themes not currently in use can be uninstalled immediately
if (aAddon.type == "theme")
return aAddon.internalName == this.currentSkin ||

Просмотреть файл

@ -1,112 +0,0 @@
<?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is The Extension Manager.
#
# The Initial Developer of the Original Code is
# Ben Goodger.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://mozapps/locale/extensions/errors.dtd">
<dialog id="errors"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&errors.title;"
onload="init()"
style="width: 40em;"
buttons="cancel">
<script type="application/javascript">
<![CDATA[
function LOG(string)
{
dump("*** " + string + "\n");
var console = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
console.logStringMessage(string);
}
function init()
{
var state = window.arguments[0].state;
var brandShortName = document.getElementById("brandStrings").getString("brandShortName");
var updateStrings = document.getElementById("updateStrings");
var str = updateStrings.getFormattedString(state + "Errors", [brandShortName]);
document.getElementById("intro").appendChild(document.createTextNode(str));
var xpinstallStrings = document.getElementById("xpinstallStrings");
var items = window.arguments[0].errors;
var listbox = document.getElementById("extensions");
for (var i = 0; i < items.length; ++i) {
if (items[i].error) {
if (items[i].error == -207) {
LOG("Error -207 (\"Not a valid install package\") generally implies\r\n" +
"a 404 at the URL specified for the update. Check for typos in\r\n" +
"your update manifest.");
}
var listitem = document.createElement("listitem");
try {
var errorString = xpinstallStrings.getString("error" + items[i].error);
var label = updateStrings.getFormattedString("installErrorItemFormat",
[items[i].name, errorString]);
}
catch (e) { label = items[i].name; }
listitem.setAttribute("label", label);
listbox.appendChild(listitem);
}
}
var strings = document.getElementById("updateStrings");
var cancel = document.documentElement.getButton("cancel");
cancel.label = strings.getString("closeButton");
cancel.focus();
}
]]>
</script>
<stringbundleset id="updateSet">
<stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
<stringbundle id="xpinstallStrings" src="chrome://global/locale/xpinstall/xpinstall.properties"/>
<stringbundle id="updateStrings" src="chrome://mozapps/locale/extensions/update.properties"/>
</stringbundleset>
<description id="intro"/>
<separator class="thin"/>
<listbox id="extensions" rows="7"/>
<separator class="thin"/>
</dialog>

Просмотреть файл

@ -38,68 +38,60 @@
// This UI is only opened from the Extension Manager when the app is upgraded.
const nsIExtensionManager = Components.interfaces.nsIExtensionManager;
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
const nsIAUCL = Components.interfaces.nsIAddonUpdateCheckListener;
const PREF_UPDATE_EXTENSIONS_ENABLED = "extensions.update.enabled";
const PREF_XPINSTALL_ENABLED = "xpinstall.enabled";
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var gUpdateWizard = {
// When synchronizing app compatibility info this contains all installed
// add-ons. When checking for compatible versions this contains only
// incompatible add-ons.
items: [],
// Contains a list of items that were disabled prior to the application
addons: [],
// Contains a list of add-ons that were disabled prior to the application
// upgrade.
inactiveItemIDs: [],
// The items that we found updates available for
itemsToUpdate: [],
inactiveAddonIDs: [],
// The add-ons that we found updates available for
addonsToUpdate: [],
shouldSuggestAutoChecking: false,
shouldAutoCheck: false,
xpinstallEnabled: false,
xpinstallEnabled: true,
xpinstallLocked: false,
init: function ()
{
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
// Retrieve all items in order to sync their app compatibility information
this.items = em.getItemList(nsIUpdateItem.TYPE_ANY);
this.inactiveItemIDs = window.arguments[0];
var pref =
Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
this.inactiveAddonIDs = window.arguments[0];
try {
this.shouldSuggestAutoChecking =
!pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED);
!Services.prefs.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED);
}
catch (e) {
}
try {
this.xpinstallEnabled = pref.getBoolPref(PREF_XPINSTALL_ENABLED);
this.xpinstallLocked = pref.prefIsLocked(PREF_XPINSTALL_ENABLED);
this.xpinstallEnabled = Services.prefs.getBoolPref(PREF_XPINSTALL_ENABLED);
this.xpinstallLocked = Services.prefs.prefIsLocked(PREF_XPINSTALL_ENABLED);
}
catch (e) {
}
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
if (ioService.offline)
document.documentElement.currentPage =
document.getElementById("offline");
else
document.documentElement.currentPage =
document.getElementById("versioninfo");
// Retrieve all add-ons in order to sync their app compatibility information
AddonManager.getAllAddons(function(aAddons) {
gUpdateWizard.addons = aAddons;
if (Services.io.offline)
document.documentElement.currentPage = document.getElementById("offline");
else
document.documentElement.currentPage = document.getElementById("versioninfo");
});
},
onWizardFinish: function ()
{
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
if (this.shouldSuggestAutoChecking)
pref.setBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED, this.shouldAutoCheck);
Services.prefs.setBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED, this.shouldAutoCheck);
},
_setUpButton: function (aButtonID, aButtonKey, aDisabled)
@ -129,22 +121,6 @@ var gUpdateWizard = {
/////////////////////////////////////////////////////////////////////////////
// Update Errors
errorItems: [],
showErrors: function (aState, aErrors)
{
openDialog("chrome://mozapps/content/extensions/errors.xul", "",
"modal", { state: aState, errors: aErrors });
},
// Displays a list of items that had an error during the update check. We
// don't display the actual error that occurred since
// nsIAddonUpdateCheckListener doesn't return the error details.
showUpdateCheckErrors: function ()
{
var errors = [];
for (var i = 0; i < this.errorItems.length; ++i)
errors.push({ name: this.errorItems[i].name, error: true });
this.showErrors("checking", errors);
},
checkForErrors: function (aElementIDToShow)
{
@ -154,10 +130,8 @@ var gUpdateWizard = {
onWizardClose: function (aEvent)
{
if (gInstallingPage._installing) {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.notifyObservers(null, "xpinstall-progress", "cancel");
if (gInstallingPage.installing) {
gInstallingPage.cancelInstalls();
return false;
}
return true;
@ -167,9 +141,7 @@ var gUpdateWizard = {
var gOfflinePage = {
onPageAdvanced: function ()
{
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
ioService.offline = false;
Services.io.offline = false;
return true;
},
@ -188,34 +160,23 @@ var gVersionInfoPage = {
gUpdateWizard.setButtonLabels(null, true,
"nextButtonText", true,
"cancelButtonText", false);
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
// Synchronize the app compatibility info for all items.
em.update([], 0, nsIExtensionManager.UPDATE_SYNC_COMPATIBILITY, this,
nsIExtensionManager.UPDATE_WHEN_NEW_APP_INSTALLED);
this._totalCount = gUpdateWizard.addons.length;
gUpdateWizard.addons.forEach(function(aAddon) {
aAddon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
}, this);
},
/////////////////////////////////////////////////////////////////////////////
// nsIAddonUpdateCheckListener
onUpdateStarted: function() {
this._totalCount = gUpdateWizard.items.length;
},
onUpdateEnded: function() {
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
// Retrieve the remaining incompatible items.
gUpdateWizard.items = em.getIncompatibleItemList(null, null,
nsIUpdateItem.TYPE_ANY,
true);
gUpdateWizard.items = gUpdateWizard.items.filter(function(item) {
return gUpdateWizard.inactiveItemIDs.indexOf(item.id) < 0;
onAllUpdatesFinished: function() {
// Filter out any add-ons that were disabled before the application was
// upgraded or are already compatible
gUpdateWizard.addons = gUpdateWizard.addons.filter(function(a) {
return a.appDisabled && gUpdateWizard.inactiveAddonIDs.indexOf(a.id) < 0;
});
if (gUpdateWizard.items.length > 0) {
if (gUpdateWizard.addons.length > 0) {
// There are still incompatible addons, inform the user.
document.documentElement.currentPage =
document.getElementById("mismatch");
document.documentElement.currentPage = document.getElementById("mismatch");
}
else {
// VersionInfo compatibility updates resolved all compatibility problems,
@ -226,44 +187,28 @@ var gVersionInfoPage = {
}
},
onAddonUpdateStarted: function(addon) {
},
onAddonUpdateEnded: function(addon, status) {
if (status == nsIAUCL.STATUS_VERSIONINFO) {
for (var i = 0; i < gUpdateWizard.items.length; ++i) {
var item = gUpdateWizard.items[i].QueryInterface(nsIUpdateItem);
if (addon.id == item.id) {
gUpdateWizard.items.splice(i, 1);
break;
}
}
}
else if (status == nsIAUCL.STATUS_FAILURE)
gUpdateWizard.errorItems.push(addon);
/////////////////////////////////////////////////////////////////////////////
// UpdateListener
onUpdateFinished: function(aAddon, status) {
if (status != AddonManager.UPDATE_STATUS_NO_ERROR)
gUpdateWizard.errorItems.push(aAddon);
++this._completeCount;
// Update the status text and progress bar
var updateStrings = document.getElementById("updateStrings");
var status = document.getElementById("versioninfo.status");
var statusString = updateStrings.getFormattedString("statusPrefix", [addon.name]);
var statusString = updateStrings.getFormattedString("statusPrefix", [aAddon.name]);
status.setAttribute("value", statusString);
// Update the status text and progress bar
var progress = document.getElementById("versioninfo.progress");
progress.mode = "normal";
progress.value = Math.ceil((this._completeCount / this._totalCount) * 100);
},
/////////////////////////////////////////////////////////////////////////////
// nsISupports
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.nsIAddonUpdateCheckListener) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
if (this._completeCount == this._totalCount)
this.onAllUpdatesFinished();
},
};
var gMismatchPage = {
@ -275,12 +220,11 @@ var gMismatchPage = {
document.documentElement.getButton("next").focus();
var incompatible = document.getElementById("mismatch.incompatible");
for (var i = 0; i < gUpdateWizard.items.length; ++i) {
var item = gUpdateWizard.items[i].QueryInterface(nsIUpdateItem);
gUpdateWizard.addons.forEach(function(aAddon) {
var listitem = document.createElement("listitem");
listitem.setAttribute("label", item.name + " " + item.version);
listitem.setAttribute("label", aAddon.name + " " + aAddon.version);
incompatible.appendChild(listitem);
}
});
}
};
@ -301,55 +245,43 @@ var gUpdatePage = {
gUpdateWizard.errorItems = [];
this._totalCount = gUpdateWizard.items.length;
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(nsIExtensionManager);
em.update(gUpdateWizard.items, this._totalCount,
nsIExtensionManager.UPDATE_CHECK_NEWVERSION, this,
nsIExtensionManager.UPDATE_WHEN_NEW_APP_INSTALLED);
this._totalCount = gUpdateWizard.addons.length;
gUpdateWizard.addons.forEach(function(aAddon) {
aAddon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
}, this);
},
/////////////////////////////////////////////////////////////////////////////
// nsIAddonUpdateCheckListener
onUpdateStarted: function() {
},
onUpdateEnded: function() {
onAllUpdatesFinished: function() {
var nextPage = document.getElementById("noupdates");
if (gUpdateWizard.itemsToUpdate.length > 0)
if (gUpdateWizard.addonsToUpdate.length > 0)
nextPage = document.getElementById("found");
document.documentElement.currentPage = nextPage;
},
onAddonUpdateStarted: function(addon) {
/////////////////////////////////////////////////////////////////////////////
// UpdateListener
onUpdateAvailable: function(aAddon, aInstall) {
gUpdateWizard.addonsToUpdate.push(aInstall);
},
onAddonUpdateEnded: function(addon, status) {
if (status == nsIAUCL.STATUS_UPDATE)
gUpdateWizard.itemsToUpdate.push(addon);
else if (status == nsIAUCL.STATUS_FAILURE)
gUpdateWizard.errorItems.push(addon);
onUpdateFinished: function(aAddon, status) {
if (status != AddonManager.UPDATE_STATUS_NO_ERROR)
gUpdateWizard.errorItems.push(aAddon);
++this._completeCount;
// Update the status text and progress bar
var updateStrings = document.getElementById("updateStrings");
var status = document.getElementById("checking.status");
var statusString = updateStrings.getFormattedString("statusPrefix", [addon.name]);
var statusString = updateStrings.getFormattedString("statusPrefix", [aAddon.name]);
status.setAttribute("value", statusString);
var progress = document.getElementById("checking.progress");
progress.value = Math.ceil((this._completeCount / this._totalCount) * 100);
},
/////////////////////////////////////////////////////////////////////////////
// nsISupports
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.nsIAddonUpdateCheckListener) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
if (this._completeCount == this._totalCount)
this.onAllUpdatesFinished()
},
};
var gFoundPage = {
@ -360,16 +292,13 @@ var gFoundPage = {
null, false);
var foundUpdates = document.getElementById("found.updates");
var itemCount = gUpdateWizard.itemsToUpdate.length;
for (var i = 0; i < itemCount; ++i) {
var item = gUpdateWizard.itemsToUpdate[i];
var listItem = foundUpdates.appendItem(item.name + " " + item.version,
item.xpiURL);
var itemCount = gUpdateWizard.addonsToUpdate.length;
gUpdateWizard.addonsToUpdate.forEach(function(aInstall) {
var listItem = foundUpdates.appendItem(aInstall.name + " " + aInstall.version);
listItem.setAttribute("type", "checkbox");
listItem.setAttribute("checked", "true");
listItem.setAttribute("URL", item.xpiURL);
listItem.setAttribute("hash", item.xpiHash);
}
listItem.install = aInstall;
});
if (!gUpdateWizard.xpinstallEnabled) {
document.getElementById("xpinstallDisabledAlert").hidden = false;
@ -418,21 +347,17 @@ var gFoundPage = {
};
var gInstallingPage = {
_installing : false,
_objs : [],
_installs : [],
_errors : [],
_strings : null,
_currentInstall : -1,
_installing : false,
onPageShow: function ()
{
gUpdateWizard.setButtonLabels(null, true,
"nextButtonText", true,
null, true);
// Get XPInstallManager and kick off download/install
// process, registering us as an observer.
var items = [];
var hashes = [];
this._objs = [];
this._errors = [];
var foundUpdates = document.getElementById("found.updates");
@ -440,58 +365,74 @@ var gInstallingPage = {
for (var i = 0; i < updates.length; ++i) {
if (!updates[i].checked)
continue;
items.push(updates[i].value);
hashes.push(updates[i].getAttribute("hash") ? updates[i].getAttribute("hash") : null);
this._objs.push({ name: updates[i].label });
this._installs.push(updates[i].install);
}
var xpimgr = Components.classes["@mozilla.org/xpinstall/install-manager;1"]
.createInstance(Components.interfaces.nsIXPInstallManager);
xpimgr.initManagerWithHashes(items, hashes, items.length, this);
this._strings = document.getElementById("updateStrings");
this._installing = true;
this.startNextInstall();
},
/////////////////////////////////////////////////////////////////////////////
// nsIXPIProgressDialog
onStateChange: function (aIndex, aState, aValue)
{
var strings = document.getElementById("updateStrings");
startNextInstall: function() {
if (this._currentInstall >= 0) {
this._installs[this._currentInstall].removeListener(this);
}
const nsIXPIProgressDialog = Components.interfaces.nsIXPIProgressDialog;
switch (aState) {
case nsIXPIProgressDialog.DOWNLOAD_START:
var label = strings.getFormattedString("downloadingPrefix", [this._objs[aIndex].name]);
var actionItem = document.getElementById("actionItem");
actionItem.value = label;
break;
case nsIXPIProgressDialog.DOWNLOAD_DONE:
case nsIXPIProgressDialog.INSTALL_START:
var label = strings.getFormattedString("installingPrefix", [this._objs[aIndex].name]);
var actionItem = document.getElementById("actionItem");
actionItem.value = label;
this._installing = true;
break;
case nsIXPIProgressDialog.INSTALL_DONE:
switch (aValue) {
case 999:
case 0:
break;
default:
this._errors.push({ name: this._objs[aIndex].name, error: aValue });
}
break;
case nsIXPIProgressDialog.DIALOG_CLOSE:
this._currentInstall++;
if (this._installs.length == this._currentInstall) {
this._installing = false;
var nextPage = this._errors.length > 0 ? "installerrors" : "finished";
document.getElementById("installing").setAttribute("next", nextPage);
document.documentElement.advance();
break;
return;
}
this._installs[this._currentInstall].addListener(this);
this._installs[this._currentInstall].install();
},
onProgress: function (aIndex, aValue, aMaxValue)
{
cancelInstalls: function() {
this._installs[this._currentInstall].removeListener(this);
this._installs[this._currentInstall].cancel();
},
/////////////////////////////////////////////////////////////////////////////
// InstallListener
onDownloadStarted: function(aInstall) {
var label = strings.getFormattedString("downloadingPrefix", [aInstall.name]);
var actionItem = document.getElementById("actionItem");
actionItem.value = label;
},
onDownloadProgress: function(aInstall) {
var downloadProgress = document.getElementById("downloadProgress");
downloadProgress.value = Math.ceil((aValue/aMaxValue) * 100);
downloadProgress.value = Math.ceil(100 * aInstall.progress / aInstall.maxProgress);
},
onDownloadEnded: function(aInstall) {
},
onDownloadFailed: function(aInstall) {
this._errors.push(aInstall);
this.startNextInstall();
},
onInstallStarted: function(aInstall) {
var label = strings.getFormattedString("installingPrefix", [aInstall.name]);
var actionItem = document.getElementById("actionItem");
actionItem.value = label;
},
onInstallEnded: function(aInstall) {
this.startNextInstall();
},
onInstallFailed: function(aInstall) {
this._errors.push(aInstall);
this.startNextInstall();
}
};
@ -501,11 +442,6 @@ var gInstallErrorsPage = {
gUpdateWizard.setButtonLabels(null, true, null, true, null, true);
document.documentElement.getButton("finish").focus();
},
onShowErrors: function ()
{
gUpdateWizard.showErrors("install", gInstallingPage._errors);
}
};
// Displayed when there are incompatible add-ons and the xpinstall.enabled

Просмотреть файл

@ -121,8 +121,6 @@
<hbox id="updateCheckErrorNotFound" class="alertBox" hidden="true" align="top">
<image id="alert"/>
<description flex="1">&noupdates.error.desc;</description>
<button label="&details.label;" accesskey="&details.accesskey;"
oncommand="gUpdateWizard.showUpdateCheckErrors();"/>
</hbox>
<separator class="thin"/>
<description id="noupdatesCheckEnabled" hidden="true">
@ -176,8 +174,6 @@
onpageshow="gInstallErrorsPage.onPageShow();">
<hbox align="top" class="alertBox">
<description flex="1">&installerrors.intro.label;</description>
<button label="&details.label;" accesskey="&details.accesskey;"
oncommand="gInstallErrorsPage.onShowErrors();"/>
</hbox>
<separator flex="1"/>
#ifndef XP_MACOSX

Просмотреть файл

@ -13,7 +13,6 @@ toolkit.jar:
* content/mozapps/extensions/blocklist.js (content/blocklist.js)
* content/mozapps/extensions/blocklist.css (content/blocklist.css)
* content/mozapps/extensions/blocklist.xml (content/blocklist.xml)
* content/mozapps/extensions/errors.xul (content/errors.xul)
* content/mozapps/extensions/update.xul (content/update.xul)
* content/mozapps/extensions/update.js (content/update.js)
* content/mozapps/extensions/eula.xul (content/eula.xul)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.9 KiB

Просмотреть файл

@ -0,0 +1,22 @@
<?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>bug542391_3@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>3</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Bug 542391 Test 3</em:name>
</Description>
</RDF>

Просмотреть файл

@ -48,6 +48,10 @@ include $(DEPTH)/config/autoconf.mk
_TEST_FILES = \
head.js \
browser_bug557943.js \
browser_bug557956.js \
browser_bug557956.rdf \
browser_bug557956_8_2.xpi \
browser_bug557956_9_2.xpi \
browser_bug562890.js \
browser_bug562899.js \
browser_bug562992.js \

Просмотреть файл

@ -0,0 +1,23 @@
<?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: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>Addon1</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon2@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon2</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon3</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -4,20 +4,20 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug511091@tests.mozilla.org</em:id>
<em:id>addon4@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Icon test</em:name>
<em:iconURL>chrome://foo/content/bar</em:iconURL>
<em:name>Addon4</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon5@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon5</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon6@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon6</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon7@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon7</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon8@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon8</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,23 @@
<?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>addon9@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon9</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -0,0 +1,397 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test that the compatibility dialog that normally displays during startup
// appears to work correctly.
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
/**
* Test add-ons:
*
* Addon minVersion maxVersion Notes
* addon1 0 *
* addon2 0 0
* addon3 0 0
* addon4 1 *
* addon5 0 0 Made compatible by update check
* addon6 0 0 Made compatible by update check
* addon7 0 0 Has a broken update available
* addon8 0 0 Has an update available
* addon9 0 0 Has an update available
*/
function test() {
waitForExplicitFinish();
run_next_test();
}
function end_test() {
Services.prefs.clearUserPref("extensions.update.url");
finish();
}
function install_test_addons(aCallback) {
var installs = [];
// Use a blank update URL
Services.prefs.setCharPref("extensions.update.url", TESTROOT + "missing.rdf");
["browser_bug557956_1",
"browser_bug557956_2",
"browser_bug557956_3",
"browser_bug557956_4",
"browser_bug557956_5",
"browser_bug557956_6",
"browser_bug557956_7",
"browser_bug557956_8_1",
"browser_bug557956_9_1"].forEach(function(aName) {
AddonManager.getInstallForURL(TESTROOT + "addons/" + aName + ".xpi", function(aInstall) {
installs.push(aInstall);
}, "application/x-xpinstall");
});
var listener = {
installCount: 0,
onInstallEnded: function() {
this.installCount++;
if (this.installCount == installs.length) {
// Switch to the test update URL
Services.prefs.setCharPref("extensions.update.url", TESTROOT + "browser_bug557956.rdf");
aCallback();
}
}
};
installs.forEach(function(aInstall) {
aInstall.addListener(listener);
aInstall.install();
});
}
function uninstall_test_addons(aCallback) {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"addon8@tests.mozilla.org",
"addon9@tests.mozilla.org"],
function(aAddons) {
aAddons.forEach(function(aAddon) {
if (aAddon)
aAddon.uninstall();
});
aCallback();
});
}
function open_compatibility_window(aInactiveAddonIds, aCallback) {
var variant = Cc["@mozilla.org/variant;1"].
createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(aInactiveAddonIds);
// Cannot be modal as we want to interract with it, shouldn't cause problems
// with testing though.
var features = "chrome,centerscreen,dialog,titlebar";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
win.addEventListener("load", function() {
win.removeEventListener("load", arguments.callee, false);
info("Compatibility dialog opened");
function page_shown(aEvent) {
info("Page " + aEvent.target.id + " shown");
}
win.addEventListener("pageshow", page_shown, false);
win.addEventListener("unload", function() {
win.removeEventListener("unload", arguments.callee, false);
win.removeEventListener("pageshow", page_shown, false);
info("Compatibility dialog closed");
}, false);
aCallback(win);
}, false);
}
function wait_for_window_close(aWindow, aCallback) {
aWindow.addEventListener("unload", function() {
aWindow.removeEventListener("unload", arguments.callee, false);
aCallback();
}, false);
}
function wait_for_page(aWindow, aPageId, aCallback) {
var page = aWindow.document.getElementById(aPageId);
page.addEventListener("pageshow", function() {
page.removeEventListener("pageshow", arguments.callee, false);
executeSoon(function() {
aCallback(aWindow);
});
}, false);
}
function get_list_names(aList) {
var items = [];
for (let i = 0; i < aList.childNodes.length; i++)
items.push(aList.childNodes[i].label);
items.sort();
return items;
}
// Tests that the right add-ons show up in the mismatch dialog and updates can
// be installed
add_test(function() {
install_test_addons(function() {
// These add-ons were inactive in the old application
var inactiveAddonIds = [
"addon2@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"
];
// Check that compatibility updates were applied.
AddonManager.getAddonsByIDs(["addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a5, a6]) {
ok(!a5.isCompatible, "addon5 should not be compatible");
ok(!a6.isCompatible, "addon6 should not be compatible");
open_compatibility_window(inactiveAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 4, "Should have seen 4 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible");
is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible");
is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible");
ok(a5.isCompatible, "addon5 should be compatible");
ok(a6.isCompatible, "addon5 should be compatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "found", function(aWindow) {
ok(doc.getElementById("xpinstallDisabledAlert").hidden,
"Install should be allowed");
var list = doc.getElementById("found.updates");
var items = get_list_names(list);
is(items.length, 3, "Should have seen 3 updates available");
is(items[0], "Addon7 2.0", "Should have seen update for addon7");
is(items[1], "Addon8 2.0", "Should have seen update for addon8");
is(items[2], "Addon9 2.0", "Should have seen update for addon9");
ok(!doc.documentElement.getButton("next").disabled,
"Next button should be enabled");
// Uncheck all
for (let i = 0; i < list.childNodes.length; i++)
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
ok(doc.documentElement.getButton("next").disabled,
"Next button should not be enabled");
// Check the ones we want to install
for (let i = 0; i < list.childNodes.length; i++) {
if (list.childNodes[i].label != "Addon7 2.0")
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "finished", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
AddonManager.getAddonsByIDs(["addon8@tests.mozilla.org",
"addon9@tests.mozilla.org"],
function([a8, a9]) {
is(a8.version, "2.0", "addon8 should have updated");
is(a9.version, "2.0", "addon9 should have updated");
uninstall_test_addons(run_next_test);
});
});
});
});
});
});
});
});
// Tests that the install failures show the install failed page and disabling
// xpinstall shows the right UI.
add_test(function() {
install_test_addons(function() {
// These add-ons were inactive in the old application
var inactiveAddonIds = [
"addon2@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"
];
Services.prefs.setBoolPref("xpinstall.enabled", false);
open_compatibility_window(inactiveAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 4, "Should have seen 4 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible");
is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible");
is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible");
// Check that compatibility updates were applied.
AddonManager.getAddonsByIDs(["addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"],
function([a5, a6]) {
ok(a5.isCompatible, "addon5 should be compatible");
ok(a6.isCompatible, "addon5 should be compatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "found", function(aWindow) {
ok(!doc.getElementById("xpinstallDisabledAlert").hidden,
"Install should not be allowed");
ok(doc.documentElement.getButton("next").disabled,
"Next button should be disabled");
var checkbox = doc.getElementById("enableXPInstall");
EventUtils.synthesizeMouse(checkbox, 2, 2, { }, aWindow);
ok(!doc.documentElement.getButton("next").disabled,
"Next button should be enabled");
var list = doc.getElementById("found.updates");
var items = get_list_names(list);
is(items.length, 3, "Should have seen 3 updates available");
is(items[0], "Addon7 2.0", "Should have seen update for addon7");
is(items[1], "Addon8 2.0", "Should have seen update for addon8");
is(items[2], "Addon9 2.0", "Should have seen update for addon9");
// Unheck the ones we don't want to install
for (let i = 0; i < list.childNodes.length; i++) {
if (list.childNodes[i].label != "Addon7 2.0")
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "installerrors", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
uninstall_test_addons(run_next_test);
});
});
});
});
});
});
});
// Tests that no add-ons show up in the mismatch dialog when they are all disabled
add_test(function() {
install_test_addons(function() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"addon8@tests.mozilla.org",
"addon9@tests.mozilla.org"],
function(aAddons) {
aAddons.forEach(function(aAddon) {
aAddon.userDisabled = true;
});
// These add-ons were inactive in the old application
var inactiveAddonIds = [
"addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"addon8@tests.mozilla.org",
"addon9@tests.mozilla.org"
];
open_compatibility_window(inactiveAddonIds, function(aWindow) {
// Should close immediately on its own
wait_for_window_close(aWindow, function() {
uninstall_test_addons(run_next_test);
});
});
});
});
});
// Tests that the right UI shows for when no updates are available
add_test(function() {
install_test_addons(function() {
AddonManager.getAddonsByIDs(["addon7@tests.mozilla.org",
"addon8@tests.mozilla.org",
"addon9@tests.mozilla.org"],
function(aAddons) {
aAddons.forEach(function(aAddon) {
aAddon.uninstall();
});
// These add-ons were inactive in the old application
var inactiveAddonIds = [
"addon2@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"
];
open_compatibility_window(inactiveAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 1, "Should have seen 1 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "noupdates", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
uninstall_test_addons(run_next_test);
});
});
});
});
});
});

Просмотреть файл

@ -0,0 +1,220 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:addon1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon3@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon4@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon6@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon7@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_7_2.xpi</em:updateLink>
<em:updateHash>sha1:18674cf7ad76664e0ead6280a43cc0c681180505</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon8@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi</em:updateLink>
<em:updateHash>sha1:d6240607c4f202226fa291d9b7e537ff2a309616</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:addon9@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi</em:updateLink>
<em:updateHash>sha1:b25d1ee94acc734a4a039d31c1620051bbbd5633</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

Двоичные данные
toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi Normal file

Двоичный файл не отображается.

Двоичные данные
toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -1,75 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Dave Townsend <dtownsend@oxymoronical.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*/
const ID = "bug511091@tests.mozilla.org";
const ADDON = "test_bug511091";
function run_test()
{
// Setup for test
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
// Install test add-on
startupEM();
gEM.installItemFromFile(do_get_addon(ADDON), NS_INSTALL_LOCATION_APPPROFILE);
var addon = gEM.getItemForID(ID);
do_check_neq(addon, null);
do_check_eq(getManifestProperty(ID, "iconURL"), "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png");
restartEM();
var location = gEM.getInstallLocation(ID);
var file = location.getItemFile(ID, "icon.png");
var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var addon = gEM.getItemForID(ID);
do_check_neq(addon, null);
var uri = ioservice.newURI(getManifestProperty(ID, "iconURL"), null, null);
uri.QueryInterface(Components.interfaces.nsIFileURL);
do_check_true(uri.file.equals(file));
gEM.disableItem(ID);
restartEM();
addon = gEM.getItemForID(ID);
do_check_neq(addon, null);
uri = ioservice.newURI(getManifestProperty(ID, "iconURL"), null, null);
uri.QueryInterface(Components.interfaces.nsIFileURL);
do_check_true(uri.file.equals(file));
shutdownEM();
}

Просмотреть файл

@ -1,271 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
*
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dave Townsend <dtownsend@oxymoronical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_EM_DISABLED_ADDONS_LIST = "extensions.disabledAddons";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
// This will be called to show the blocklist message, we just make it look like
// it was dismissed.
var WindowWatcher = {
expected: false,
arguments: null,
openWindow: function(parent, url, name, features, arguments) {
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
this.arguments = arguments.QueryInterface(Ci.nsIVariant);
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIWindowWatcher)
|| iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function isDisabled(id) {
return getManifestProperty(id, "isDisabled") == "true";
}
function appDisabled(id) {
return getManifestProperty(id, "appDisabled") == "true";
}
function userDisabled(id) {
return getManifestProperty(id, "userDisabled") == "true";
}
function check_state_v1() {
do_check_neq(gEM.getItemForID("bug542391_1@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_1@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_1@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_2@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_2@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_2@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_3@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_3@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_3@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_4@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_4@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_4@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_5@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_5@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_5@tests.mozilla.org"));
}
function check_state_v2() {
do_check_neq(gEM.getItemForID("bug542391_1@tests.mozilla.org"), null);
do_check_true(appDisabled("bug542391_1@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_1@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_2@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_2@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_2@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_3@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_3@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_3@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_4@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_4@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_4@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_5@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_5@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_5@tests.mozilla.org"));
}
function check_state_v3() {
do_check_neq(gEM.getItemForID("bug542391_1@tests.mozilla.org"), null);
do_check_true(appDisabled("bug542391_1@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_1@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_2@tests.mozilla.org"), null);
do_check_true(appDisabled("bug542391_2@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_2@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_3@tests.mozilla.org"), null);
do_check_true(appDisabled("bug542391_3@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_3@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_4@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_4@tests.mozilla.org"));
do_check_true(userDisabled("bug542391_4@tests.mozilla.org"));
do_check_neq(gEM.getItemForID("bug542391_5@tests.mozilla.org"), null);
do_check_false(appDisabled("bug542391_5@tests.mozilla.org"));
do_check_false(userDisabled("bug542391_5@tests.mozilla.org"));
}
// Install all the test add-ons, disable two of them and "upgrade" the app to
// version 2 which will appDisable one.
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
startupEM();
gEM.installItemFromFile(do_get_addon("test_bug542391_1"),
NS_INSTALL_LOCATION_APPPROFILE);
gEM.installItemFromFile(do_get_addon("test_bug542391_2"),
NS_INSTALL_LOCATION_APPPROFILE);
gEM.installItemFromFile(do_get_addon("test_bug542391_3"),
NS_INSTALL_LOCATION_APPPROFILE);
gEM.installItemFromFile(do_get_addon("test_bug542391_4"),
NS_INSTALL_LOCATION_APPPROFILE);
gEM.installItemFromFile(do_get_addon("test_bug542391_5"),
NS_INSTALL_LOCATION_APPPROFILE);
restartEM();
gEM.disableItem("bug542391_2@tests.mozilla.org");
gEM.disableItem("bug542391_4@tests.mozilla.org");
restartEM();
check_state_v1();
WindowWatcher.expected = true;
restartEM("2");
do_check_false(WindowWatcher.expected);
check_state_v2();
run_test_1();
}
// Upgrade to version 3 which will appDisable two more add-ons. Check that the
// 3 already disabled add-ons were passed to the mismatch dialog.
function run_test_1() {
WindowWatcher.expected = true;
restartEM("3");
do_check_false(WindowWatcher.expected);
check_state_v3();
// (Bug 547039) do_check_eq(WindowWatcher.arguments.length, 3);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_1@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_4@tests.mozilla.org") >= 0);
run_test_2();
}
// Downgrade to version 2 which will remove appDisable from two add-ons and
// should pass all 4 previously disabled add-ons.
function run_test_2() {
WindowWatcher.expected = true;
restartEM("2");
do_check_false(WindowWatcher.expected);
check_state_v2();
// (Bug 547039) do_check_eq(WindowWatcher.arguments.length, 4);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_1@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_3@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_4@tests.mozilla.org") >= 0);
run_test_4();
}
// Upgrade to version 3 which will appDisable two more add-ons.
function run_test_3() {
gPrefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, false);
restartEM("3");
check_state_v3();
var disabled = [];
try {
gPrefs.getCharPref(PREF_EM_DISABLED_ADDONS_LIST).split(",");
}
catch (e) {}
do_check_eq(disabled.length, 2);
do_check_true(disabled.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(disabled.indexOf("bug542391_3@tests.mozilla.org") >= 0);
gPrefs.clearUserPref(PREF_EM_DISABLED_ADDONS_LIST);
run_test_2();
}
// Downgrade to version 2 which will remove appDisable from two add-ons.
function run_test_4() {
restartEM("2");
check_state_v2();
var disabled = [];
try {
gPrefs.getCharPref(PREF_EM_DISABLED_ADDONS_LIST).split(",");
}
catch (e) {}
do_check_eq(disabled.length, 0);
finish_test();
}
function finish_test() {
gEM.uninstallItem("bug542391_1@tests.mozilla.org");
gEM.uninstallItem("bug542391_2@tests.mozilla.org");
gEM.uninstallItem("bug542391_3@tests.mozilla.org");
gEM.uninstallItem("bug542391_4@tests.mozilla.org");
gEM.uninstallItem("bug542391_5@tests.mozilla.org");
restartEM();
do_check_eq(gEM.getItemForID("bug542391_1@tests.mozilla.org"), null);
do_check_eq(gEM.getItemForID("bug542391_2@tests.mozilla.org"), null);
do_check_eq(gEM.getItemForID("bug542391_3@tests.mozilla.org"), null);
do_check_eq(gEM.getItemForID("bug542391_4@tests.mozilla.org"), null);
do_check_eq(gEM.getItemForID("bug542391_5@tests.mozilla.org"), null);
}

Просмотреть файл

@ -795,6 +795,9 @@ Services.prefs.setBoolPref("extensions.logging.enabled", true);
// By default only load extensions from the profile install location
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_PROFILE);
// Disable the compatibility updates window by default
Services.prefs.setBoolPref("extensions.showMismatchUI", false);
// Register a temporary directory for the tests.
const gTmpD = gProfD.clone();
gTmpD.append("temp");

Просмотреть файл

@ -0,0 +1,376 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
*
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dave Townsend <dtownsend@oxymoronical.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL
*
* ***** END LICENSE BLOCK *****
*/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_EM_DISABLED_ADDONS_LIST = "extensions.disabledAddons";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
var gInstallUpdate = false;
// This will be called to show the compatiiblity update dialog.
var WindowWatcher = {
expected: false,
arguments: null,
openWindow: function(parent, url, name, features, arguments) {
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
this.arguments = arguments.QueryInterface(AM_Ci.nsIVariant);
if (!gInstallUpdate)
return;
// Simulate installing an update while in the dialog
var installed = false;
installAllFiles([do_get_addon("test_bug542391_3_2")], function() {
installed = true;
});
// The dialog is meant to be opened modally and the install operation can be
// asynchronous, so we must spin an event loop (like the modal window does)
// until the install is complete
let thr = AM_Cc["@mozilla.org/thread-manager;1"].
getService(AM_Ci.nsIThreadManager).
mainThread;
while (!installed)
thr.processNextEvent(false);
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIWindowWatcher)
|| iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(iid);
}
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function check_state_v1([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_neq(a2, null);
do_check_false(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
}
function check_state_v2([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_neq(a2, null);
do_check_false(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
}
function check_state_v3([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_neq(a2, null);
do_check_true(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_neq(a3, null);
do_check_true(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
}
function check_state_v3_2([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_neq(a2, null);
do_check_true(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_eq(a3.version, "2.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
}
// Install all the test add-ons, disable two of them and "upgrade" the app to
// version 2 which will appDisable one.
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
startupManager();
installAllFiles([do_get_addon("test_bug542391_1"),
do_get_addon("test_bug542391_2"),
do_get_addon("test_bug542391_3_1"),
do_get_addon("test_bug542391_4"),
do_get_addon("test_bug542391_5")], function() {
restartManager();
AddonManager.getAddonsByIDs(["bug542391_2@tests.mozilla.org",
"bug542391_4@tests.mozilla.org"],
function([a2, a4]) {
a2.userDisabled = true;
a4.userDisabled = true;
restartManager();
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v1(addons);
WindowWatcher.expected = true;
restartManager("2");
do_check_false(WindowWatcher.expected);
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v2(addons);
run_test_1();
});
});
});
});
}
// Upgrade to version 3 which will appDisable two more add-ons. Check that the
// 3 already disabled add-ons were passed to the mismatch dialog.
function run_test_1() {
WindowWatcher.expected = true;
restartManager("3");
do_check_false(WindowWatcher.expected);
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v3(addons);
do_check_eq(WindowWatcher.arguments.length, 3);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_1@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_4@tests.mozilla.org") >= 0);
run_test_2();
});
}
// Downgrade to version 2 which will remove appDisable from two add-ons and
// should pass all 4 previously disabled add-ons.
function run_test_2() {
WindowWatcher.expected = true;
restartManager("2");
do_check_false(WindowWatcher.expected);
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v2(addons);
do_check_eq(WindowWatcher.arguments.length, 4);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_1@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_3@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_4@tests.mozilla.org") >= 0);
run_test_3();
});
}
// Upgrade to version 3 which will appDisable two more add-ons.
function run_test_3() {
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, false);
restartManager("3");
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v3(addons);
var disabled = [];
try {
disabled = Services.prefs.getCharPref(PREF_EM_DISABLED_ADDONS_LIST).split(",");
}
catch (e) {}
do_check_eq(disabled.length, 2);
do_check_true(disabled.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(disabled.indexOf("bug542391_3@tests.mozilla.org") >= 0);
Services.prefs.clearUserPref(PREF_EM_DISABLED_ADDONS_LIST);
run_test_4();
});
}
// Downgrade to version 2 which will remove appDisable from two add-ons.
function run_test_4() {
restartManager("2");
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v2(addons);
var disabled = [];
try {
disabled = Services.prefs.getCharPref(PREF_EM_DISABLED_ADDONS_LIST).split(",");
}
catch (e) {}
do_check_eq(disabled.length, 0);
run_test_5();
});
}
// Upgrade to version 3 which will appDisable two more add-ons. Check that when
// the upgrade dialog updates an add-on no restart is necessary
function run_test_5() {
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
gInstallUpdate = true;
WindowWatcher.expected = true;
restartManager("3");
do_check_false(WindowWatcher.expected);
AddonManager.getAddonsByIDs(["bug542391_1@tests.mozilla.org",
"bug542391_2@tests.mozilla.org",
"bug542391_3@tests.mozilla.org",
"bug542391_4@tests.mozilla.org",
"bug542391_5@tests.mozilla.org"],
function(addons) {
check_state_v3_2(addons);
do_check_eq(WindowWatcher.arguments.length, 3);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_1@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_2@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.arguments.indexOf("bug542391_4@tests.mozilla.org") >= 0);
finish_test();
});
}
function finish_test() {
do_test_finished();
}