v8/test/mjsunit/regress/regress-builtinbust-7.js
littledan 48a36c7df7 [intl] Avoid modifying options bag from constructor
Previously, the Intl.DateTimeFormat constructor and other related paths had
a bug where the options bag passed in would be modified in place. This patch
makes V8's Intl implementation follow the specification's logic to avoid
such a modification.

BUG=v8:4219

Review-Url: https://codereview.chromium.org/2587703002
Cr-Commit-Position: refs/heads/master@{#41826}
2016-12-19 21:36:16 +00:00

33 lines
1.0 KiB
JavaScript

// Copyright 2014 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.
if ("Intl" in this) {
function overflow() {
return overflow() + 1;
}
Object.defineProperty = overflow;
assertDoesNotThrow(function() { Intl.Collator.supportedLocalesOf("en"); });
var date = new Date(Date.UTC(2004, 12, 25, 3, 0, 0));
var options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
};
Object.apply = overflow;
assertDoesNotThrow(function() { date.toLocaleDateString("de-DE", options); });
var options_incomplete = {};
assertDoesNotThrow(function() {
date.toLocaleDateString("de-DE", options_incomplete);
});
assertFalse(options_incomplete.hasOwnProperty("year"));
assertDoesNotThrow(function() { date.toLocaleDateString("de-DE", undefined); });
assertDoesNotThrow(function() { date.toLocaleDateString("de-DE"); });
assertThrows(function() { date.toLocaleDateString("de-DE", null); }, TypeError);
}