summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/meta/refresh-time.html
blob: 7aef1266a2bdc3fdae0a83d814bd32a2f0e816cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!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">
<link rel="help" href="https://html.spec.whatwg.org/#pragma-directives">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
  async function sleep(ms, test) {
    return new Promise(resolve => {test.step_timeout(resolve, ms)});
  }

  promise_test(async test => {
    const frame = document.createElement("iframe");
    document.body.appendChild(frame);
    frame.src = "resources/refresh1.html";
    await sleep(500, test);
    assert_equals(frame.contentWindow.document.title, "refresh 1");
    await sleep(1000, test);
    assert_equals(frame.contentWindow.document.title, "got refreshed");
  }, "Ensure that refresh is observed");

  promise_test(async test => {
    const frame = document.createElement("iframe");
    document.body.appendChild(frame);
    frame.src = "resources/refresh.99.html";
    await sleep(500, test);
    assert_equals(frame.contentWindow.document.title, "got refreshed");
  }, "Ensure that fractions in refresh time are ignored");

  promise_test(async test => {
    const frame = document.createElement("iframe");
    document.body.appendChild(frame);
    frame.src = "resources/refresh1.99.html";
    await sleep(500, test);
    assert_equals(frame.contentWindow.document.title, "refresh 1.99");
    await sleep(1000, test);
    assert_equals(frame.contentWindow.document.title, "got refreshed");
  }, "Ensure that non-fractional part in refresh time does not get discarded");

  promise_test(async test => {
    const frame = document.createElement("iframe");
    document.body.appendChild(frame);
    frame.src = "resources/refresh1dotdot5dot.html";
    await sleep(500, test);
    assert_equals(frame.contentWindow.document.title, "refresh 1..5.");
    await sleep(750, test);
    assert_equals(frame.contentWindow.document.title, "got refreshed");
  }, "Ensure that multiple periods in refresh time just get ignored");
</script>
</body>