Bug 1517496 - Make misused string test also check fluent files, r=jaws,flod
authorYuan Cheng <chengy12@msu.edu>
Thu, 07 Feb 2019 10:38:24 +0000
changeset 457597 b1514d57bcdc98b0accb4f727ad0d91380ea5f28
parent 457596 c90fe3ee1999efedec2bddca08db72b8975fc561
child 457598 ce0770fa1ddfcd095a4e6fcda578010458f9fc0e
push id35516
push userrmaries@mozilla.com
push dateFri, 08 Feb 2019 04:23:26 +0000
treeherdermozilla-central@d599d1a73a3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, flod
bugs1517496
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517496 - Make misused string test also check fluent files, r=jaws,flod Differential Revision: https://phabricator.services.mozilla.com/D18524
browser/base/content/test/static/browser_misused_characters_in_strings.js
browser/locales/en-US/browser/newInstallPage.ftl
devtools/client/aboutdebugging-new/tmp-locale/en-US/aboutdebugging.notftl
--- a/browser/base/content/test/static/browser_misused_characters_in_strings.js
+++ b/browser/base/content/test/static/browser_misused_characters_in_strings.js
@@ -256,11 +256,48 @@ add_task(async function checkAllTheDTDs(
   }
 
   // This support DTD file supplies a string with a newline to make sure
   // the regex in checkDTD works correctly for that case.
   let dtdLocation = gTestPath.replace(/\/[^\/]*$/i, "/bug1262648_string_with_newlines.dtd");
   await checkDTD(dtdLocation);
 });
 
+add_task(async function checkAllTheFluents() {
+  let uris = await getAllTheFiles(".ftl");
+  let {FluentResource} = ChromeUtils.import("resource://gre/modules/Fluent.jsm", {});
+  let domParser = new DOMParser();
+  for (let uri of uris) {
+    let rawContents = await fetchFile(uri.spec);
+    let resource = FluentResource.fromString(rawContents);
+    if (!resource) {
+      return;
+    }
+
+    for (let [key, val] of resource) {
+      CheckError(domParser, uri, key, val);
+    }
+  }
+});
+
+/**
+ * A recursive function which can check if a value is valid
+ *
+ * @param domParser The DOMParser object
+ * @param uri The URI of the locale file
+ * @param key The key of the entity that is being checked
+ * @param val The value of the entity that is being checked
+ */
+function CheckError(domParser, uri, key, val) {
+  if (typeof val === "string") {
+    let stripped_val = domParser.parseFromString(val, "text/html").documentElement.textContent;
+    testForErrors(uri.spec, key, stripped_val);
+  } else if (typeof val === "object" && val) {
+    let new_vals = Object.values(val);
+    for (let new_val of new_vals) {
+      CheckError(domParser, uri, key, new_val);
+    }
+  }
+}
+
 add_task(async function ensureWhiteListIsEmpty() {
   is(gWhitelist.length, 0, "No remaining whitelist entries exist");
 });
--- a/browser/locales/en-US/browser/newInstallPage.ftl
+++ b/browser/locales/en-US/browser/newInstallPage.ftl
@@ -23,10 +23,10 @@ resources = Resources:
 support-link = Using the Profile Manager - Support Article
 
 sync-header = Sign in or create a { -fxaccount-brand-name }
 sync-label = Enter your email
 sync-input =
   .placeholder = Email
 sync-button = Continue
 sync-terms = By proceeding, you agree to the <a data-l10n-name="terms">Terms of Service</a> and <a data-l10n-name="privacy">Privacy Notice</a>.
-sync-first = First time using { -sync-brand-name }? You'll need to sign in to every installation of Firefox to sync your information.
+sync-first = First time using { -sync-brand-name }? You’ll need to sign in to every installation of Firefox to sync your information.
 sync-learn = Learn more
--- a/devtools/client/aboutdebugging-new/tmp-locale/en-US/aboutdebugging.notftl
+++ b/devtools/client/aboutdebugging-new/tmp-locale/en-US/aboutdebugging.notftl
@@ -65,17 +65,17 @@ about-debugging-connect-title = Connect 
 
 # WiFi section of the Connect page
 about-debugging-connect-wifi =
   .title = Via WiFi
 
 # Temporary text displayed when wifi support is turned off via preferences.
 # { $pref } is the name of the preference that enables wifi
 # Do not localize
-about-debugging-connect-wifi-disabled = WiFi debugging currently under development. You can enable it with the preference "{ $pref }".
+about-debugging-connect-wifi-disabled = WiFi debugging currently under development. You can enable it with the preference “{ $pref }”.
 
 # WiFi section step by step guide
 about-debugging-connect-wifi-step-same-network = Ensure that your browser and device are on the same network
 
 # WiFi section step by step guide
 about-debugging-connect-wifi-step-open-firefox = Open Firefox for Android
 
 # WiFi section step by step guide
@@ -104,17 +104,17 @@ about-debugging-connect-usb-step-plug-de
 
 # Network section of the Connect page
 about-debugging-connect-network =
   .title = Via Network Location
 
 # Temporary text displayed when network location support is turned off via preferences.
 # { $pref } is the name of the preference that enables network locations
 # Do not localize
-about-debugging-connect-network-disabled = Network location support currently under development. You can enable it with the preference "{ $pref }".
+about-debugging-connect-network-disabled = Network location support currently under development. You can enable it with the preference “{ $pref }”.
 
 # Below are the titles for the various categories of debug targets that can be found
 # on "runtime" pages of about:debugging.
 # Title of the temporary extensions category (only available for "This Firefox" runtime).
 about-debugging-runtime-temporary-extensions = Temporary Extensions
 # Title of the extensions category.
 about-debugging-runtime-extensions = Extensions
 # Title of the tabs category.