Merge mozilla-central to autoland. a=merge
authorDaniel Varga <dvarga@mozilla.com>
Sat, 29 Dec 2018 11:38:36 +0200
changeset 509221 2dc4dd76f57a6dee78d33c92f45599fcc57db27d
parent 509220 d44fc9b8912588dbf24a34dac85404e3b0056b73 (current diff)
parent 509202 2367d9d7566dd86d491be68a162c44808d4f152f (diff)
child 509222 9297836c0b83a03b9c645c899621b0d3af4876d3
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone66.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
Merge mozilla-central to autoland. a=merge
new file mode 100644
--- /dev/null
+++ b/intl/icu-patches/bug-1504656-relativetimeformat-plural-other-fallback.diff
@@ -0,0 +1,45 @@
+Workaround for https://unicode-org.atlassian.net/browse/ICU-20253
+
+https://bugzilla.mozilla.org/show_bug.cgi?id=1504656
+
+diff --git a/intl/icu/source/i18n/reldatefmt.cpp b/intl/icu/source/i18n/reldatefmt.cpp
+--- a/intl/icu/source/i18n/reldatefmt.cpp
++++ b/intl/icu/source/i18n/reldatefmt.cpp
+@@ -157,24 +157,30 @@ const UnicodeString& RelativeDateTimeCac
+  }
+ 
+  // Use fallback cache for SimpleFormatter relativeUnits.
+  const SimpleFormatter* RelativeDateTimeCacheData::getRelativeDateTimeUnitFormatter(
+         int32_t fStyle,
+         URelativeDateTimeUnit unit,
+         int32_t pastFutureIndex,
+         int32_t pluralUnit) const {
+-    int32_t style = fStyle;
+-    do {
+-        if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
+-            return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
++    while (true) {
++        int32_t style = fStyle;
++        do {
++            if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
++                return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
++            }
++            style = fallBackCache[style];
++        } while (style != -1);
++
++        if (pluralUnit == StandardPlural::OTHER) {
++            return nullptr;  // No formatter found.
+         }
+-        style = fallBackCache[style];
+-    } while (style != -1);
+-    return nullptr;  // No formatter found.
++        pluralUnit = StandardPlural::OTHER;
++    }
+  }
+ 
+ static UBool getStringWithFallback(
+         const UResourceBundle *resource,
+         const char *key,
+         UnicodeString &result,
+         UErrorCode &status) {
+     int32_t len = 0;
--- a/intl/icu/source/i18n/reldatefmt.cpp
+++ b/intl/icu/source/i18n/reldatefmt.cpp
@@ -157,24 +157,30 @@ const UnicodeString& RelativeDateTimeCac
  }
 
  // Use fallback cache for SimpleFormatter relativeUnits.
  const SimpleFormatter* RelativeDateTimeCacheData::getRelativeDateTimeUnitFormatter(
         int32_t fStyle,
         URelativeDateTimeUnit unit,
         int32_t pastFutureIndex,
         int32_t pluralUnit) const {
-    int32_t style = fStyle;
-    do {
-        if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
-            return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
+    while (true) {
+        int32_t style = fStyle;
+        do {
+            if (relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit] != nullptr) {
+                return relativeUnitsFormatters[style][unit][pastFutureIndex][pluralUnit];
+            }
+            style = fallBackCache[style];
+        } while (style != -1);
+
+        if (pluralUnit == StandardPlural::OTHER) {
+            return nullptr;  // No formatter found.
         }
-        style = fallBackCache[style];
-    } while (style != -1);
-    return nullptr;  // No formatter found.
+        pluralUnit = StandardPlural::OTHER;
+    }
  }
 
 static UBool getStringWithFallback(
         const UResourceBundle *resource,
         const char *key,
         UnicodeString &result,
         UErrorCode &status) {
     int32_t len = 0;
--- a/intl/update-icu.sh
+++ b/intl/update-icu.sh
@@ -81,16 +81,17 @@ find ${icu_dir}/source/data/zone \
     -name tzdbNames.txt -prune -or \
     -name '*.txt' -print | xargs sed -i '/^\s*zoneStrings{/{N; s/^\s*zoneStrings{\n\s*}// }; /^$/d'
 
 for patch in \
  bug-915735 \
  suppress-warnings.diff \
  bug-1172609-timezone-recreateDefault.diff \
  bug-1198952-workaround-make-3.82-bug.diff \
+ bug-1504656-relativetimeformat-plural-other-fallback.diff \
 ; do
   echo "Applying local patch $patch"
   patch -d ${icu_dir}/../../ -p1 --no-backup-if-mismatch < ${icu_dir}/../icu-patches/$patch
 done
 
 topsrcdir=`dirname $0`/../
 python ${topsrcdir}/js/src/tests/non262/String/make-normalize-generateddata-input.py $topsrcdir
 
--- a/js/src/builtin/intl/DateTimeFormat.js
+++ b/js/src/builtin/intl/DateTimeFormat.js
@@ -867,20 +867,20 @@ function Intl_DateTimeFormat_resolvedOpt
         locale: internals.locale,
         calendar: internals.calendar,
         numberingSystem: internals.numberingSystem,
         timeZone: internals.timeZone,
     };
 
     if (internals.mozExtensions) {
         if (internals.patternOption !== undefined) {
-            result.pattern = internals.pattern;
+            _DefineDataProperty(result, "pattern", internals.pattern);
         } else if (internals.dateStyle || internals.timeStyle) {
-            result.dateStyle = internals.dateStyle;
-            result.timeStyle = internals.timeStyle;
+            _DefineDataProperty(result, "dateStyle", internals.dateStyle);
+            _DefineDataProperty(result, "timeStyle", internals.timeStyle);
         }
     }
 
     resolveICUPattern(internals.pattern, result);
 
     // Step 6.
     return result;
 }
@@ -911,16 +911,17 @@ function resolveICUPattern(pattern, resu
                 count++;
             }
 
             var value;
             switch (c) {
             // "text" cases
             case "G":
             case "E":
+            case "c":
             case "z":
             case "v":
             case "V":
                 if (count <= 3)
                     value = "short";
                 else if (count === 4)
                     value = "long";
                 else
@@ -958,16 +959,17 @@ function resolveICUPattern(pattern, resu
                 // skip other pattern characters and literal text
             }
 
             // Map ICU pattern characters back to the corresponding date-time
             // components of DateTimeFormat. See
             // http://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
             switch (c) {
             case "E":
+            case "c":
                 weekday = value;
                 break;
             case "G":
                 era = value;
                 break;
             case "y":
                 year = value;
                 break;
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/Intl/DateTimeFormat/standalone-month.js
@@ -0,0 +1,11 @@
+// |reftest| skip-if(!this.hasOwnProperty("Intl"))
+
+for (let weekday of ["long", "short", "narrow"]) {
+    let dtf = new Intl.DateTimeFormat("en", {weekday});
+    let options = dtf.resolvedOptions();
+
+    assertEq(options.weekday, weekday);
+}
+
+if (typeof reportCompare === "function")
+    reportCompare(0, 0, "ok");
new file mode 100644
--- /dev/null
+++ b/js/src/tests/non262/Intl/RelativeTimeFormat/locale-fallback-handling.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Intl"))
+/* 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/. */
+
+// In locales that don't have a relative-date/time formatter -- and presently
+// "ak" is such a locale -- behavior is expected to fall back to the root-locale
+// formatter.  This test verifies such fallback works as long as "ak" satisfies
+// these properties; "ak" may safely be changed to a different locale if that
+// ever changes.  See bug 1504656.
+assertEq(new Intl.RelativeTimeFormat("ak").format(1, "second"),
+         "+1 s");
+
+if (typeof reportCompare === "function")
+  reportCompare(0, 0, 'ok');