Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "2e2aa2290fac856d6f451ceacb58f7f5b44dd057";
export const WEBKIT_VERSION = "autobuild-preview-pr-600-cbbbe00e";
Comment thread
robobun marked this conversation as resolved.
Resolved
Comment thread
robobun marked this conversation as resolved.
Resolved

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
74 changes: 74 additions & 0 deletions test/js/web/temporal/temporal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,77 @@ describe("Temporal core operations", () => {
expect(() => structuredClone(Temporal.Instant.from("2024-06-15T00:00Z"))).toThrow(DOMException);
});
});

// Divergences from V8 found by differential fuzzing. Expected values are what Node 26 / Chromium 148 print.
describe("Temporal spec conformance", () => {
test("PlainDate.from rejects a non-object options before it resolves the calendar fields", () => {
// ToTemporalDate: PrepareCalendarFields, then GetOptionsObject (TypeError), then CalendarDateFromFields
// (era resolution and the ISODateWithinLimits check, both RangeError).
const lateFailingBags = [
{ year: -271821, month: 2, day: 31 },
{ year: 275760, month: 9, day: 14 },
{ era: "xx", eraYear: 1, month: 1, day: 1, calendar: "gregory" },
{ year: 2024, month: 13, day: 1 },
];
for (const bag of lateFailingBags) {
for (const options of [null, "constrain", 1, true]) {
expect(() => Temporal.PlainDate.from(bag, options as any)).toThrow(TypeError);
}
Comment thread
robobun marked this conversation as resolved.
Resolved
}
// The bag is still read first, and PrepareCalendarFields errors still win.
const reads: PropertyKey[] = [];
const bag = new Proxy({ year: -271821, month: 2, day: 31 }, { get: (t, k, r) => (reads.push(k), Reflect.get(t, k, r)) });
expect(() => Temporal.PlainDate.from(bag, null as any)).toThrow(TypeError);
expect(reads).toEqual(["calendar", "day", "month", "monthCode", "year"]);
expect(() => Temporal.PlainDate.from({ year: 2024, month: 0, day: 1 }, null as any)).toThrow(RangeError);
// With a real options object the late RangeErrors surface.
expect(() => Temporal.PlainDate.from(lateFailingBags[0], {})).toThrow(RangeError);
expect(() => Temporal.PlainDate.from(lateFailingBags[2], {})).toThrow(RangeError);
expect(Temporal.PlainDate.from(lateFailingBags[3], {}).toString()).toBe("2024-12-01");
});

test("rounding to weeks accepts a window edge on the minimum PlainDate", () => {
const later = Temporal.PlainDate.from("2016-02-29");
const nearMin = Temporal.PlainDate.from("-271821-04-20");
const results = Object.fromEntries(
["trunc", "floor", "expand", "halfExpand"].map(roundingMode => [
roundingMode,
later.since(nearMin, { smallestUnit: "weeks", roundingMode: roundingMode as Temporal.RoundingMode }).toString(),
]),
);
expect(results).toEqual({
trunc: "P14288122W",
floor: "P14288122W",
expand: "P14288123W",
halfExpand: "P14288123W",
});
expect(nearMin.until(later, { smallestUnit: "weeks" }).toString()).toBe("P14288122W");
expect(later.since(nearMin, { smallestUnit: "days", roundingIncrement: 7 }).toString()).toBe("P100016854D");
expect(
Temporal.Duration.from({ days: -100016860 })
.round({ relativeTo: later, smallestUnit: "weeks", roundingMode: "trunc" })
.toString(),
).toBe("-P14288122W");
// An edge that is really below the minimum still throws (here: the exact minimum as operand).
expect(() => later.since("-271821-04-19", { smallestUnit: "weeks" })).toThrow(RangeError);
});

test("era codes match the lowercase CLDR identifiers exactly", () => {
for (const [calendar, era] of [
["gregory", "CE"],
["gregory", "Bce"],
["gregory", "AD"],
["japanese", "Reiwa"],
["hebrew", "AM"],
]) {
expect(() => Temporal.PlainDate.from({ era, eraYear: 1, month: 1, day: 1, calendar })).toThrow(RangeError);
}
expect(Temporal.PlainDate.from({ era: "ce", eraYear: 1, month: 1, day: 1, calendar: "gregory" }).toString()).toBe(
"0001-01-01[u-ca=gregory]",
);
expect(Temporal.PlainDate.from({ era: "ad", eraYear: 1, month: 1, day: 1, calendar: "gregory" }).era).toBe("ce");
expect(Temporal.PlainDate.from({ era: "reiwa", eraYear: 1, month: 5, day: 1, calendar: "japanese" }).toString()).toBe(
"2019-05-01[u-ca=japanese]",
);
});
});
Loading