tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

document-timelines.html (1865B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Document timelines</title>
      4 <link rel="help" href="https://drafts.csswg.org/web-animations/#document-timelines">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="../../testcommon.js"></script>
      8 <div id="log"></div>
      9 <script>
     10 'use strict';
     11 
     12 async_test(t => {
     13  assert_greater_than_equal(document.timeline.currentTime, 0,
     14    'The current time is initially is positive or zero');
     15 
     16  // document.timeline.currentTime should be set even before document
     17  // load fires. We expect this code to be run before document load and hence
     18  // the above assertion is sufficient.
     19  // If the following assertion fails, this test needs to be redesigned.
     20  assert_not_equals(document.readyState, 'complete',
     21    'Test is running prior to document load');
     22 
     23  // Test that the document timeline's current time is measured from
     24  // navigationStart.
     25  //
     26  // We can't just compare document.timeline.currentTime to
     27  // window.performance.now() because currentTime is only updated on a sample
     28  // so we use requestAnimationFrame instead.
     29  window.requestAnimationFrame(rafTime => {
     30    t.step(() => {
     31      assert_equals(document.timeline.currentTime, rafTime,
     32                    'The current time matches requestAnimationFrame time');
     33    });
     34    t.done();
     35  });
     36 }, 'Document timelines report current time relative to navigationStart');
     37 
     38 async_test(t => {
     39  window.requestAnimationFrame(rafTime => {
     40    t.step(() => {
     41      const iframe = document.createElement('iframe');
     42      document.body.appendChild(iframe);
     43      assert_greater_than_equal(iframe.contentDocument.timeline.currentTime, 0,
     44        'The current time of a new iframe is initially is positive or zero');
     45    });
     46    t.done();
     47  });
     48 }, 'Child frames do not report negative initial times');
     49 
     50 </script>