Bug 1303384 - Part 4: Localize command descriptions r=aswan

Differential Revision: https://phabricator.services.mozilla.com/D6346

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Striemer 2019-01-12 02:25:23 +00:00
parent 890829b813
commit 7aba48c482
2 changed files with 17 additions and 1 deletions

View File

@ -62,6 +62,7 @@
},
"description": {
"type": "string",
"preprocess": "localize",
"optional": true
}
}

View File

@ -4,8 +4,17 @@
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
files: {
"_locales/en/messages.json": {
"with_translation": {
"message": "The description",
"description": "A description",
},
},
},
manifest: {
"name": "Commands Extension",
"default_locale": "en",
"commands": {
"with-desciption": {
"suggested_key": {
@ -26,6 +35,9 @@ add_task(async function() {
"android": "Ctrl+Shift+A",
},
},
"with-translation": {
"description": "__MSG_with_translation__",
},
"without-suggested-key": {
"description": "has no suggested_key",
},
@ -38,7 +50,7 @@ add_task(async function() {
browser.test.onMessage.addListener((message, additionalScope) => {
browser.commands.getAll((commands) => {
let errorMessage = "getAll should return an array of commands";
browser.test.assertEq(commands.length, 5, errorMessage);
browser.test.assertEq(commands.length, 6, errorMessage);
let command = commands.find(c => c.name == "with-desciption");
@ -69,6 +81,9 @@ add_task(async function() {
errorMessage = `The shortcut should match the one provided in the manifest for OS='${additionalScope.platform}'`;
browser.test.assertEq(shortcut, command.shortcut, errorMessage);
command = commands.find(c => c.name == "with-translation");
browser.test.assertEq(command.description, "The description", "The description can be localized");
command = commands.find(c => c.name == "without-suggested-key");
browser.test.assertEq("has no suggested_key", command.description, "The description should match what is provided in the manifest");