diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.id.js | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index acadf8200a..24d709556b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -66,10 +66,11 @@ void CalendarPrototype::initialize(GlobalObject& global_object) JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::id_getter) { // 1. Let calendar be the this value. - auto calendar = vm.this_value(global_object); + // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + auto* calendar = TRY(typed_this_object(global_object)); - // 2. Return ? ToString(calendar). - return { js_string(vm, TRY(calendar.to_string(global_object))) }; + // 3. Return ? ToString(calendar). + return { js_string(vm, TRY(Value(calendar).to_string(global_object))) }; } // 12.4.4 Temporal.Calendar.prototype.dateFromFields ( fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.datefromfields diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.id.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.id.js index 07660f5025..af81f0f390 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.id.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/Calendar/Calendar.prototype.id.js @@ -3,8 +3,12 @@ describe("correct behavior", () => { const calendar = new Temporal.Calendar("iso8601"); expect(calendar.id).toBe("iso8601"); }); +}); - test("works with any this value", () => { - expect(Reflect.get(Temporal.Calendar.prototype, "id", "foo")).toBe("foo"); +describe("errors", () => { + test("this value must be a Temporal.Calendar object", () => { + expect(() => { + Reflect.get(Temporal.Calendar.prototype, "id", "foo"); + }).toThrowWithMessage(TypeError, "Not an object of type Temporal.Calendar"); }); }); |