Bug 1294220 - fix tests relying on L10N.stringBundle draft
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 18 Aug 2016 15:54:37 +0200
changeset 403228 7e2b47901180ad7655ed814b32bc26222727d690
parent 403227 5c21e32ff71adcec90169655c47b2885631fb4ea
child 403336 098d1f2579249ce4b07de720c88c4be40bd542ad
push id26865
push userjdescottes@mozilla.com
push dateFri, 19 Aug 2016 12:11:19 +0000
bugs1294220
milestone51.0a1
Bug 1294220 - fix tests relying on L10N.stringBundle MozReview-Commit-ID: CicWir5vKu
devtools/client/netmonitor/test/browser_net_prefs-and-l10n.js
devtools/client/projecteditor/lib/helpers/l10n.js
--- 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;