DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (81f420f057e4)

VCS Links

Line Code
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<!DOCTYPE html>
<html>
<head>
  <title>time origin value manual test</title>
  <link rel="help" href="https://w3c.github.io/hr-time/#time-origin-1">
  <link rel="prefetch" href="./resources/unload-a.html">
  <link rel="prefetch" href="./resources/unload-b.html">
  <link rel="prefetch" href="./resources/unload-c.html">
</head>
<body>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script>
    setup({ explicit_timeout: true });

    const ACCEPTABLE_VARIANCE = 400; // ms

    const isRoughlyEqual = (a, b) => Math.abs(a - b) < ACCEPTABLE_VARIANCE;

    const timings = { a: {}, b: {}, c: {} };
    const t = async_test("hr-time time origin");

    window.mark = msg => {
      timings[msg.docName][msg.lifecycleEventName] = {
        performanceNow: msg.performanceNow,
        dateNow: msg.dateNow
      };

      if (msg.docName === "c" && msg.lifecycleEventName === "unload") {
        setTimeout(makeAssertions, 0);
      }
    };

    function makeAssertions () {
      t.step(() => {
        const loadTimeBetweenAandB = timings.b.load.dateNow - timings.a.unload.dateNow;
        const loadTimeBetweenBandC = timings.c.load.dateNow - timings.b.unload.dateNow;

        assert_true(
          isRoughlyEqual(loadTimeBetweenAandB, timings.b.load.performanceNow),
          "Document in reused window's time origin should be time of close of pop-up box."
        );
        assert_true(
          isRoughlyEqual(loadTimeBetweenBandC, timings.c.load.performanceNow),
          "Document in reused window's time origin should be time of close of pop-up box."
        );
        assert_true(
          !isRoughlyEqual(timings.a.unload.performanceNow, 0),
          "Time origin during unload event should match that of rest of document."
        );
        assert_true(
          !isRoughlyEqual(timings.b.unload.performanceNow, 0),
          "Time origin during unload event should match that of rest of document."
        );
        assert_true(
          !isRoughlyEqual(timings.c.unload.performanceNow, 0),
          "Time origin during unload event should match that of rest of document."
        );
      });
      t.done();
    }
  </script>

  <h2>Description</h2>
  <p>This test validates the behavior of <code>performance.now()</code> with respect to its time origin.</p>
  <div id="log">
   <h2>Manual Test Steps</h2>
   <ol>
    <li><a href="resources/unload-a.html" target="_blank">Click here</a>
   </ol>
  </div>
</body>
<html>