Skip to content

Commit 887dfa7

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[environment] Register Intl.DurationFormat and its builtins
Bug: 487347678 Change-Id: I92fa5d5dccfcd3b5f5590ecea134265bb10d1190 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9064297 Reviewed-by: Manish Goregaokar <manishearth@google.com> Commit-Queue: Matthias Liedtke <mliedtke@google.com>
1 parent e12a171 commit 887dfa7

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ public class JavaScriptEnvironment: ComponentBase {
486486
registerObjectGroup(.jsIntlDisplayNames)
487487
registerObjectGroup(.jsIntlDisplayNamesConstructor)
488488
registerObjectGroup(.jsIntlDisplayNamesPrototype)
489+
registerObjectGroup(.jsIntlDurationFormat)
490+
registerObjectGroup(.jsIntlDurationFormatConstructor)
491+
registerObjectGroup(.jsIntlDurationFormatPrototype)
489492
registerObjectGroup(.jsIntlDateTimeFormat)
490493
registerObjectGroup(.jsIntlDateTimeFormatConstructor)
491494
registerObjectGroup(.jsIntlDateTimeFormatPrototype)
@@ -544,6 +547,7 @@ public class JavaScriptEnvironment: ComponentBase {
544547
registerEnumeration(OptionsBag.jsIntlDisplayNamesTypeEnum)
545548
registerEnumeration(OptionsBag.jsIntlDisplayNamesFallbackEnum)
546549
registerEnumeration(OptionsBag.jsIntlDisplayNamesLanguageDisplayEnum)
550+
registerEnumeration(OptionsBag.jsIntlDurationFormatStyleEnum)
547551
registerEnumeration(OptionsBag.jsIntlListFormatTypeEnum)
548552
registerEnumeration(OptionsBag.jsIntlNumberFormatStyleEnum)
549553
registerEnumeration(OptionsBag.jsIntlCurrencySystemEnum)
@@ -577,6 +581,7 @@ public class JavaScriptEnvironment: ComponentBase {
577581
registerOptionsBag(.jsIntlDateTimeFormatSettings)
578582
registerOptionsBag(.jsIntlCollatorSettings)
579583
registerOptionsBag(.jsIntlDisplayNamesSettings)
584+
registerOptionsBag(.jsIntlDurationFormatSettings)
580585
registerOptionsBag(.jsIntlListFormatSettings)
581586
registerOptionsBag(.jsIntlLocaleSettings)
582587
registerOptionsBag(.jsIntlNumberFormatSettings)
@@ -3440,7 +3445,7 @@ extension OptionsBag {
34403445
// Intl
34413446
extension ILType {
34423447
// Intl types
3443-
static let jsIntlObject = ILType.object(ofGroup: "Intl", withProperties: ["DateTimeFormat", "Collator", "DisplayNames", "ListFormat", "Locale", "NumberFormat", "PluralRules", "RelativeTimeFormat", "Segmenter"], withMethods: ["getCanonicalLocales", "supportedValuesOf"])
3448+
static let jsIntlObject = ILType.object(ofGroup: "Intl", withProperties: ["DateTimeFormat", "Collator", "DisplayNames", "DurationFormat", "ListFormat", "Locale", "NumberFormat", "PluralRules", "RelativeTimeFormat", "Segmenter"], withMethods: ["getCanonicalLocales", "supportedValuesOf"])
34443449

34453450
static let jsIntlLocale = ILType.object(ofGroup: "Intl.Locale", withProperties: ["baseName", "calendar", "caseFirst", "collation", "hourCycle", "language", "numberingSystem", "numeric", "region", "script", "variants"], withMethods: ["getCalendars", "getCollations", "getHourCycles", "getNumberingSystems", "getTextInfo", "getTimeZones", "getWeekInfo", "maximize", "minimize", "toString"])
34463451
static let jsIntlLocaleConstructor = ILType.functionAndConstructor([.plain(.jsIntlLocaleString), .opt(OptionsBag.jsIntlLocaleSettings.group.instanceType)] => .jsIntlLocale) + .object(ofGroup: "IntlLocaleConstructor", withProperties: ["prototype"], withMethods: [])
@@ -3451,6 +3456,9 @@ extension ILType {
34513456
static let jsIntlDisplayNames = ILType.object(ofGroup: "Intl.DisplayNames", withProperties: [], withMethods: ["of", "resolvedOptions"])
34523457
static let jsIntlDisplayNamesConstructor = ILType.functionAndConstructor([.plain(.jsIntlLocaleLike), .plain(OptionsBag.jsIntlDisplayNamesSettings.group.instanceType)] => .jsIntlDisplayNames) + .object(ofGroup: "IntlDisplayNamesConstructor", withProperties: ["prototype"], withMethods: ["supportedLocalesOf"])
34533458

3459+
static let jsIntlDurationFormat = ILType.object(ofGroup: "Intl.DurationFormat", withProperties: [], withMethods: ["format", "formatToParts", "resolvedOptions"])
3460+
static let jsIntlDurationFormatConstructor = ILType.functionAndConstructor([.opt(.jsIntlLocaleLike), .opt(OptionsBag.jsIntlDurationFormatSettings.group.instanceType)] => .jsIntlDurationFormat) + .object(ofGroup: "IntlDurationFormatConstructor", withProperties: ["prototype"], withMethods: ["supportedLocalesOf"])
3461+
34543462
static let jsIntlDateTimeFormat = ILType.object(ofGroup: "Intl.DateTimeFormat", withProperties: [], withMethods: ["format", "formatRange", "formatRangeToParts", "formatToParts", "resolvedOptions"])
34553463
static let jsIntlDateTimeFormatConstructor = ILType.functionAndConstructor([.opt(.jsIntlLocaleLike), .opt(OptionsBag.jsIntlDateTimeFormatSettings.group.instanceType)] => .jsIntlDateTimeFormat) + .object(ofGroup: "IntlDateTimeFormatConstructor", withProperties: ["prototype"], withMethods: ["supportedLocalesOf"])
34563464

@@ -3491,6 +3499,7 @@ extension ObjectGroup {
34913499
"Collator" : .jsIntlCollatorConstructor,
34923500
"DateTimeFormat" : .jsIntlDateTimeFormatConstructor,
34933501
"DisplayNames" : .jsIntlDisplayNamesConstructor,
3502+
"DurationFormat" : .jsIntlDurationFormatConstructor,
34943503
"ListFormat" : .jsIntlListFormatConstructor,
34953504
"Locale" : .jsIntlLocaleConstructor,
34963505
"NumberFormat" : .jsIntlNumberFormatConstructor,
@@ -3561,6 +3570,34 @@ extension ObjectGroup {
35613570
]
35623571
)
35633572

3573+
static let jsIntlDurationFormat = ObjectGroup(
3574+
name: "Intl.DurationFormat",
3575+
instanceType: .jsIntlDurationFormat,
3576+
properties: [:],
3577+
methods: [
3578+
"format": [.plain(ObjectGroup.jsTemporalDurationLikeObject.instanceType)] => .string,
3579+
"formatToParts": [.plain(ObjectGroup.jsTemporalDurationLikeObject.instanceType)] => .jsArray,
3580+
"resolvedOptions": [] => .object(withProperties: ["locale", "numberingSystem", "style", "fractionalDigits"]),
3581+
]
3582+
)
3583+
3584+
static let jsIntlDurationFormatPrototype = createPrototypeObjectGroup(
3585+
jsIntlDurationFormat,
3586+
constructor: .jsIntlDurationFormatConstructor)
3587+
3588+
static let jsIntlDurationFormatConstructor = ObjectGroup(
3589+
name: "IntlDurationFormatConstructor",
3590+
constructorPath: "Intl.DurationFormat",
3591+
instanceType: .jsIntlDurationFormatConstructor,
3592+
properties: [
3593+
"prototype" : jsIntlDurationFormatPrototype.instanceType
3594+
],
3595+
methods: [
3596+
// TODO(manishearth) this also accepts arrays of locale-likes
3597+
"supportedLocalesOf": [.opt(.jsIntlLocaleLike), .opt(OptionsBag.jsIntlLocaleMatcherSettings.group.instanceType)] => .jsArray,
3598+
]
3599+
)
3600+
35643601
fileprivate static func dateTimeFormatSignature(_ returnType: ILType) -> [Signature] {
35653602
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/format#date
35663603
// No ZonedDateTime as stated in the docs.
@@ -3840,6 +3877,7 @@ extension OptionsBag {
38403877
fileprivate static let jsIntlDisplayNamesTypeEnum = ILType.enumeration(ofName: "IntlDisplayNamesTypeEnum", withValues: ["language", "region", "script", "currency", "calendar", "dateTimeField"])
38413878
fileprivate static let jsIntlDisplayNamesFallbackEnum = ILType.enumeration(ofName: "IntlDisplayNamesFallbackEnum", withValues: ["code", "none"])
38423879
fileprivate static let jsIntlDisplayNamesLanguageDisplayEnum = ILType.enumeration(ofName: "IntlDisplayNamesLanguageDisplayEnum", withValues: ["dialect", "standard"])
3880+
fileprivate static let jsIntlDurationFormatStyleEnum = ILType.enumeration(ofName: "IntlDurationFormatStyleEnum", withValues: ["long", "short", "narrow", "digital"])
38433881
fileprivate static let jsIntlListFormatTypeEnum = ILType.enumeration(ofName: "IntlListFormatTypeEnum", withValues: ["conjunction", "disjunction", "unit"])
38443882
fileprivate static let jsIntlNumberFormatStyleEnum = ILType.enumeration(ofName: "IntlNumberFormatStyleEnum", withValues: ["decimal", "currency", "percent", "unit"])
38453883
fileprivate static let jsIntlCurrencySystemEnum = ILType.enumeration(ofName: "IntlCurrency", withValues: Locale.Currency.isoCurrencies.map { $0.identifier })
@@ -3910,6 +3948,37 @@ extension OptionsBag {
39103948
]
39113949
)
39123950

3951+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/DurationFormat#options
3952+
static let jsIntlDurationFormatSettings = OptionsBag(
3953+
name: "IntlDurationFormatSettings",
3954+
properties: [
3955+
"localeMatcher": jsIntlLocaleMatcherEnum,
3956+
"numberingSystem": jsIntlNumberingSystemEnum,
3957+
"style": jsIntlDurationFormatStyleEnum,
3958+
"years": jsIntlLongShortNarrowEnum,
3959+
"yearsDisplay": jsIntlAutoAlwaysEnum,
3960+
"months": jsIntlLongShortNarrowEnum,
3961+
"monthsDisplay": jsIntlAutoAlwaysEnum,
3962+
"weeks": jsIntlLongShortNarrowEnum,
3963+
"weeksDisplay": jsIntlAutoAlwaysEnum,
3964+
"days": jsIntlLongShortNarrowEnum,
3965+
"daysDisplay": jsIntlAutoAlwaysEnum,
3966+
"hours": jsIntlLongShortNarrowEnum,
3967+
"hoursDisplay": jsIntlAutoAlwaysEnum,
3968+
"minutes": jsIntlLongShortNarrowEnum,
3969+
"minutesDisplay": jsIntlAutoAlwaysEnum,
3970+
"seconds": jsIntlLongShortNarrowEnum,
3971+
"secondsDisplay": jsIntlAutoAlwaysEnum,
3972+
"milliseconds": jsIntlLongShortNarrowEnum,
3973+
"millisecondsDisplay": jsIntlAutoAlwaysEnum,
3974+
"microseconds": jsIntlLongShortNarrowEnum,
3975+
"microsecondsDisplay": jsIntlAutoAlwaysEnum,
3976+
"nanoseconds": jsIntlLongShortNarrowEnum,
3977+
"nanosecondsDisplay": jsIntlAutoAlwaysEnum,
3978+
"fractionalDigits": .integer,
3979+
]
3980+
)
3981+
39133982
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options
39143983
static let jsIntlListFormatSettings = OptionsBag(
39153984
name: "IntlListFormatSettings",

0 commit comments

Comments
 (0)