Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<meta charset="utf-8">
<title>Test fractional values in meta http-equiv=refresh</title>
<link rel="author" title="Psychpsyo" href="mailto:psychpsyo@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
async function measureRefreshTime(src) {
const frame = document.createElement("iframe");
document.body.appendChild(frame);
const loadPromise = new Promise(resolve => {
frame.addEventListener("load", () => {
resolve(performance.now());
});
});
frame.src = src;
const startTime = await loadPromise;
const unloadPromise = new Promise(resolve => {
frame.contentWindow.addEventListener("beforeunload", () => {
resolve(performance.now());
});
});
const endTime = await unloadPromise;
return endTime - startTime;
}
promise_test(async test => {
const refreshTime = await measureRefreshTime("resources/refresh1.html");
assert_greater_than(refreshTime, 900);
}, "Ensure that refresh is observed");
promise_test(async test => {
const refreshTime = await measureRefreshTime("resources/refresh1.99.html");
assert_greater_than(refreshTime, 900);
}, "Ensure that non-fractional part in refresh time does not get discarded");
promise_test(async test => {
const refreshTime = await measureRefreshTime("resources/refresh1dotdot9dot.html");
assert_greater_than(refreshTime, 900);
}, "Ensure that multiple periods in refresh time just get ignored");
</script>
</body>