v8/test/intl/regress-1041319.js
Frank Tang 545f820c28 Reland "[Intl] Fix RelativeTimeFormat fatal"
Fix the gc_stress problem in Original by moving the
NewStringFromAsciiChecked before the cast.

This is a reland of a872c393c6

Original change's description:
> [Intl] Fix RelativeTimeFormat fatal
>
> Intl.RelativeTimeFormat constructor crash while the locale or
> numberingSystem contains an "algorithmic" numberingSystem.
> Fix by fallback to the locale without the nu
>
> Bug: chromium:1041319
> Change-Id: Ica520e8dec6ace21264504274b92cb2c3d16286f
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2055970
> Reviewed-by: Shu-yu Guo <syg@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Commit-Queue: Frank Tang <ftang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#66276}

Bug: chromium:1041319
Change-Id: I97563c5dbac1842a4e740e2450070471ea2681a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2057761
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66315}
2020-02-18 18:29:08 +00:00

47 lines
1.3 KiB
JavaScript

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test to check "algorithmic" numbering systems stated in UTS35 but not
// mandated by ECMA402 won't crash.
// The entries which type is "algorithmic" in
// https://github.com/unicode-org/cldr/blob/master/common/supplemental/numberingSystems.xml
// These are numbering systems which is not supported in ECMA402 but we should
// not crash.
let algorithmicNumberingSystems = [
"armn",
"armnlow",
"cyrl",
"ethi",
"geor",
"grek",
"greklow",
"hanidays",
"hans",
"hansfin",
"hant",
"hantfin",
"hebr",
"jpan",
"jpanfin",
"jpanyear",
"roman",
"romanlow",
"taml",
];
for (numberingSystem of algorithmicNumberingSystems) {
let baseLocale = "en";
let locale = baseLocale + "-u-nu-" + numberingSystem;
// Ensure the creation won't crash
let rtf = new Intl.RelativeTimeFormat(locale);
let rtf2 = new Intl.RelativeTimeFormat(baseLocale, {numberingSystem});
let dtf = new Intl.DateTimeFormat(locale);
let dtf2 = new Intl.DateTimeFormat(baseLocale, {numberingSystem});
let nf = new Intl.NumberFormat(locale);
let nf2 = new Intl.NumberFormat(baseLocale, {numberingSystem});
}