зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1330349 - Part 4 - make sure theme type WebExtension support is covered by the existing test suite. r=mossop
MozReview-Commit-ID: JCbBZObWDQZ --HG-- extra : rebase_source : bb04f52e483fc07586858011ece82b1de5c6499a
This commit is contained in:
Родитель
8ced0acd87
Коммит
e69d85fd1f
|
@ -307,8 +307,40 @@ add_task(function*() {
|
|||
do_check_false(addon.appDisabled);
|
||||
do_check_true(addon.isActive);
|
||||
do_check_eq(addon.type, "extension");
|
||||
do_check_true(addon.isWebExtension);
|
||||
do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
|
||||
|
||||
// test reloading a webextension with the same name, but a different type.
|
||||
webext.remove(false);
|
||||
webext = createTempWebExtensionFile({
|
||||
manifest: {
|
||||
version: "6.0",
|
||||
name: "Test WebExtension 1 (temporary)",
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
theme: { images: { headerURL: "https://example.com/example.png" } }
|
||||
}
|
||||
});
|
||||
|
||||
yield Promise.all([
|
||||
AddonManager.installTemporaryAddon(webext),
|
||||
promiseAddonStartup(),
|
||||
]);
|
||||
addon = yield promiseAddonByID(ID);
|
||||
|
||||
do_check_neq(addon, null);
|
||||
do_check_eq(addon.version, "6.0");
|
||||
do_check_eq(addon.name, "Test WebExtension 1 (temporary)");
|
||||
do_check_true(addon.isCompatible);
|
||||
do_check_false(addon.appDisabled);
|
||||
do_check_true(addon.isActive);
|
||||
// This is what we're really interested in:
|
||||
do_check_eq(addon.type, "theme");
|
||||
do_check_true(addon.isWebExtension);
|
||||
|
||||
restartManager();
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
|
||||
|
|
|
@ -30,8 +30,11 @@ function promiseAddonStartup() {
|
|||
function promiseInstallWebExtension(aData) {
|
||||
let addonFile = createTempWebExtensionFile(aData);
|
||||
|
||||
return promiseInstallAllFiles([addonFile]).then(() => {
|
||||
return promiseInstallAllFiles([addonFile]).then(installs => {
|
||||
Services.obs.notifyObservers(addonFile, "flush-cache-entry", null);
|
||||
// Since themes are disabled by default, it won't start up.
|
||||
if ("theme" in aData.manifest)
|
||||
return installs[0].addon;
|
||||
return promiseAddonStartup();
|
||||
});
|
||||
}
|
||||
|
@ -418,3 +421,48 @@ add_task(function* authorNotString() {
|
|||
addon.uninstall();
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function* testThemeExtension() {
|
||||
let addon = yield promiseInstallWebExtension({
|
||||
manifest: {
|
||||
"author": "Some author",
|
||||
manifest_version: 2,
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
theme: { images: { headerURL: "https://example.com/example.png" } },
|
||||
}
|
||||
});
|
||||
|
||||
addon = yield promiseAddonByID(addon.id);
|
||||
do_check_neq(addon, null);
|
||||
do_check_eq(addon.creator, "Some author");
|
||||
do_check_eq(addon.version, "1.0");
|
||||
do_check_eq(addon.name, "Web Extension Name");
|
||||
do_check_true(addon.isCompatible);
|
||||
do_check_false(addon.appDisabled);
|
||||
do_check_false(addon.isActive);
|
||||
do_check_true(addon.userDisabled);
|
||||
do_check_false(addon.isSystem);
|
||||
do_check_eq(addon.type, "theme");
|
||||
do_check_true(addon.isWebExtension);
|
||||
do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
|
||||
|
||||
addon.uninstall();
|
||||
|
||||
// Also test one without a proper 'theme' section.
|
||||
addon = yield promiseInstallWebExtension({
|
||||
manifest: {
|
||||
"author": "Some author",
|
||||
manifest_version: 2,
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
theme: null,
|
||||
}
|
||||
});
|
||||
|
||||
addon = yield promiseAddonByID(addon.id);
|
||||
do_check_eq(addon.type, "extension");
|
||||
do_check_true(addon.isWebExtension);
|
||||
|
||||
addon.uninstall();
|
||||
});
|
||||
|
|
|
@ -24,27 +24,12 @@ function promiseAddonStartup() {
|
|||
});
|
||||
}
|
||||
|
||||
// Test simple icon set parsing
|
||||
add_task(function*() {
|
||||
yield promiseWriteWebManifestForExtension({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
16: "icon16.png",
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png"
|
||||
}
|
||||
}, profileDir);
|
||||
function* testSimpleIconsetParsing(manifest) {
|
||||
yield promiseWriteWebManifestForExtension(manifest, profileDir);
|
||||
|
||||
yield promiseRestartManager();
|
||||
yield promiseAddonStartup();
|
||||
if (!manifest.theme)
|
||||
yield promiseAddonStartup();
|
||||
|
||||
let uri = do_get_addon_root_uri(profileDir, ID);
|
||||
|
||||
|
@ -76,7 +61,8 @@ add_task(function*() {
|
|||
|
||||
// check if icons are persisted through a restart
|
||||
yield promiseRestartManager();
|
||||
yield promiseAddonStartup();
|
||||
if (!manifest.theme)
|
||||
yield promiseAddonStartup();
|
||||
|
||||
addon = yield promiseAddonByID(ID);
|
||||
do_check_neq(addon, null);
|
||||
|
@ -86,30 +72,14 @@ add_task(function*() {
|
|||
addon.uninstall();
|
||||
|
||||
yield promiseRestartManager();
|
||||
});
|
||||
}
|
||||
|
||||
// Test AddonManager.getPreferredIconURL for retina screen sizes
|
||||
add_task(function*() {
|
||||
yield promiseWriteWebManifestForExtension({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png",
|
||||
128: "icon128.png",
|
||||
256: "icon256.png"
|
||||
}
|
||||
}, profileDir);
|
||||
function* testRetinaIconsetParsing(manifest) {
|
||||
yield promiseWriteWebManifestForExtension(manifest, profileDir);
|
||||
|
||||
yield promiseRestartManager();
|
||||
yield promiseAddonStartup();
|
||||
if (!manifest.theme)
|
||||
yield promiseAddonStartup();
|
||||
|
||||
let addon = yield promiseAddonByID(ID);
|
||||
do_check_neq(addon, null);
|
||||
|
@ -132,23 +102,14 @@ add_task(function*() {
|
|||
addon.uninstall();
|
||||
|
||||
yield promiseRestartManager();
|
||||
});
|
||||
}
|
||||
|
||||
// Handles no icons gracefully
|
||||
add_task(function*() {
|
||||
yield promiseWriteWebManifestForExtension({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
}
|
||||
}, profileDir);
|
||||
function* testNoIconsParsing(manifest) {
|
||||
yield promiseWriteWebManifestForExtension(manifest, profileDir);
|
||||
|
||||
yield promiseRestartManager();
|
||||
yield promiseAddonStartup();
|
||||
if (!manifest.theme)
|
||||
yield promiseAddonStartup();
|
||||
|
||||
let addon = yield promiseAddonByID(ID);
|
||||
do_check_neq(addon, null);
|
||||
|
@ -163,4 +124,109 @@ add_task(function*() {
|
|||
addon.uninstall();
|
||||
|
||||
yield promiseRestartManager();
|
||||
}
|
||||
|
||||
// Test simple icon set parsing
|
||||
add_task(function*() {
|
||||
yield* testSimpleIconsetParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
16: "icon16.png",
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png"
|
||||
}
|
||||
});
|
||||
|
||||
// Now for theme-type extensions too.
|
||||
yield* testSimpleIconsetParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
16: "icon16.png",
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png"
|
||||
},
|
||||
theme: { images: { headerURL: "https://example.com/example.png" } }
|
||||
});
|
||||
});
|
||||
|
||||
// Test AddonManager.getPreferredIconURL for retina screen sizes
|
||||
add_task(function*() {
|
||||
yield* testRetinaIconsetParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png",
|
||||
128: "icon128.png",
|
||||
256: "icon256.png"
|
||||
}
|
||||
});
|
||||
|
||||
yield* testRetinaIconsetParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
icons: {
|
||||
32: "icon32.png",
|
||||
48: "icon48.png",
|
||||
64: "icon64.png",
|
||||
128: "icon128.png",
|
||||
256: "icon256.png"
|
||||
},
|
||||
theme: { images: { headerURL: "https://example.com/example.png" } }
|
||||
});
|
||||
});
|
||||
|
||||
// Handles no icons gracefully
|
||||
add_task(function*() {
|
||||
yield* testNoIconsParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield* testNoIconsParsing({
|
||||
name: "Web Extension Name",
|
||||
version: "1.0",
|
||||
manifest_version: 2,
|
||||
applications: {
|
||||
gecko: {
|
||||
id: ID
|
||||
}
|
||||
},
|
||||
theme: { images: { headerURL: "https://example.com/example.png" } }
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче