test262/test/built-ins/Temporal/Now/plainDateTime/calendar-instance-does-not-get-calendar-property.js
Philip Chimento 34805283d9 Temporal: Add tests for fast path in ToTemporalCalendar
Normally, a plain object passed into an API that takes a Temporal.Calendar
has its 'calendar' property checked (observably) with a Has operation
followed by a Get operation if the property is present. In the normative
change https://github.com/tc39/proposal-temporal/pull/2392 which reached
consensus at the September 2022 TC39 meeting, this was changed so that
this check is skipped for objects which have the Temporal.Calendar
internal slots.

This adds tests to all entry points that pass a user-supplied object to
ToTemporalCalendar, with a "poisoned" calendar object which has the
correct internal slots but a 'calendar' accessor property whose getter
throws. A correct implementation should not cause this getter to throw.
2022-10-18 14:38:38 +02:00

21 lines
589 B
JavaScript

// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.now.plaindatetime
description: >
A Temporal.Calendar instance passed to plainDateTime() does not have its
'calendar' property observably checked
features: [Temporal]
---*/
const arg = new Temporal.Calendar("iso8601");
Object.defineProperty(arg, "calendar", {
get() {
throw new Test262Error("calendar.calendar should not be accessed");
},
});
Temporal.Now.plainDateTime(arg);
Temporal.Now.plainDateTime({ calendar: arg });