Bug 1295608 - Migrate devtools/client/inspector/test to use l10n.js;r=pbro

MozReview-Commit-ID: 7uH7CA6pPpd

--HG--
extra : rebase_source : bbf6e2e39ceb0390d44239dad29afdb8386ac181
This commit is contained in:
Julian Descottes 2016-08-25 10:35:22 +02:00
Родитель c3d6bf2925
Коммит a542fa1662
18 изменённых файлов: 55 добавлений и 78 удалений

Просмотреть файл

@ -4,9 +4,8 @@
"use strict";
const { LocalizationHelper } = require("devtools/client/shared/l10n");
const STRINGS_URI = "global/locale/layout_errors.properties";
const L10N = new LocalizationHelper(STRINGS_URI);
const LAYOUT_ERRORS_L10N =
new LocalizationHelper("global/locale/layout_errors.properties");
// Test that when an animation is selected, its list of animated properties is
// displayed below it.
@ -79,7 +78,7 @@ function hasExpectedWarnings(containerEl) {
for (let warning of warnings) {
let warningID =
"CompositorAnimationWarningTransformWithGeometricProperties";
if (warning.getAttribute("title") == L10N.getStr(warningID)) {
if (warning.getAttribute("title") == LAYOUT_ERRORS_L10N.getStr(warningID)) {
return true;
}
}

Просмотреть файл

@ -7,11 +7,6 @@ requestLongerTimeout(2);
// Test that the panel shows no animation data for invalid or not animated nodes
const { LocalizationHelper } = require("devtools/client/shared/l10n");
const STRINGS_URI = "devtools/locale/animationinspector.properties";
const L10N = new LocalizationHelper(STRINGS_URI);
add_task(function* () {
yield addTab(URL_ROOT + "doc_simple_animation.html");
let {inspector, panel, window} = yield openAnimationInspector();
@ -28,7 +23,7 @@ add_task(function* () {
is(panel.animationsTimelineComponent.animationsEl.childNodes.length, 0,
"No animation displayed in the timeline component for a still node");
is(document.querySelector("#error-type").textContent,
L10N.getStr("panel.invalidElementSelected"),
ANIMATION_L10N.getStr("panel.invalidElementSelected"),
"The correct error message is displayed");
info("Select the comment text node and check that the panel is empty");
@ -42,6 +37,6 @@ add_task(function* () {
is(panel.animationsTimelineComponent.animationsEl.childNodes.length, 0,
"No animation displayed in the timeline component for a text node");
is(document.querySelector("#error-type").textContent,
L10N.getStr("panel.invalidElementSelected"),
ANIMATION_L10N.getStr("panel.invalidElementSelected"),
"The correct error message is displayed");
});

Просмотреть файл

@ -9,11 +9,6 @@ requestLongerTimeout(2);
// Test that when animations displayed in the timeline are running on the
// compositor, they get a special icon and information in the tooltip.
const { LocalizationHelper } = require("devtools/client/shared/l10n");
const STRINGS_URI = "devtools/locale/animationinspector.properties";
const L10N = new LocalizationHelper(STRINGS_URI);
add_task(function* () {
yield addTab(URL_ROOT + "doc_simple_animation.html");
let {inspector, panel} = yield openAnimationInspector();
@ -26,7 +21,7 @@ add_task(function* () {
ok(animationEl.classList.contains("fast-track"),
"The animation element has the fast-track css class");
ok(hasTooltip(animationEl,
L10N.getStr("player.allPropertiesOnCompositorTooltip")),
ANIMATION_L10N.getStr("player.allPropertiesOnCompositorTooltip")),
"The animation element has the right tooltip content");
info("Select a node we know doesn't have an animation on the compositor");
@ -36,10 +31,10 @@ add_task(function* () {
ok(!animationEl.classList.contains("fast-track"),
"The animation element does not have the fast-track css class");
ok(!hasTooltip(animationEl,
L10N.getStr("player.allPropertiesOnCompositorTooltip")),
ANIMATION_L10N.getStr("player.allPropertiesOnCompositorTooltip")),
"The animation element does not have oncompositor tooltip content");
ok(!hasTooltip(animationEl,
L10N.getStr("player.somePropertiesOnCompositorTooltip")),
ANIMATION_L10N.getStr("player.somePropertiesOnCompositorTooltip")),
"The animation element does not have oncompositor tooltip content");
info("Select a node we know has animation on the compositor and not on the" +
@ -50,7 +45,7 @@ add_task(function* () {
ok(animationEl.classList.contains("fast-track"),
"The animation element has the fast-track css class");
ok(hasTooltip(animationEl,
L10N.getStr("player.somePropertiesOnCompositorTooltip")),
ANIMATION_L10N.getStr("player.somePropertiesOnCompositorTooltip")),
"The animation element has the right tooltip content");
});

Просмотреть файл

@ -14,6 +14,8 @@ Services.scriptloader.loadSubScript(
const FRAME_SCRIPT_URL = CHROME_URL_ROOT + "doc_frame_script.js";
const COMMON_FRAME_SCRIPT_URL = "chrome://devtools/content/shared/frame-script-utils.js";
const TAB_NAME = "animationinspector";
const ANIMATION_L10N =
new LocalizationHelper("devtools/locale/animationinspector.properties");
// Auto clean-up when a test ends
registerCleanupFunction(function* () {

Просмотреть файл

@ -8,10 +8,8 @@
// in an attribute.
const TEST_URL = URL_ROOT + "doc_markup_links.html";
const STRINGS = Services.strings
.createBundle("chrome://devtools/locale/inspector.properties");
const TOOLBOX_STRINGS = Services.strings
.createBundle("chrome://devtools/locale/toolbox.properties");
const TOOLBOX_L10N = new LocalizationHelper("devtools/locale/toolbox.properties");
// The test case array contains objects with the following properties:
// - selector: css selector for the node to select in the inspector
@ -28,9 +26,9 @@ const TEST_DATA = [{
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName(
linkFollowItemLabel: TOOLBOX_L10N.getStr(
"toolbox.viewCssSourceInStyleEditor.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
linkCopyItemLabel: INSPECTOR_L10N.getStr(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "link[rel=icon]",
@ -38,9 +36,9 @@ const TEST_DATA = [{
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: STRINGS.GetStringFromName(
linkFollowItemLabel: INSPECTOR_L10N.getStr(
"inspector.menu.openUrlInNewTab.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
linkCopyItemLabel: INSPECTOR_L10N.getStr(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "link",
@ -54,17 +52,17 @@ const TEST_DATA = [{
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: false,
linkFollowItemLabel: STRINGS.formatStringFromName(
"inspector.menu.selectElement.label", ["name"], 1)
linkFollowItemLabel: INSPECTOR_L10N.getFormatStr(
"inspector.menu.selectElement.label", "name")
}, {
selector: "script",
attributeName: "src",
popupNodeSelector: ".link",
isLinkFollowItemVisible: true,
isLinkCopyItemVisible: true,
linkFollowItemLabel: TOOLBOX_STRINGS.GetStringFromName(
linkFollowItemLabel: TOOLBOX_L10N.getStr(
"toolbox.viewJsSourceInDebugger.label"),
linkCopyItemLabel: STRINGS.GetStringFromName(
linkCopyItemLabel: INSPECTOR_L10N.getStr(
"inspector.menu.copyUrlToClipboard.label")
}, {
selector: "p[for]",

Просмотреть файл

@ -22,7 +22,7 @@ function* addNewRuleFromContextMenu(inspector, view) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, view.element);
let menuitemAddRule = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.addNewRule"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.addNewRule"));
ok(menuitemAddRule.visible, "Add rule is visible");

Просмотреть файл

@ -17,9 +17,6 @@ const CONTENT = `
</body>
`;
const STRINGS = Services.strings
.createBundle("chrome://devtools-shared/locale/styleinspector.properties");
add_task(function* () {
let tab = yield addTab("data:text/html;charset=utf-8," + CONTENT);
@ -36,13 +33,13 @@ function checkRuleViewContent({styleDocument}) {
is(headers.length, 3, "There are 3 headers for inherited rules");
is(headers[0].textContent,
STRINGS.formatStringFromName("rule.inheritedFrom", ["p"], 1),
STYLE_INSPECTOR_L10N.getFormatStr("rule.inheritedFrom", "p"),
"The first header is correct");
is(headers[1].textContent,
STRINGS.formatStringFromName("rule.inheritedFrom", ["div"], 1),
STYLE_INSPECTOR_L10N.getFormatStr("rule.inheritedFrom", "div"),
"The second header is correct");
is(headers[2].textContent,
STRINGS.formatStringFromName("rule.inheritedFrom", ["body"], 1),
STYLE_INSPECTOR_L10N.getFormatStr("rule.inheritedFrom", "body"),
"The third header is correct");
let rules = styleDocument.querySelectorAll(".ruleview-rule");
@ -50,17 +47,14 @@ function checkRuleViewContent({styleDocument}) {
for (let rule of rules) {
let selector = rule.querySelector(".ruleview-selectorcontainer");
is(selector.textContent,
STRINGS.GetStringFromName("rule.sourceElement"),
is(selector.textContent, STYLE_INSPECTOR_L10N.getStr("rule.sourceElement"),
"The rule's selector is correct");
let propertyNames = [...rule.querySelectorAll(".ruleview-propertyname")];
is(propertyNames.length, 1,
"There's only one property name, as expected");
is(propertyNames.length, 1, "There's only one property name, as expected");
let propertyValues = [...rule.querySelectorAll(".ruleview-propertyvalue")];
is(propertyValues.length, 1,
"There's only one property value, as expected");
is(propertyValues.length, 1, "There's only one property value, as expected");
}
}

Просмотреть файл

@ -61,7 +61,7 @@ function* testMdnContextMenuItemVisibility(view) {
info("Creating context menu with " + node + " as popupNode");
let allMenuItems = openStyleContextMenuAndGetAllItems(view, node);
let menuitemShowMdnDocs = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.showMdnDocs"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.showMdnDocs"));
let isVisible = menuitemShowMdnDocs.visible;
let shouldBeVisible = isPropertyNameNode(node);

Просмотреть файл

@ -45,7 +45,7 @@ add_task(function* () {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, nameSpan.firstChild);
let menuitemShowMdnDocs = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.showMdnDocs"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.showMdnDocs"));
let cssDocs = view.tooltips.cssDocs;

Просмотреть файл

@ -105,7 +105,7 @@ function* testMdnContextMenuItemVisibility(view, shouldBeVisible) {
let node = root.querySelector("." + PROPERTY_NAME_CLASS).firstChild;
let allMenuItems = openStyleContextMenuAndGetAllItems(view, node);
let menuitemShowMdnDocs = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.showMdnDocs"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.showMdnDocs"));
let isVisible = menuitemShowMdnDocs.visible;
is(isVisible, shouldBeVisible,

Просмотреть файл

@ -215,21 +215,21 @@ add_task(function* () {
function* checkCopyStyle(view, node, menuItemLabel, expectedPattern, visible) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, node);
let menuItem = allMenuItems.find(item =>
item.label === _STRINGS.GetStringFromName(menuItemLabel));
item.label === STYLE_INSPECTOR_L10N.getStr(menuItemLabel));
let menuitemCopy = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copy"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
let menuitemCopyLocation = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyLocation"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyLocation"));
let menuitemCopyPropertyDeclaration = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyPropertyDeclaration"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyPropertyDeclaration"));
let menuitemCopyPropertyName = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyPropertyName"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyPropertyName"));
let menuitemCopyPropertyValue = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyPropertyValue"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyPropertyValue"));
let menuitemCopySelector = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copySelector"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copySelector"));
let menuitemCopyRule = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyRule"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyRule"));
ok(menuitemCopy.disabled,
"Copy disabled is as expected: true");

Просмотреть файл

@ -16,10 +16,7 @@ add_task(function* () {
let elementStyle = view._elementStyle;
let _strings = Services.strings
.createBundle("chrome://devtools-shared/locale/styleinspector.properties");
let inline = _strings.GetStringFromName("rule.sourceInline");
let inline = STYLE_INSPECTOR_L10N.getStr("rule.sourceInline");
is(elementStyle.rules.length, 3, "Should have 3 rules.");
is(elementStyle.rules[0].title, inline, "check rule 0 title");

Просмотреть файл

@ -69,7 +69,7 @@ function* checkCopySelection(view) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);
let menuitemCopy = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copy"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
ok(menuitemCopy.visible,
"Copy menu item is displayed as expected");
@ -103,7 +103,7 @@ function* checkSelectAll(view) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, prop);
let menuitemCopy = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copy"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
ok(menuitemCopy.visible,
"Copy menu item is displayed as expected");
@ -131,7 +131,7 @@ function* checkCopyEditorValue(view) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, editor.input);
let menuitemCopy = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copy"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copy"));
ok(menuitemCopy.visible,
"Copy menu item is displayed as expected");

Просмотреть файл

@ -19,8 +19,8 @@ var {getInplaceEditorForSpan: inplaceEditor} =
const ROOT_TEST_DIR = getRootDirectory(gTestPath);
const FRAME_SCRIPT_URL = ROOT_TEST_DIR + "doc_frame_script.js";
const _STRINGS = Services.strings.createBundle(
"chrome://devtools-shared/locale/styleinspector.properties");
const STYLE_INSPECTOR_L10N = new LocalizationHelper("chrome://devtools-shared/locale/styleinspector.properties");
registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.defaultColorUnit");

Просмотреть файл

@ -35,7 +35,7 @@ function* testCopyToClipboard(inspector, view) {
let allMenuItems = openStyleContextMenuAndGetAllItems(view, element);
let menuitemCopyColor = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyColor"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyColor"));
ok(menuitemCopyColor.visible, "Copy color is visible");

Просмотреть файл

@ -5,17 +5,13 @@
/* Tests both Copy URL and Copy Data URL context menu items */
const PROPERTIES_URL = "chrome://devtools-shared/locale/styleinspector.properties";
const TEST_DATA_URI = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=";
// Invalid URL still needs to be reachable otherwise getImageDataUrl will
// timeout. DevTools chrome:// URLs aren't content accessible, so use some
// random resource:// URL here.
const INVALID_IMAGE_URI = "resource://devtools/client/definitions.js";
const ERROR_MESSAGE = Services.strings
.createBundle(PROPERTIES_URL)
.GetStringFromName("styleinspector.copyImageDataUrlError");
const ERROR_MESSAGE = STYLE_INSPECTOR_L10N.getStr("styleinspector.copyImageDataUrlError");
add_task(function* () {
const TEST_URI = `<style type="text/css">
@ -79,9 +75,9 @@ function* testCopyUrlToClipboard({view, inspector}, type, selector, expected) {
info("Simulate right click on the background-image URL");
let allMenuItems = openStyleContextMenuAndGetAllItems(view, imageLink);
let menuitemCopyUrl = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyUrl"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyUrl"));
let menuitemCopyImageDataUrl = allMenuItems.find(item => item.label ===
_STRINGS.GetStringFromName("styleinspector.contextmenu.copyImageDataUrl"));
STYLE_INSPECTOR_L10N.getStr("styleinspector.contextmenu.copyImageDataUrl"));
info("Context menu is displayed");
ok(menuitemCopyUrl.visible,

Просмотреть файл

@ -21,8 +21,7 @@ const TEST_URL_ROOT_SSL =
"https://example.com/browser/devtools/client/inspector/shared/test/";
const ROOT_TEST_DIR = getRootDirectory(gTestPath);
const FRAME_SCRIPT_URL = ROOT_TEST_DIR + "doc_frame_script.js";
const _STRINGS = Services.strings.createBundle(
"chrome://devtools-shared/locale/styleinspector.properties");
const STYLE_INSPECTOR_L10N = new LocalizationHelper("chrome://devtools-shared/locale/styleinspector.properties");
// Clean-up all prefs that might have been changed during a test run
// (safer here because if the test fails, then the pref is never reverted)

Просмотреть файл

@ -34,6 +34,9 @@ Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/inspector/test/shared-head.js",
this);
const {LocalizationHelper} = require("devtools/client/shared/l10n");
const INSPECTOR_L10N = new LocalizationHelper("devtools/locale/inspector.properties");
flags.testing = true;
registerCleanupFunction(() => {
flags.testing = false;
@ -228,9 +231,8 @@ var focusSearchBoxUsingShortcut = Task.async(function* (panelWin, callback) {
let focused = once(searchBox, "focus");
panelWin.focus();
let strings = Services.strings.createBundle(
"chrome://devtools/locale/inspector.properties");
synthesizeKeyShortcut(strings.GetStringFromName("inspector.searchHTML.key"));
synthesizeKeyShortcut(INSPECTOR_L10N.getStr("inspector.searchHTML.key"));
yield focused;