Bug 1294220 - fix tests relying on L10N.stringBundle
MozReview-Commit-ID: CicWir5vKu
--- a/devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
+++ b/devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
@@ -1,40 +1,32 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
/**
* Tests if the preferences and localization objects work correctly.
*/
function test() {
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
info("Starting test... ");
ok(aMonitor.panelWin.L10N,
"Should have a localization object available on the panel window.");
ok(aMonitor.panelWin.Prefs,
"Should have a preferences object available on the panel window.");
function testL10N() {
let { L10N } = aMonitor.panelWin;
-
- ok(L10N.stringBundle,
- "The localization object should have a string bundle available.");
-
- let bundleName = "chrome://devtools/locale/netmonitor.properties";
- let stringBundle = Services.strings.createBundle(bundleName);
-
- is(L10N.getStr("netmonitor.label"),
- stringBundle.GetStringFromName("netmonitor.label"),
- "The getStr() method didn't return the expected string.");
-
- is(L10N.getFormatStr("networkMenu.totalMS", "foo"),
- stringBundle.formatStringFromName("networkMenu.totalMS", ["foo"], 1),
- "The getFormatStr() method didn't return the expected string.");
+ is(typeof L10N.getStr("netmonitor.label"), "string",
+ "The getStr() method didn't return a valid string.");
+ is(typeof L10N.getFormatStr("networkMenu.totalMS", "foo"), "string",
+ "The getFormatStr() method didn't return a valid string.");
}
function testPrefs() {
let { Prefs } = aMonitor.panelWin;
is(Prefs.networkDetailsWidth,
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
"Getting a pref should work correctly.");
--- a/devtools/client/projecteditor/lib/helpers/l10n.js
+++ b/devtools/client/projecteditor/lib/helpers/l10n.js
@@ -1,25 +1,26 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
/**
* This file contains helper functions for internationalizing projecteditor strings
*/
-const { Cu, Cc, Ci } = require("chrome");
const { LocalizationHelper } = require("devtools/client/shared/l10n");
const ITCHPAD_STRINGS_URI = "chrome://devtools/locale/projecteditor.properties";
-const L10N = new LocalizationHelper(ITCHPAD_STRINGS_URI).stringBundle;
+const L10N = new LocalizationHelper(ITCHPAD_STRINGS_URI);
function getLocalizedString(name) {
try {
- return L10N.GetStringFromName(name);
+ return L10N.getStr(name);
} catch (ex) {
console.log("Error reading '" + name + "'");
throw new Error("l10n error with " + name);
}
}
exports.getLocalizedString = getLocalizedString;