Skip to content

Commit 4e27e74

Browse files
Danylo MocherniukV8-internal LUCI CQ
authored andcommitted
[dumpling] Add temporal determinism.
Similar to Date, we also need to mock Temporal Bug: 441467877 Change-Id: I72f44575b2c9c08c9067f55518259727b8cb10b1 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9026357 Reviewed-by: Michael Achenbach <machenbach@google.com> Commit-Queue: Danylo Mocherniuk <mdanylo@google.com>
1 parent f9cacf4 commit 4e27e74

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Sources/FuzzilliCli/Profiles/V8DumplingProfile.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ let v8DumplingProfile = Profile(
9191
};
9292
}();
9393
Math.random = rng;
94+
95+
if (typeof Temporal !== 'undefined' && Temporal.Now) {
96+
const fixedInstant = Temporal.Instant.fromEpochMilliseconds(FIXED_TIME);
97+
98+
Temporal.Now.instant = () => fixedInstant;
99+
100+
// Shim Zoned/Plain methods to use the fixed instant
101+
Temporal.Now.zonedDateTimeISO = (tzLike) =>
102+
fixedInstant.toZonedDateTimeISO(tzLike || Temporal.Now.timeZoneId());
103+
104+
Temporal.Now.plainDateTimeISO = (tzLike) =>
105+
fixedInstant.toZonedDateTimeISO(tzLike || Temporal.Now.timeZoneId()).toPlainDateTime();
106+
107+
Temporal.Now.plainDateISO = (tzLike) =>
108+
fixedInstant.toZonedDateTimeISO(tzLike || Temporal.Now.timeZoneId()).toPlainDate();
109+
110+
Temporal.Now.plainTimeISO = (tzLike) =>
111+
fixedInstant.toZonedDateTimeISO(tzLike || Temporal.Now.timeZoneId()).toPlainTime();
112+
}
94113
})();
95114
// --- End Determinism Shim ---
96115
""",

0 commit comments

Comments
 (0)