зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1495908 - Label unexpected WebExtension manifest.json properties as a Warning r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D40413 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d9f0623861
Коммит
24afc1d3b1
|
@ -40,7 +40,7 @@ add_task(async function() {
|
|||
let waitForConsole = new Promise(resolve => {
|
||||
SimpleTest.monitorConsole(resolve, [
|
||||
{
|
||||
message: /Reading manifest: Error processing browser_action.unrecognized_property: An unexpected property was found/,
|
||||
message: /Reading manifest: Warning processing browser_action.unrecognized_property: An unexpected property was found/,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -234,7 +234,7 @@ add_task(async function test_user_defined_commands() {
|
|||
let waitForConsole = new Promise(resolve => {
|
||||
SimpleTest.monitorConsole(resolve, [
|
||||
{
|
||||
message: /Reading manifest: Error processing commands.*.unrecognized_property: An unexpected property was found/,
|
||||
message: /Reading manifest: Warning processing commands.*.unrecognized_property: An unexpected property was found/,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ add_task(async function test_pageAction_basic() {
|
|||
let waitForConsole = new Promise(resolve => {
|
||||
SimpleTest.monitorConsole(resolve, [
|
||||
{
|
||||
message: /Reading manifest: Error processing page_action.unrecognized_property: An unexpected property was found/,
|
||||
message: /Reading manifest: Warning processing page_action.unrecognized_property: An unexpected property was found/,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -454,9 +454,12 @@ class Context {
|
|||
* A caller may pass `null` to prevent a choice from being
|
||||
* added, but this should *only* be done from code processing a
|
||||
* choices type.
|
||||
* @param {boolean} [warning = false]
|
||||
* If true, make message prefixed `Warning`. If false, make message
|
||||
* prefixed `Error`
|
||||
* @returns {object}
|
||||
*/
|
||||
error(errorMessage, choicesMessage = undefined) {
|
||||
error(errorMessage, choicesMessage = undefined, warning = false) {
|
||||
if (choicesMessage !== null) {
|
||||
let { choicePath } = this;
|
||||
if (choicePath) {
|
||||
|
@ -470,7 +473,9 @@ class Context {
|
|||
let { currentTarget } = this;
|
||||
return {
|
||||
error: () =>
|
||||
`Error processing ${currentTarget}: ${forceString(errorMessage)}`,
|
||||
`${
|
||||
warning ? "Warning" : "Error"
|
||||
} processing ${currentTarget}: ${forceString(errorMessage)}`,
|
||||
};
|
||||
}
|
||||
return { error: errorMessage };
|
||||
|
@ -485,10 +490,12 @@ class Context {
|
|||
* the message, in the same way as for the `error` method.
|
||||
*
|
||||
* @param {string} message
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.warning = false]
|
||||
* @returns {Error}
|
||||
*/
|
||||
makeError(message) {
|
||||
let error = forceString(this.error(message).error);
|
||||
makeError(message, { warning = false } = {}) {
|
||||
let error = forceString(this.error(message, null, warning).error);
|
||||
if (this.cloneScope) {
|
||||
return new this.cloneScope.Error(error);
|
||||
}
|
||||
|
@ -1186,7 +1193,7 @@ class Entry {
|
|||
}
|
||||
}
|
||||
|
||||
context.logError(context.makeError(message));
|
||||
context.logError(context.makeError(message, { warning: true }));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ add_task(async function test_contentscript() {
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
let waitForConsole = new Promise(resolve => {
|
||||
SimpleTest.monitorConsole(resolve, [{
|
||||
message: /Reading manifest: Error processing content_scripts.*.unrecognized_property: An unexpected property was found/,
|
||||
message: /Reading manifest: Warning processing content_scripts.*.unrecognized_property: An unexpected property was found/,
|
||||
}]);
|
||||
});
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ add_task(async function test_eventpages() {
|
|||
{ message: /Event pages are not currently supported./ },
|
||||
{ message: /Event pages are not currently supported./ },
|
||||
{
|
||||
message: /Reading manifest: Error processing background.nonExistentProp: An unexpected property was found/,
|
||||
message: /Reading manifest: Warning processing background.nonExistentProp: An unexpected property was found/,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -61,3 +61,33 @@ add_task(async function test_manifest() {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_manifest_warnings_on_unexpected_props() {
|
||||
let extension = await ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
background: {
|
||||
scripts: ["bg.js"],
|
||||
wrong_prop: true,
|
||||
},
|
||||
},
|
||||
files: {
|
||||
"bg.js": "",
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
|
||||
// Retrieve the warning message collected by the Extension class
|
||||
// packagingWarning method.
|
||||
const { warnings } = extension.extension;
|
||||
equal(warnings.length, 1, "Got the expected number of manifest warnings");
|
||||
|
||||
const expectedMessage =
|
||||
"Reading manifest: Warning processing background.wrong_prop";
|
||||
ok(
|
||||
warnings[0].startsWith(expectedMessage),
|
||||
"Got the expected warning message format"
|
||||
);
|
||||
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ async function test_theme_property(property) {
|
|||
);
|
||||
|
||||
if (property === "unrecognized_key") {
|
||||
const expectedWarning = `Error processing theme.${property}`;
|
||||
const expectedWarning = `Warning processing theme.${property}`;
|
||||
ok(
|
||||
normalized.errors[0].includes(expectedWarning),
|
||||
`The manifest warning ${JSON.stringify(
|
||||
|
|
|
@ -1266,8 +1266,8 @@ add_task(async function testDeprecation() {
|
|||
{ foo: "bar", xxx: "any", yyy: "property" },
|
||||
]);
|
||||
checkErrors([
|
||||
"Error processing xxx: Unknown property",
|
||||
"Error processing yyy: Unknown property",
|
||||
"Warning processing xxx: Unknown property",
|
||||
"Warning processing yyy: Unknown property",
|
||||
]);
|
||||
|
||||
root.deprecated.value(12);
|
||||
|
|
Загрузка…
Ссылка в новой задаче