tor-browser

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

custom-property-and-allow-discrete.html (2111B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset=utf-8>
      5 <title>CSS Transitions Test: transition of a custom property with "transition-behavior: allows-discrete"</title>
      6 <meta name="assert" content="Checks that transitioning a custom property with 'transition-behavior: allows-discrete' works as expected">
      7 <link rel="help" href="https://drafts.csswg.org/css-transitions-2/#transition-behavior-property">
      8 <script src="/resources/testharness.js" type="text/javascript"></script>
      9 <script src="/resources/testharnessreport.js" type="text/javascript"></script>
     10 <script src="./support/helper.js" type="text/javascript"></script>
     11 <style>
     12  .target {
     13    transition: --foo 10s step-start;
     14    transition-behavior: allow-discrete;
     15    --foo: bar;
     16  }
     17 </style>
     18 </head>
     19 <body>
     20 <div id="log"></div>
     21 <script>
     22 promise_test(async t => {
     23  const div = addDiv(t, { class: 'target' });
     24 
     25  let transitionCount = 0;
     26  div.addEventListener("transitionstart", () => transitionCount++);
     27 
     28  // Trigger a transition on the custom property.
     29  getComputedStyle(div).getPropertyValue('--foo');
     30  div.style.setProperty('--foo', 'baz');
     31  getComputedStyle(div).getPropertyValue('--foo');
     32 
     33  // Wait two more frames to ensure only a single transition was started.
     34  await waitForFrame();
     35  await waitForFrame();
     36 
     37  assert_equals(transitionCount, 1, 'A single "transitionstart" event was dispatched');
     38 }, 'It is possible to transition an unregistered custom property using "transition-behavior: allows-discrete"');
     39 
     40 promise_test(async t => {
     41  const div = addDiv(t);
     42  div.style.setProperty('--foo', 'bar');
     43 
     44  // Trigger a transition on the custom property.
     45  getComputedStyle(div).getPropertyValue('--foo');
     46  div.style.transition = "--foo 10s allow-discrete";
     47  div.style.setProperty('--foo', 'baz');
     48 
     49  assert_equals(div.getAnimations()[0].transitionProperty, '--foo', 'A transition was started for the custom property');
     50 }, 'It is possible to transition an unregistered custom property using "transition-behavior: allows-discrete" when setting "transition-property" in the style change that yields the transition');
     51 
     52 </script>
     53 </body>
     54 </html>