Issue #2259 - Update Intl.* Object-ness to ECMA-402, 4th edition

- turn each Intl object into a NativeObject subclass
- create them as PlainObject
- ensure correct type is passed in self-hosted code
- implement legacy constructor semantics for DateTime&NumberFormat
- store internals on object slot instead of JS WeakMap

Based-on: m-c 1328386, 1332604
This commit is contained in:
Martok 2023-06-29 23:02:11 +02:00 committed by roytam1
commit 30157344fe
31 changed files with 633 additions and 663 deletions

View file

@ -13,5 +13,5 @@ evalcx(`
');
oomTest(() => eval('Array(..."")'));
if ('Intl' in this)
Intl.NumberFormat.prototype.format(0);
new Intl.NumberFormat().format(0);
`, newGlobal());

View file

@ -4,15 +4,8 @@ load(libdir + "asserts.js");
// any value except "best fit" or "lookup" is okay.
Object.prototype.localeMatcher = "invalid matcher option";
// The Intl API may not be available in the testing environment. Note that |hasOwnProperty("Intl")|
// initializes the Intl API if present, so this if-statement needs to appear after "localeMatcher"
// was added to Object.prototype.
// The Intl API may not be available in the testing environment.
if (this.hasOwnProperty("Intl")) {
// Intl prototypes are properly initialized despite changed Object.prototype.
Intl.Collator.prototype.compare("a", "b");
Intl.NumberFormat.prototype.format(10);
Intl.DateTimeFormat.prototype.format(new Date);
// Intl constructors no longer work properly, because "localeMatcher" defaults to the invalid
// value from Object.prototype. Except for Intl.DateTimeFormat, cf. ECMA-402 ToDateTimeOptions.
assertThrowsInstanceOf(() => new Intl.Collator(), RangeError);

View file

@ -15,6 +15,7 @@ for (var i = 0; i < 3; i++) {
x.toString();
assertEq(0, 1);
} catch (e) {
assertEq(e.message, "y is undefined");
assertEq(e.message === "y is undefined" ||
e.message === "undefined has no properties", true);
}
}