Bug 1509057. Disable <input type=number> support for grouping separators in user input. r=mats

Differential Revision: https://phabricator.services.mozilla.com/D12554

--HG--
extra : rebase_source : 7ae34793e15f626df16bba225c2077c05135d568
extra : amend_source : 429cf996b8c66a17025a6eeb8b1c2fce6a58a614
This commit is contained in:
Jonathan Watt 2018-11-02 10:10:42 +00:00
Родитель 96f02e3f50
Коммит 8009877bd7
5 изменённых файлов: 15 добавлений и 10 удалений

Просмотреть файл

@ -16,15 +16,17 @@ var tests = [
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
@ -33,6 +35,6 @@ var tests = [
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" }
];

Просмотреть файл

@ -40,8 +40,8 @@ function runTest(test) {
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);

Просмотреть файл

@ -44,7 +44,7 @@ function runTest(test) {
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`);

Просмотреть файл

@ -145,6 +145,9 @@ ICUUtils::ParseNumber(nsAString& aValue,
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");

Просмотреть файл

@ -69,8 +69,8 @@
#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"