788c96a955
Previously, the Intl implementation tracked types two ways: - In the intl_initialized_marker_symbol - In various named properties of the intl_impl_object_symbol value As far as I can tell, these will never disagree with each other, modulo bugs in Intl itself. This patch removes the second type checking system. This reland includes a fixed type check for Intl.DateTimeFormat.prototype.formatToParts , which is the only Intl method which is not bound. All future methods will follow this pattern. The second reland ensures that a newly inserted test is only run if Intl is present. BUG=v8:5751,chromium:677055, v8:4962 CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_linux_noi18n_rel_ng TBR=yangguo@chromium.org Review-Url: https://codereview.chromium.org/2623683002 Cr-Commit-Position: refs/heads/master@{#42152}
40 lines
1.9 KiB
JavaScript
40 lines
1.9 KiB
JavaScript
// Copyright 2016 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.
|
|
|
|
// Calling Intl methods with a bad receiver throws a TypeError
|
|
|
|
// An uninitialized object of the same type
|
|
assertThrows(() => Object.create(Intl.DateTimeFormat.prototype).format(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.NumberFormat.prototype).format(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.Collator.prototype).compare(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).adoptText(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).first(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).next(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).current(),
|
|
TypeError);
|
|
assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).breakType(),
|
|
TypeError);
|
|
|
|
// Or similarly, just accessing the method getter on the prototype
|
|
assertThrows(() => Intl.DateTimeFormat.prototype.format, TypeError);
|
|
assertThrows(() => Intl.NumberFormat.prototype.format, TypeError);
|
|
assertThrows(() => Intl.Collator.prototype.compare, TypeError);
|
|
assertThrows(() => Intl.v8BreakIterator.prototype.adoptText, TypeError);
|
|
assertThrows(() => Intl.v8BreakIterator.prototype.first, TypeError);
|
|
assertThrows(() => Intl.v8BreakIterator.prototype.next, TypeError);
|
|
assertThrows(() => Intl.v8BreakIterator.prototype.current, TypeError);
|
|
assertThrows(() => Intl.v8BreakIterator.prototype.breakType, TypeError);
|
|
|
|
// The method .call'd on a different instance will have that
|
|
// other instance benignly ignored, since it's a bound function
|
|
let nf = Intl.NumberFormat();
|
|
let df = Intl.DateTimeFormat();
|
|
assertEquals("0", nf.format.call(df, 0));
|