mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1294811: Move AddonManager test helpers to a shared test module. r=rhelmer
Most of the AddonTestUtils code is simply moved from head_addons.js, but I did significantly refactor some of the especially crufty parts. MozReview-Commit-ID: K4vIqnI1qhY --HG-- extra : rebase_source : 776d94bcf59546aa827f5befc4b018dd628e2efe
This commit is contained in:
parent
6a596c0e80
commit
71550e4477
1151
toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
Normal file
1151
toolkit/mozapps/extensions/internal/AddonTestUtils.jsm
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,10 @@ EXTRA_JS_MODULES.addons += [
|
||||
'XPIProviderUtils.js',
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
'AddonTestUtils.jsm',
|
||||
]
|
||||
|
||||
# Don't ship unused providers on Android
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
|
||||
EXTRA_JS_MODULES.addons += [
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -60,7 +60,7 @@ writeInstallRDFToDir({
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Unpacked, Enabled",
|
||||
}, profileDir, null, "extraFile.js");
|
||||
}, profileDir, undefined, "extraFile.js");
|
||||
|
||||
|
||||
// Unpacked, disabled
|
||||
@ -75,7 +75,7 @@ writeInstallRDFToDir({
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Unpacked, disabled",
|
||||
}, profileDir, null, "extraFile.js");
|
||||
}, profileDir, undefined, "extraFile.js");
|
||||
|
||||
// Keep track of the last time stamp we've used, so that we can keep moving
|
||||
// it forward (if we touch two different files in the same add-on with the same
|
||||
|
@ -330,7 +330,8 @@ function run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
|
||||
restartManager();
|
||||
Assert.throws(shutdownManager);
|
||||
startupManager(false);
|
||||
|
||||
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
@ -396,6 +397,8 @@ function run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
|
||||
Assert.throws(shutdownManager);
|
||||
|
||||
end_test();
|
||||
}));
|
||||
}));
|
||||
|
@ -329,7 +329,8 @@ function run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
|
||||
restartManager();
|
||||
Assert.throws(shutdownManager);
|
||||
startupManager(false);
|
||||
|
||||
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
@ -395,6 +396,8 @@ function run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
|
||||
Assert.throws(shutdownManager);
|
||||
|
||||
end_test();
|
||||
}));
|
||||
}));
|
||||
|
@ -361,7 +361,12 @@ add_task(function* run_test_1() {
|
||||
// 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();
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
// We're expecting an error here.
|
||||
}
|
||||
startupManager(false);
|
||||
|
||||
// Shouldn't have seen any startup changes
|
||||
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
|
||||
@ -440,7 +445,11 @@ add_task(function* run_test_1() {
|
||||
|
||||
// After allowing access to the original DB things should go back to as
|
||||
// they were previously
|
||||
shutdownManager();
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
// We're expecting an error here.
|
||||
}
|
||||
do_print("Unlocking " + gExtensionsJSON.path);
|
||||
yield file.close();
|
||||
gExtensionsJSON.permissions = filePermissions;
|
||||
@ -521,6 +530,12 @@ add_task(function* run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
do_check_true(isThemeInAddonsList(profileDir, t2.id));
|
||||
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
// We're expecting an error here.
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -217,7 +217,12 @@ add_task(function*() {
|
||||
|
||||
// After allowing access to the original DB things should still be
|
||||
// back how they were before the lock
|
||||
shutdownManager();
|
||||
let shutdownError;
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
shutdownError = e;
|
||||
}
|
||||
yield file.close();
|
||||
gExtensionsJSON.permissions = filePermissions;
|
||||
startupManager();
|
||||
@ -226,7 +231,7 @@ add_task(function*() {
|
||||
// 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) {
|
||||
if (shutdownError) {
|
||||
do_print("Previous XPI save failed");
|
||||
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED,
|
||||
["addon6@tests.mozilla.org"]);
|
||||
|
@ -362,7 +362,12 @@ add_task(function* run_test_1() {
|
||||
// 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();
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
// We're expecting an error here.
|
||||
}
|
||||
startupManager(false);
|
||||
|
||||
// Shouldn't have seen any startup changes
|
||||
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
|
||||
@ -441,7 +446,12 @@ add_task(function* run_test_1() {
|
||||
|
||||
// After allowing access to the original DB things should go back to as
|
||||
// back how they were before the lock
|
||||
shutdownManager();
|
||||
let shutdownError;
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
shutdownError = e;
|
||||
}
|
||||
do_print("Unlocking " + gExtensionsJSON.path);
|
||||
yield file.close();
|
||||
gExtensionsJSON.permissions = filePermissions;
|
||||
@ -481,7 +491,7 @@ add_task(function* run_test_1() {
|
||||
// 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) {
|
||||
if (shutdownError) {
|
||||
do_print("XPI save failed");
|
||||
do_check_true(a3.isActive);
|
||||
do_check_false(a3.appDisabled);
|
||||
@ -543,6 +553,12 @@ add_task(function* run_test_1() {
|
||||
do_check_false(t2.appDisabled);
|
||||
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
|
||||
do_check_true(isThemeInAddonsList(profileDir, t2.id));
|
||||
|
||||
try {
|
||||
shutdownManager();
|
||||
} catch (e) {
|
||||
// An error is expected here.
|
||||
}
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
|
@ -243,7 +243,7 @@ function run_test() {
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 18"
|
||||
}, profileDir, null, "options.xul");
|
||||
}, profileDir, undefined, "options.xul");
|
||||
|
||||
writeInstallRDFForExtension({
|
||||
id: "addon19@tests.mozilla.org",
|
||||
@ -305,7 +305,7 @@ function run_test() {
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 23"
|
||||
}, profileDir, null, "options.xul");
|
||||
}, profileDir, undefined, "options.xul");
|
||||
|
||||
writeInstallRDFForExtension({
|
||||
id: "addon24@tests.mozilla.org",
|
||||
@ -316,7 +316,7 @@ function run_test() {
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 24"
|
||||
}, profileDir, null, "options.xul");
|
||||
}, profileDir, undefined, "options.xul");
|
||||
|
||||
writeInstallRDFForExtension({
|
||||
id: "addon25@tests.mozilla.org",
|
||||
@ -340,7 +340,7 @@ function run_test() {
|
||||
maxVersion: "1"
|
||||
}],
|
||||
name: "Test Addon 26"
|
||||
}, profileDir, null, "options.xul");
|
||||
}, profileDir, undefined, "options.xul");
|
||||
|
||||
do_test_pending();
|
||||
startupManager();
|
||||
|
@ -18,6 +18,19 @@ const sampleRDFManifest = {
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
|
||||
startupManager();
|
||||
|
||||
const {Management} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
|
||||
|
||||
function promiseAddonStartup() {
|
||||
return new Promise(resolve => {
|
||||
let listener = (extension) => {
|
||||
Management.off("startup", listener);
|
||||
resolve(extension);
|
||||
};
|
||||
|
||||
Management.on("startup", listener);
|
||||
});
|
||||
}
|
||||
|
||||
BootstrapMonitor.init();
|
||||
|
||||
// Partial list of bootstrap reasons from XPIProvider.jsm
|
||||
@ -135,10 +148,10 @@ add_task(function*() {
|
||||
version: "3.0",
|
||||
bootstrap: true,
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "1"
|
||||
}],
|
||||
}],
|
||||
name: "Test Bootstrap 1 (temporary)",
|
||||
}, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
|
||||
|
||||
@ -247,7 +260,10 @@ add_task(function*() {
|
||||
}
|
||||
});
|
||||
|
||||
yield AddonManager.installTemporaryAddon(webext);
|
||||
yield Promise.all([
|
||||
AddonManager.installTemporaryAddon(webext),
|
||||
promiseAddonStartup(),
|
||||
]);
|
||||
addon = yield promiseAddonByID(ID);
|
||||
|
||||
// temporary add-on is installed and started
|
||||
@ -274,7 +290,10 @@ add_task(function*() {
|
||||
}
|
||||
});
|
||||
|
||||
yield AddonManager.installTemporaryAddon(webext);
|
||||
yield Promise.all([
|
||||
AddonManager.installTemporaryAddon(webext),
|
||||
promiseAddonStartup(),
|
||||
]);
|
||||
addon = yield promiseAddonByID(ID);
|
||||
|
||||
// temporary add-on is installed and started
|
||||
|
Loading…
Reference in New Issue
Block a user