Tests/LibWeb: Prevent inadvertent cookie expiration

We were testing cookie expiry by setting moving a Date 1000ms to the
future, and then calling `.toUTCString()` on it. However, that method
truncates milliseconds and could cause the actual expiry to be almost
immediately - that makes this test flaky, especially on slower machines.

Fix the issue by using a larger expiry.
This commit is contained in:
Jelle Raaijmakers 2026-03-20 14:06:57 +01:00 committed by Jelle Raaijmakers
parent 943319453d
commit f326f087fa

View file

@ -140,13 +140,13 @@
};
const expiresTest = () => {
let expiry = new Date(Date.now() + 1000);
let expiry = new Date(Date.now() + 3000);
expiry = expiry.toUTCString();
document.cookie = `cookie-expires=value; expires=${expiry}`;
printCookies("Expires (before expiration)");
internals.expireCookiesWithTimeOffset(2);
internals.expireCookiesWithTimeOffset(4);
printCookies("Expires (after expiration)");
};