author | André Bargull <andre.bargull@gmail.com> |
Wed, 21 Mar 2018 07:27:24 -0700 | |
changeset 409394 | 6d67329ad458575215e1ac31d738573017d36e4d |
parent 409342 | 2356a4fada564d0e9d1fc1909051c3b068ec2f01 |
child 409395 | 3f714569d3341fe328de828988c04e12792e70b2 |
push id | 33687 |
push user | apavel@mozilla.com |
push date | Thu, 22 Mar 2018 09:31:48 +0000 |
treeherder | mozilla-central@7771df14ea18 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Waldo |
bugs | 1447018 |
milestone | 61.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
|
--- a/js/src/builtin/intl/DateTimeFormat.js +++ b/js/src/builtin/intl/DateTimeFormat.js @@ -666,33 +666,35 @@ function ToDateTimeOptions(options, requ else options = ToObject(options); options = std_Object_create(options); // Step 3. 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. if (needDefaults && (defaults === "date" || defaults === "all")) { // The specification says to call [[DefineOwnProperty]] with false for // the Throw parameter, while Object.defineProperty uses true. For the // calls here, the difference doesn't matter because we're adding // properties to a new object.
new file mode 100644 --- /dev/null +++ b/js/src/tests/non262/Intl/DateTimeFormat/options-property-accesses.js @@ -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);