Bug 957123 - Fix the use of File.prototype.close() by a few AddonManager tests. r=Unfocused

This commit is contained in:
David Rajchenbach-Teller 2014-02-07 10:52:45 -05:00
parent 36ed748051
commit 168808d0d9
4 changed files with 939 additions and 891 deletions

View File

@ -23,6 +23,11 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/Promise.jsm");
Components.utils.import("resource://gre/modules/Task.jsm");
Components.utils.import("resource://gre/modules/osfile.jsm");
Services.prefs.setBoolPref("toolkit.osfile.log", true);
// We need some internal bits of AddonManager
let AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm");
@ -444,6 +449,7 @@ function shutdownManager() {
// This would be cleaner if I could get it as the rejection reason from
// the AddonManagerInternal.shutdown() promise
gXPISaveError = XPIscope.XPIProvider._shutdownError;
do_print("gXPISaveError set to: " + gXPISaveError);
AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider);
Components.utils.unload("resource://gre/modules/XPIProvider.jsm");
}
@ -691,6 +697,8 @@ function writeInstallRDFForExtension(aData, aDir, aId, aExtraFile) {
*
* @param aExt a file pointing to either the packed extension or its unpacked directory.
* @param aTime the time to which we set the lastModifiedTime of the extension
*
* @deprecated Please use promiseSetExtensionModifiedTime instead
*/
function setExtensionModifiedTime(aExt, aTime) {
aExt.lastModifiedTime = aTime;
@ -702,6 +710,25 @@ function setExtensionModifiedTime(aExt, aTime) {
entries.close();
}
}
function promiseSetExtensionModifiedTime(aPath, aTime) {
return Task.spawn(function* () {
yield OS.File.setDates(aPath, aTime, aTime);
let entries, iterator;
try {
let iterator = new OS.File.DirectoryIterator(aPath);
entries = yield iterator.nextBatch();
} catch (ex if ex instanceof OS.File.Error) {
return;
} finally {
if (iterator) {
iterator.close();
}
}
for (let entry of entries) {
yield promiseSetExtensionModifiedTime(entry.path, aTime);
}
});
}
/**
* Manually installs an XPI file into an install location by either copying the
@ -1082,7 +1109,11 @@ function completeAllInstalls(aInstalls, aCallback) {
function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
let count = aFiles.length;
let installs = [];
function callback() {
if (aCallback) {
aCallback();
}
}
aFiles.forEach(function(aFile) {
AddonManager.getInstallForFile(aFile, function(aInstall) {
if (!aInstall)
@ -1093,11 +1124,18 @@ function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
installs.push(aInstall);
if (--count == 0)
completeAllInstalls(installs, aCallback);
completeAllInstalls(installs, callback);
});
});
}
function promiseInstallAllFiles(aFiles, aIgnoreIncompatible) {
let deferred = Promise.defer();
installAllFiles(aFiles, deferred.resolve, aIgnoreIncompatible);
return deferred.promise;
}
if ("nsIWindowsRegKey" in AM_Ci) {
var MockRegistry = {
LOCAL_MACHINE: {},
@ -1473,3 +1511,17 @@ function callback_soon(aFunction) {
}, aFunction.name ? "delayed callback " + aFunction.name : "delayed callback");
}
}
/**
* A promise-based variant of AddonManager.getAddonsByIDs.
*
* @param {array} list As the first argument of AddonManager.getAddonsByIDs
* @return {promise}
* @resolve {array} The list of add-ons sent by AddonManaget.getAddonsByIDs to
* its callback.
*/
function promiseAddonsByIDs(list) {
let deferred = Promise.defer();
AddonManager.getAddonsByIDs(list, deferred.resolve);
return deferred.promise;
}

View File

@ -134,8 +134,7 @@ var theme2 = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
add_task(function* init() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir);
@ -154,37 +153,221 @@ function run_test() {
// New profile so new add-ons are ignored
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
let [a2, a3, a4, a7, t2] =
yield promiseAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4,
a7, t2]) {
// Set up the initial state
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
// Let the updates finish before restarting the manager
do_execute_soon(run_test_1);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
});
}
"theme2@tests.mozilla.org"]);
let deferredUpdateFinished = Promise.defer();
// Set up the initial state
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
// Let the updates finish before restarting the manager
deferredUpdateFinished.resolve();
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
function end_test() {
testserver.stop(do_test_finished);
}
yield deferredUpdateFinished.promise;
});
function run_test_1() {
add_task(function* run_test_1() {
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
let [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
// The compatibility update won't be recovered and with strict
// compatibility it would not have been able to tell that it was
// previously userDisabled. However, without strict compat, it wasn't
// appDisabled, so it knows it must have been userDisabled.
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
restartManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
@ -192,340 +375,155 @@ function run_test_1() {
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
"theme2@tests.mozilla.org"]);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options).then(
file => {
filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function get_after_lock([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
// The compatibility update won't be recovered and with strict
// compatibility it would not have been able to tell that it was
// previously userDisabled. However, without strict compat, it wasn't
// appDisabled, so it knows it must have been userDisabled.
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
restartManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// After allowing access to the original DB things should go back to as
// they were previously
shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager();
// After allowing access to the original DB things should go back to as
// they were previously
shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
yield file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
end_test();
}));
}));
}));
},
do_report_unexpected_exception
);
}));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
});
function run_test() {
run_next_test();
}

View File

@ -71,8 +71,8 @@ var addon5 = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
add_task(function() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir);
@ -83,7 +83,8 @@ function run_test() {
// Make it look like add-on 5 was installed some time in the past so the update is
// detected
setExtensionModifiedTime(getFileForAddon(profileDir, addon5.id), Date.now() - (60000));
let path = getFileForAddon(profileDir, addon5.id).path;
yield promiseSetExtensionModifiedTime(path, Date.now() - (60000));
// Startup the profile and setup the initial state
startupManager();
@ -91,205 +92,201 @@ function run_test() {
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) {
a2.userDisabled = true;
let a1, a2, a3, a4, a5, a6;
restartManager();
[a2] = yield promiseAddonsByIDs(["addon2@tests.mozilla.org"]);
a2.userDisabled = true;
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
a2.userDisabled = false;
a3.userDisabled = true;
a4.uninstall();
restartManager();
installAllFiles([do_get_addon("test_locked2_5"),
do_get_addon("test_locked2_6")], function locked_installed() {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
[a1, a2, a3, a4, a5] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"]);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_ENABLE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
a2.userDisabled = false;
a3.userDisabled = true;
a4.uninstall();
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
yield promiseInstallAllFiles([do_get_addon("test_locked2_5"),
do_get_addon("test_locked2_6")]);
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a4, null);
do_check_true(a4.isActive);
do_check_false(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_UNINSTALL);
do_check_true(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_ENABLE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a5, null);
do_check_eq(a5.version, "1.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_UPGRADE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
do_check_neq(a4, null);
do_check_true(a4.isActive);
do_check_false(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_UNINSTALL);
do_check_true(isExtensionInAddonsList(profileDir, a4.id));
OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options).then(
file => {
filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
do_check_neq(a5, null);
do_check_eq(a5.version, "1.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_UPGRADE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
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"],
callback_soon(function([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
do_check_neq(a2, null);
do_check_true(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
do_check_eq(a4, null);
[a1, a2, a3, a4, a5, a6] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"]);
do_check_neq(a5, null);
do_check_eq(a5.version, "2.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
do_check_neq(a2, null);
do_check_true(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
// After allowing access to the original DB things should still be
// back how they were before the lock
shutdownManager();
file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager();
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
// On Unix, we can save the DB even when the original file wasn't
// readable, so our changes were saved. On Windows,
// these things happened when we had no access to the database so
// they are seen as external changes when we get the database back
if (gXPISaveError) {
do_print("Previous XPI save failed");
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED,
["addon6@tests.mozilla.org"]);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED,
["addon4@tests.mozilla.org"]);
}
else {
do_print("Previous XPI save succeeded");
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
}
do_check_eq(a4, null);
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"],
function([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a5, null);
do_check_eq(a5.version, "2.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a2, null);
do_check_true(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
// After allowing access to the original DB things should still be
// back how they were before the lock
shutdownManager();
yield file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager();
do_check_eq(a4, null);
// On Unix, we can save the DB even when the original file wasn't
// readable, so our changes were saved. On Windows,
// these things happened when we had no access to the database so
// they are seen as external changes when we get the database back
if (gXPISaveError) {
do_print("Previous XPI save failed");
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED,
["addon6@tests.mozilla.org"]);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED,
["addon4@tests.mozilla.org"]);
}
else {
do_print("Previous XPI save succeeded");
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
}
do_check_neq(a5, null);
do_check_eq(a5.version, "2.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
[a1, a2, a3, a4, a5, a6] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"]);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
end_test();
});
}));
},
do_report_unexpected_exception
);
});
});
}));
do_check_neq(a2, null);
do_check_true(a2.isActive);
do_check_false(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_true(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a4, null);
do_check_neq(a5, null);
do_check_eq(a5.version, "2.0");
do_check_true(a5.isActive);
do_check_false(a5.userDisabled);
do_check_false(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
});
function run_test() {
run_next_test();
}
function end_test() {
do_execute_soon(do_test_finished);
}

View File

@ -134,8 +134,7 @@ var theme2 = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
add_task(function* init() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir);
@ -154,37 +153,222 @@ function run_test() {
// New profile so new add-ons are ignored
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4,
a7, t2]) {
// Set up the initial state
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
do_execute_soon(run_test_1);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
});
}
let a1, a2, a3, a4, a5, a6, a7, t1, t2;
function end_test() {
testserver.stop(do_test_finished);
}
[a2, a3, a4, a7, t2] =
yield promiseAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
function run_test_1() {
// Set up the initial state
let deferredUpdateFinished = Promise.defer();
a2.userDisabled = true;
a4.userDisabled = true;
a7.userDisabled = true;
t2.userDisabled = false;
a3.findUpdates({
onUpdateFinished: function() {
a4.findUpdates({
onUpdateFinished: function() {
deferredUpdateFinished.resolve();
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
yield deferredUpdateFinished.promise;
});
add_task(function* run_test_1() {
let a1, a2, a3, a4, a5, a6, a7, t1, t2;
restartManager();
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
@ -192,359 +376,176 @@ function run_test_1() {
"addon6@tests.mozilla.org",
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
"theme2@tests.mozilla.org"]);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a3, null);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// After allowing access to the original DB things should go back to as
// back how they were before the lock
shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
yield file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"]);
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.userDisabled);
// On Unix, we may be able to save our changes over the locked DB so we
// remember that this extension was changed to disabled. On Windows we
// couldn't replace the old DB so we read the older version of the DB
// where the extension is enabled
if (gXPISaveError) {
do_print("XPI save failed");
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_false(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
}
else {
do_print("XPI save succeeded");
do_check_false(a3.isActive);
do_check_true(a3.appDisabled);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
}
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_neq(a4, null);
do_check_false(a4.isActive);
// The reverse of the platform difference for a3 - Unix should
// stay the same as the last iteration because the save succeeded,
// Windows should still say userDisabled
if (OS.Constants.Win) {
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
}
else {
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
}
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
});
// Open another handle on the JSON DB with as much Unix and Windows locking
// as we can to simulate some other process interfering with it
shutdownManager();
do_print("Locking " + gExtensionsJSON.path);
let options = {
winShare: 0
};
if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = OS.Constants.libc.O_EXLOCK;
OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options).then(
file => {
filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0;
}
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
// Should be correctly recovered
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
// Should be correctly recovered
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
// The compatibility update won't be recovered but it should still be
// active for this session
do_check_neq(a3, null);
do_check_true(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
// Should be correctly recovered
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
restartManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.isActive);
do_check_false(a3.userDisabled);
do_check_true(a3.appDisabled);
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_neq(a4, null);
do_check_false(a4.isActive);
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
// After allowing access to the original DB things should go back to as
// back how they were before the lock
shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager(false);
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
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",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
do_check_neq(a1, null);
do_check_true(a1.isActive);
do_check_false(a1.userDisabled);
do_check_false(a1.appDisabled);
do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_true(a2.userDisabled);
do_check_false(a2.appDisabled);
do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.userDisabled);
// On Unix, we may be able to save our changes over the locked DB so we
// remember that this extension was changed to disabled. On Windows we
// couldn't replace the old DB so we read the older version of the DB
// where the extension is enabled
if (gXPISaveError) {
do_print("XPI save failed");
do_check_true(a3.isActive);
do_check_false(a3.appDisabled);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
}
else {
do_print("XPI save succeeded");
do_check_false(a3.isActive);
do_check_true(a3.appDisabled);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
}
do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a4, null);
do_check_false(a4.isActive);
// The reverse of the platform difference for a3 - Unix should
// stay the same as the last iteration because the save succeeded,
// Windows should still say userDisabled
if (OS.Constants.Win) {
do_check_true(a4.userDisabled);
do_check_false(a4.appDisabled);
}
else {
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
}
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a5, null);
do_check_false(a5.isActive);
do_check_false(a5.userDisabled);
do_check_true(a5.appDisabled);
do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_true(a6.isActive);
do_check_false(a6.userDisabled);
do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(a7, null);
do_check_false(a7.isActive);
do_check_true(a7.userDisabled);
do_check_false(a7.appDisabled);
do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
do_check_neq(t1, null);
do_check_false(t1.isActive);
do_check_true(t1.userDisabled);
do_check_false(t1.appDisabled);
do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
do_check_false(isThemeInAddonsList(profileDir, t1.id));
do_check_neq(t2, null);
do_check_true(t2.isActive);
do_check_false(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
end_test();
}));
}));
}));
},
do_report_unexpected_exception
);
}));
function run_test() {
run_next_test();
}