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/FileUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.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 // We need some internal bits of AddonManager
let AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm"); 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 // This would be cleaner if I could get it as the rejection reason from
// the AddonManagerInternal.shutdown() promise // the AddonManagerInternal.shutdown() promise
gXPISaveError = XPIscope.XPIProvider._shutdownError; gXPISaveError = XPIscope.XPIProvider._shutdownError;
do_print("gXPISaveError set to: " + gXPISaveError);
AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider); AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider);
Components.utils.unload("resource://gre/modules/XPIProvider.jsm"); 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 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 * @param aTime the time to which we set the lastModifiedTime of the extension
*
* @deprecated Please use promiseSetExtensionModifiedTime instead
*/ */
function setExtensionModifiedTime(aExt, aTime) { function setExtensionModifiedTime(aExt, aTime) {
aExt.lastModifiedTime = aTime; aExt.lastModifiedTime = aTime;
@ -702,6 +710,25 @@ function setExtensionModifiedTime(aExt, aTime) {
entries.close(); 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 * 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) { function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
let count = aFiles.length; let count = aFiles.length;
let installs = []; let installs = [];
function callback() {
if (aCallback) {
aCallback();
}
}
aFiles.forEach(function(aFile) { aFiles.forEach(function(aFile) {
AddonManager.getInstallForFile(aFile, function(aInstall) { AddonManager.getInstallForFile(aFile, function(aInstall) {
if (!aInstall) if (!aInstall)
@ -1093,11 +1124,18 @@ function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
installs.push(aInstall); installs.push(aInstall);
if (--count == 0) 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) { if ("nsIWindowsRegKey" in AM_Ci) {
var MockRegistry = { var MockRegistry = {
LOCAL_MACHINE: {}, LOCAL_MACHINE: {},
@ -1473,3 +1511,17 @@ function callback_soon(aFunction) {
}, aFunction.name ? "delayed callback " + aFunction.name : "delayed callback"); }, 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(); const profileDir = gProfD.clone();
profileDir.append("extensions"); profileDir.append("extensions");
function run_test() { add_task(function* init() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir); writeInstallRDFForExtension(addon1, profileDir);
@ -154,12 +153,13 @@ function run_test() {
// New profile so new add-ons are ignored // New profile so new add-ons are ignored
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); 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", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4, "theme2@tests.mozilla.org"]);
a7, t2]) { let deferredUpdateFinished = Promise.defer();
// Set up the initial state // Set up the initial state
a2.userDisabled = true; a2.userDisabled = true;
a4.userDisabled = true; a4.userDisabled = true;
@ -170,21 +170,20 @@ function run_test() {
a4.findUpdates({ a4.findUpdates({
onUpdateFinished: function() { onUpdateFinished: function() {
// Let the updates finish before restarting the manager // Let the updates finish before restarting the manager
do_execute_soon(run_test_1); deferredUpdateFinished.resolve();
} }
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
} }
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
});
}
function end_test() { yield deferredUpdateFinished.promise;
testserver.stop(do_test_finished); });
}
function run_test_1() {
add_task(function* run_test_1() {
restartManager(); 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", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -192,8 +191,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -265,9 +264,9 @@ function run_test_1() {
if (OS.Constants.libc.O_EXLOCK) if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = 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( let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
file => {
filePermissions = gExtensionsJSON.permissions; let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) { if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0; gExtensionsJSON.permissions = 0;
} }
@ -277,7 +276,8 @@ function run_test_1() {
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database // Accessing the add-ons should open and recover the database
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -285,8 +285,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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 // Should be correctly recovered
do_check_neq(a1, null); do_check_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
@ -366,7 +366,8 @@ function run_test_1() {
// Shouldn't have seen any startup changes // Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -374,8 +375,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -441,7 +442,7 @@ function run_test_1() {
// they were previously // they were previously
shutdownManager(); shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path); do_print("Unlocking " + gExtensionsJSON.path);
file.close(); yield file.close();
gExtensionsJSON.permissions = filePermissions; gExtensionsJSON.permissions = filePermissions;
startupManager(); startupManager();
@ -449,7 +450,8 @@ function run_test_1() {
// Shouldn't have seen any startup changes // Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -457,8 +459,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -519,13 +521,9 @@ function run_test_1() {
do_check_false(t2.appDisabled); do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE); do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id)); do_check_true(isThemeInAddonsList(profileDir, t2.id));
});
end_test();
})); function run_test() {
})); run_next_test();
}));
},
do_report_unexpected_exception
);
}));
} }

View File

@ -71,8 +71,8 @@ var addon5 = {
const profileDir = gProfD.clone(); const profileDir = gProfD.clone();
profileDir.append("extensions"); profileDir.append("extensions");
function run_test() { add_task(function() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir); 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 // Make it look like add-on 5 was installed some time in the past so the update is
// detected // 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 // Startup the profile and setup the initial state
startupManager(); startupManager();
@ -91,23 +92,26 @@ function run_test() {
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { let a1, a2, a3, a4, a5, a6;
[a2] = yield promiseAddonsByIDs(["addon2@tests.mozilla.org"]);
a2.userDisabled = true; a2.userDisabled = true;
restartManager(); restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"], "addon5@tests.mozilla.org"]);
function([a1, a2, a3, a4, a5]) {
a2.userDisabled = false; a2.userDisabled = false;
a3.userDisabled = true; a3.userDisabled = true;
a4.uninstall(); a4.uninstall();
installAllFiles([do_get_addon("test_locked2_5"), yield promiseInstallAllFiles([do_get_addon("test_locked2_5"),
do_get_addon("test_locked2_6")], function locked_installed() { do_get_addon("test_locked2_6")]);
do_check_neq(a1, null); do_check_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -154,9 +158,9 @@ function run_test() {
if (OS.Constants.libc.O_EXLOCK) if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = 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( let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
file => {
filePermissions = gExtensionsJSON.permissions; let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) { if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0; gExtensionsJSON.permissions = 0;
} }
@ -165,13 +169,14 @@ function run_test() {
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
"addon5@tests.mozilla.org", "addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"], "addon6@tests.mozilla.org"]);
callback_soon(function([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null); do_check_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -213,7 +218,7 @@ function run_test() {
// After allowing access to the original DB things should still be // After allowing access to the original DB things should still be
// back how they were before the lock // back how they were before the lock
shutdownManager(); shutdownManager();
file.close(); yield file.close();
gExtensionsJSON.permissions = filePermissions; gExtensionsJSON.permissions = filePermissions;
startupManager(); startupManager();
@ -234,13 +239,14 @@ function run_test() {
check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
} }
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
"addon5@tests.mozilla.org", "addon5@tests.mozilla.org",
"addon6@tests.mozilla.org"], "addon6@tests.mozilla.org"]);
function([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null); do_check_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -278,18 +284,9 @@ function run_test() {
do_check_false(a6.appDisabled); do_check_false(a6.appDisabled);
do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE); do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isExtensionInAddonsList(profileDir, a6.id)); do_check_true(isExtensionInAddonsList(profileDir, a6.id));
});
end_test(); function run_test() {
}); run_next_test();
}));
},
do_report_unexpected_exception
);
});
});
}));
} }
function end_test() {
do_execute_soon(do_test_finished);
}

View File

@ -134,8 +134,7 @@ var theme2 = {
const profileDir = gProfD.clone(); const profileDir = gProfD.clone();
profileDir.append("extensions"); profileDir.append("extensions");
function run_test() { add_task(function* init() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
writeInstallRDFForExtension(addon1, profileDir); writeInstallRDFForExtension(addon1, profileDir);
@ -154,13 +153,18 @@ function run_test() {
// New profile so new add-ons are ignored // New profile so new add-ons are ignored
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org", let a1, a2, a3, a4, a5, a6, a7, t1, t2;
[a2, a3, a4, a7, t2] =
yield promiseAddonsByIDs(["addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme2@tests.mozilla.org"], function([a2, a3, a4, "theme2@tests.mozilla.org"]);
a7, t2]) {
// Set up the initial state // Set up the initial state
let deferredUpdateFinished = Promise.defer();
a2.userDisabled = true; a2.userDisabled = true;
a4.userDisabled = true; a4.userDisabled = true;
a7.userDisabled = true; a7.userDisabled = true;
@ -169,22 +173,20 @@ function run_test() {
onUpdateFinished: function() { onUpdateFinished: function() {
a4.findUpdates({ a4.findUpdates({
onUpdateFinished: function() { onUpdateFinished: function() {
do_execute_soon(run_test_1); deferredUpdateFinished.resolve();
} }
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
} }
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}); yield deferredUpdateFinished.promise;
} });
function end_test() { add_task(function* run_test_1() {
testserver.stop(do_test_finished); let a1, a2, a3, a4, a5, a6, a7, t1, t2;
}
function run_test_1() {
restartManager(); restartManager();
[a1, a2, a3, a4, a5, a6, a7, t1, t2] =
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -192,8 +194,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -265,9 +267,9 @@ function run_test_1() {
if (OS.Constants.libc.O_EXLOCK) if (OS.Constants.libc.O_EXLOCK)
options.unixFlags = 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( let file = yield OS.File.open(gExtensionsJSON.path, {read:true, write:true, existing:true}, options);
file => {
filePermissions = gExtensionsJSON.permissions; let filePermissions = gExtensionsJSON.permissions;
if (!OS.Constants.Win) { if (!OS.Constants.Win) {
gExtensionsJSON.permissions = 0; gExtensionsJSON.permissions = 0;
} }
@ -277,7 +279,8 @@ function run_test_1() {
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
// Accessing the add-ons should open and recover the database // Accessing the add-ons should open and recover the database
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -285,8 +288,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"], "theme2@tests.mozilla.org"]);
callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
// Should be correctly recovered // Should be correctly recovered
do_check_neq(a1, null); do_check_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
@ -364,7 +367,8 @@ function run_test_1() {
// Shouldn't have seen any startup changes // Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -372,8 +376,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -439,14 +443,15 @@ function run_test_1() {
// back how they were before the lock // back how they were before the lock
shutdownManager(); shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path); do_print("Unlocking " + gExtensionsJSON.path);
file.close(); yield file.close();
gExtensionsJSON.permissions = filePermissions; gExtensionsJSON.permissions = filePermissions;
startupManager(false); startupManager(false);
// Shouldn't have seen any startup changes // Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []); check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", [a1, a2, a3, a4, a5, a6, a7, t1, t2] =
yield promiseAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org", "addon2@tests.mozilla.org",
"addon3@tests.mozilla.org", "addon3@tests.mozilla.org",
"addon4@tests.mozilla.org", "addon4@tests.mozilla.org",
@ -454,8 +459,8 @@ function run_test_1() {
"addon6@tests.mozilla.org", "addon6@tests.mozilla.org",
"addon7@tests.mozilla.org", "addon7@tests.mozilla.org",
"theme1@tests.mozilla.org", "theme1@tests.mozilla.org",
"theme2@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_neq(a1, null);
do_check_true(a1.isActive); do_check_true(a1.isActive);
do_check_false(a1.userDisabled); do_check_false(a1.userDisabled);
@ -538,13 +543,9 @@ function run_test_1() {
do_check_false(t2.appDisabled); do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE); do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id)); do_check_true(isThemeInAddonsList(profileDir, t2.id));
});
end_test(); function run_test() {
})); run_next_test();
}));
}));
},
do_report_unexpected_exception
);
}));
} }