tor-browser

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

element-request-fullscreen-timing.html (2319B)


      1 <!DOCTYPE html>
      2 <title>Element#requestFullscreen() timing</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 <script src="../trusted-click.js"></script>
      8 <div id="log"></div>
      9 <script>
     10 promise_test(async t => {
     11  const div = document.querySelector('div');
     12 
     13  // If fullscreenchange is an animation frame event, then animation frame
     14  // callbacks should be run after it is fired, before the timer callback.
     15  // The resize event should fire before the fullscreenchange event.
     16  const events = [];
     17  const p = new Promise(resolve => {
     18    const callback = t.step_func(event => {
     19      // fullscreenElement should have changed before either event is fired.
     20      assert_equals(document.fullscreenElement, div, `fullscreenElement in {event.type} event`);
     21      events.push(event.type);
     22      if (event.type == 'fullscreenchange') {
     23        step_timeout(t.unreached_func('timer callback'));
     24        requestAnimationFrame(t.step_func_done(() => {
     25          // Removed 'resize' expectation for now, see https://crbug.com/381127087.
     26          assert_array_equals(events, ['fullscreenchange'], 'event order');
     27          resolve();
     28        }));
     29      }
     30    });
     31    document.onfullscreenchange = window.onresize = callback;
     32  });
     33  await trusted_request(div);
     34  await p;
     35  // so the user doesn't have to exit for themselves
     36  document.exitFullscreen();
     37 }, 'Timing of fullscreenchange and resize events');
     38 
     39 async_test(t => {
     40  // Gecko throttles requestAnimationFrame before the first paint, so
     41  // wrap the test to work around that.
     42  requestAnimationFrame(t.step_func(() => {
     43    var promise = document.createElement('a').requestFullscreen();
     44    var promise_executed = false;
     45    promise.catch(()=>{promise_executed = true; });
     46    // If fullscreenerror is an animation frame event, then animation frame
     47    // callbacks should be run after it is fired, before the timer callback.
     48    document.onfullscreenerror = t.step_func(() => {
     49      assert_true(promise_executed, "promise executed");
     50      step_timeout(t.unreached_func('timer callback'));
     51      requestAnimationFrame(t.step_func_done());
     52    });
     53  }));
     54 }, 'Timing of fullscreenerror event');
     55 </script>