зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1447018 - Don't break early in ToDateTimeOptions to improve spec conformance. r=Waldo
--HG-- extra : rebase_source : 57812cb92f35c7058ac8a8052674a8dba0d2833e extra : histedit_source : 74c211a6af5417dab1f53019659bac4d103d847c
This commit is contained in:
Родитель
735f401ec7
Коммит
cfbfabb86f
|
@ -671,23 +671,25 @@ function ToDateTimeOptions(options, required, defaults) {
|
|||
var needDefaults = true;
|
||||
|
||||
// Step 4.
|
||||
// TODO: spec issue - The spec requires to retrieve all options, so using
|
||||
// the ||-operator with its lazy evaluation semantics is incorrect.
|
||||
if ((required === "date" || required === "any") &&
|
||||
(options.weekday !== undefined || options.year !== undefined ||
|
||||
options.month !== undefined || options.day !== undefined))
|
||||
{
|
||||
needDefaults = false;
|
||||
if (required === "date" || required === "any") {
|
||||
if (options.weekday !== undefined)
|
||||
needDefaults = false;
|
||||
if (options.year !== undefined)
|
||||
needDefaults = false;
|
||||
if (options.month !== undefined)
|
||||
needDefaults = false;
|
||||
if (options.day !== undefined)
|
||||
needDefaults = false;
|
||||
}
|
||||
|
||||
// Step 5.
|
||||
// TODO: spec issue - The spec requires to retrieve all options, so using
|
||||
// the ||-operator with its lazy evaluation semantics is incorrect.
|
||||
if ((required === "time" || required === "any") &&
|
||||
(options.hour !== undefined || options.minute !== undefined ||
|
||||
options.second !== undefined))
|
||||
{
|
||||
needDefaults = false;
|
||||
if (required === "time" || required === "any") {
|
||||
if (options.hour !== undefined)
|
||||
needDefaults = false;
|
||||
if (options.minute !== undefined)
|
||||
needDefaults = false;
|
||||
if (options.second !== undefined)
|
||||
needDefaults = false;
|
||||
}
|
||||
|
||||
// Step 6.
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
|
||||
|
||||
var log;
|
||||
var proxy = new Proxy({
|
||||
year: "numeric",
|
||||
hour: "numeric",
|
||||
}, new Proxy({
|
||||
get(t, pk, r) {
|
||||
log.push(pk);
|
||||
return Reflect.get(t, pk, r);
|
||||
}
|
||||
}, {
|
||||
get(t, pk, r) {
|
||||
assertEq(pk, "get");
|
||||
return Reflect.get(t, pk, r);
|
||||
}
|
||||
}));
|
||||
|
||||
var constructorAccesses = [
|
||||
// ToDateTimeOptions(options, "any", "date").
|
||||
"weekday", "year", "month", "day",
|
||||
"hour", "minute", "second",
|
||||
|
||||
// InitializeDateTimeFormat
|
||||
"localeMatcher", "hour12", "hourCycle", "timeZone",
|
||||
|
||||
// Table 5: Components of date and time formats
|
||||
"weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName",
|
||||
|
||||
// InitializeDateTimeFormat
|
||||
"formatMatcher",
|
||||
];
|
||||
|
||||
log = [];
|
||||
new Intl.DateTimeFormat(undefined, proxy);
|
||||
|
||||
assertEqArray(log, constructorAccesses);
|
||||
|
||||
log = [];
|
||||
new Date().toLocaleString(undefined, proxy);
|
||||
|
||||
assertEqArray(log, [
|
||||
// ToDateTimeOptions(options, "any", "all").
|
||||
"weekday", "year", "month", "day",
|
||||
"hour", "minute", "second",
|
||||
|
||||
...constructorAccesses
|
||||
]);
|
||||
|
||||
log = [];
|
||||
new Date().toLocaleDateString(undefined, proxy);
|
||||
|
||||
assertEqArray(log, [
|
||||
// ToDateTimeOptions(options, "date", "date").
|
||||
"weekday", "year", "month", "day",
|
||||
|
||||
...constructorAccesses
|
||||
]);
|
||||
|
||||
log = [];
|
||||
new Date().toLocaleTimeString(undefined, proxy);
|
||||
|
||||
assertEqArray(log, [
|
||||
// ToDateTimeOptions(options, "time", "time").
|
||||
"hour", "minute", "second",
|
||||
|
||||
...constructorAccesses
|
||||
]);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0);
|
Загрузка…
Ссылка в новой задаче