Bug 1509057. Disable <input type=number> support for grouping separators in user input. r=mats
authorJonathan Watt <jwatt@jwatt.org>
Fri, 02 Nov 2018 10:10:42 +0000
changeset 506817 27fe8b1767f2acc452f47ca8a948902b0ebf7a51
parent 506816 53c79413e7c6bf6d1ce68b8bb307c9c2a71c8ac5
child 506818 1a235d5c636775aff8cbaa50b55a6e8a07e40060
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1509057
milestone65.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 1509057. Disable <input type=number> support for grouping separators in user input. r=mats Differential Revision: https://phabricator.services.mozilla.com/D12554
dom/html/test/forms/test_input_number_data.js
dom/html/test/forms/test_input_number_l10n.html
dom/html/test/forms/test_input_number_validation.html
intl/unicharutil/util/ICUUtils.cpp
layout/generic/nsGfxScrollFrame.cpp
--- a/dom/html/test/forms/test_input_number_data.js
+++ b/dom/html/test/forms/test_input_number_data.js
@@ -11,28 +11,30 @@ var tests = [
   { desc: "French",
     langTag: "fr-FR", inputWithGrouping: "123 456,78",
     inputWithoutGrouping: "123456,78", value: 123456.78
   },
   { desc: "German",
     langTag: "de", inputWithGrouping: "123.456,78",
     inputWithoutGrouping: "123456,78", value: 123456.78
   },
+  // Bug 1509057 disables grouping separators for now, so this test isn't
+  // currently relevant.
   // Extra german test to check that a locale that uses '.' as its grouping
   // separator doesn't result in it being invalid (due to step mismatch) due
   // to the de-localization code mishandling numbers that look like other
   // numbers formatted for English speakers (i.e. treating this as 123.456
   // instead of 123456):
-  { desc: "German (test 2)",
-    langTag: "de", inputWithGrouping: "123.456",
-    inputWithoutGrouping: "123456", value: 123456
-  },
+  //{ desc: "German (test 2)",
+  //  langTag: "de", inputWithGrouping: "123.456",
+  //  inputWithoutGrouping: "123456", value: 123456
+  //},
   { desc: "Hebrew",
     langTag: "he", inputWithGrouping: "123,456.78",
     inputWithoutGrouping: "123456.78", value: 123456.78
   },
 ];
 
 var invalidTests = [
   // Right now this will pass in a 'de' build, but not in the 'en' build that
-  // are used for testing. See bug .
+  // are used for testing. See bug 1216831.
   // { desc: "Invalid German", langTag: "de", input: "12.34" }
 ];
--- a/dom/html/test/forms/test_input_number_l10n.html
+++ b/dom/html/test/forms/test_input_number_l10n.html
@@ -35,18 +35,18 @@ SimpleTest.waitForFocus(function() {
 var elem;
 
 function runTest(test) {
   elem.lang = test.langTag;
   elem.value = 0;
   elem.focus();
   elem.select();
   sendString(test.inputWithGrouping);
-  is(elem.value, String(test.value), "Test " + test.desc + " ('" + test.langTag +
-                                     "') localization with grouping separator");
+  is(elem.value, "", "Test " + test.desc + " ('" + test.langTag +
+                     "') localization with grouping separator");
   elem.value = 0;
   elem.select();
   sendString(test.inputWithoutGrouping);
   is(elem.value, String(test.value), "Test " + test.desc + " ('" + test.langTag +
                                      "') localization without grouping separator");
 }
 
 function runInvalidInputTest(test) {
--- a/dom/html/test/forms/test_input_number_validation.html
+++ b/dom/html/test/forms/test_input_number_validation.html
@@ -39,17 +39,17 @@ function runTest(test) {
   elem.lang = test.langTag;
 
   gInvalid = false; // reset
   var desc = `${test.desc}  (lang='${test.langTag}', id='${elem.id}')`;
   elem.value = 0;
   elem.focus();
   elem.select();
   sendString(test.inputWithGrouping);
-  checkIsValid(elem, `${desc} with grouping separator`);
+  checkIsInvalid(elem, `${desc} with grouping separator`);
   sendChar("a");
   checkIsInvalid(elem, `${desc} with grouping separator`);
 
   gInvalid = false; // reset
   elem.value = 0;
   elem.select();
   sendString(test.inputWithoutGrouping);
   checkIsValid(elem, `${desc} without grouping separator`);
--- a/intl/unicharutil/util/ICUUtils.cpp
+++ b/intl/unicharutil/util/ICUUtils.cpp
@@ -140,16 +140,19 @@ ICUUtils::ParseNumber(nsAString& aValue,
   uint32_t length = aValue.Length();
 
   nsAutoCString langTag;
   aLangTags.GetNext(langTag);
   while (!langTag.IsEmpty()) {
     UErrorCode status = U_ZERO_ERROR;
     AutoCloseUNumberFormat format(unum_open(UNUM_DECIMAL, nullptr, 0,
                                             langTag.get(), nullptr, &status));
+    if (!LocaleNumberGroupingIsEnabled()) {
+      unum_setAttribute(format.rwget(), UNUM_GROUPING_USED, UBool(0));
+    }
     int32_t parsePos = 0;
     static_assert(sizeof(UChar) == 2 && sizeof(nsAString::char_type) == 2,
                   "Unexpected character size - the following cast is unsafe");
     double val = unum_parseDouble(format,
                                   (const UChar*)PromiseFlatString(aValue).get(),
                                   length, &parsePos, &status);
     if (U_SUCCESS(status) && parsePos == (int32_t)length) {
       return val;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -64,18 +64,18 @@
 #include "ScrollAnimationPhysics.h"
 #include "ScrollAnimationBezierPhysics.h"
 #include "ScrollAnimationMSDPhysics.h"
 #include "ScrollSnap.h"
 #include "UnitTransforms.h"
 #include "nsPluginFrame.h"
 #include "nsSliderFrame.h"
 #include "mozilla/layers/APZCCallbackHelper.h"
-#include <mozilla/layers/AxisPhysicsModel.h>
-#include <mozilla/layers/AxisPhysicsMSDModel.h>
+#include "mozilla/layers/AxisPhysicsModel.h"
+#include "mozilla/layers/AxisPhysicsMSDModel.h"
 #include "mozilla/layers/LayerTransactionChild.h"
 #include "mozilla/layers/ScrollLinkedEffectDetector.h"
 #include "mozilla/Unused.h"
 #include "LayersLogging.h"  // for Stringify
 #include <algorithm>
 #include <cstdlib> // for std::abs(int/long)
 #include <cmath> // for std::abs(float/double)