tor-browser

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

events-007.html (2098B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>CSS Transitions Test: no transitionend event after display:none</title>
      6 <link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
      7 <link rel="help" href="http://www.w3.org/TR/css3-transitions/#transition-events">
      8 <link rel="help" href="https://lists.w3.org/Archives/Public/www-style/2015Apr/0405.html" title="[CSSWG] Minutes Telecon 2015-04-29" data-section-title="AnimationEnd events and display: none">
      9 <meta name="assert" content="Making an element display:none; while it has a transition in progress should prevent a transitionend event from getting fired.">
     10 
     11 <script src="/resources/testharness.js"></script>
     12 <script src="/resources/testharnessreport.js"></script>
     13 <script src="./support/helper.js" type="text/javascript"></script>
     14 
     15 </head>
     16 <body>
     17 
     18 <div id="log"></div>
     19 
     20 <script>
     21 async_test(t => {
     22  window.addEventListener('load', function () {
     23    const div = addDiv(t, { 'style': 'transition: background-color 0.4s;' +
     24                                     'background-color: red' });
     25    getComputedStyle(div).backgroundColor;
     26    div.style.backgroundColor = 'blue';
     27 
     28    // Wait until the transition has started before registering the event
     29    // listener. That way, if the transition finishes before the
     30    // requestAnimationFrame callback is called and the element is made
     31    // display:none, we won't report an error if transitionend is dispatched.
     32    //
     33    // In that case, there will be no indication that the test didn't test
     34    // anything. However, that's preferable to having this test fail
     35    // intermittently on slower automation hardware and end up being disabled
     36    // as a result.
     37    requestAnimationFrame(t.step_func(() => {
     38      div.addEventListener('transitionend', t.step_func(() => {
     39        assert_unreached('transitionend event didn\'t fire');
     40      }), false);
     41 
     42      div.style.display = 'none';
     43 
     44      setTimeout(t.done.bind(t), 500);
     45    }));
     46  }, false);
     47 }, 'transitionend should not be fired if the element is made display:none during the transition');
     48 </script>
     49 </body>
     50 </html>