tor-browser

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

pseudo-get-computed-style.html (7695B)


      1 <!DOCTYPE html>
      2 <html>
      3 <title>View transitions: check pseudo element's default styles</title>
      4 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
      5 <link rel="author" href="mailto:vmpstr@chromium.org">
      6 
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 
     10 <style>
     11 #target {
     12  width: 100px;
     13  height: 100px;
     14  background: blue;
     15  contain: paint;
     16  view-transition-name: target;
     17  mix-blend-mode: multiply;
     18  text-orientation: upright;
     19  color-scheme: dark light;
     20 }
     21 ::view-transition-image-pair(target) {
     22  position: fixed;
     23 }
     24 </style>
     25 
     26 <div id=target></div>
     27 
     28 <script>
     29 promise_test(async () => {
     30  assert_implements(document.startViewTransition, "Missing document.startViewTransition");
     31  let transition = document.startViewTransition(() => {
     32    assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "absolute", "::view-transition");
     33    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute", "container(target)");
     34    // The position is set via the style rules, so it should be applied once
     35    // we create the pseudo elements.
     36    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed", "wrapper(target)");
     37    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute", "outgoing(target)");
     38 
     39    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute", "container(root)");
     40    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute", "wrapper(root)");
     41    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute", "outgoing(root)");
     42 
     43    // Per spec, we update pseudo-element styles when activating the
     44    // transition, and this is after we invoke the update callback. Therefore,
     45    // these computed values should be the default values at this moment.
     46    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "mixed", "container(target)");
     47    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "normal", "container(target)");
     48    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "normal", "container(target)");
     49    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").mixBlendMode, "normal", "container(root)");
     50  });
     51 
     52  // When transition is ready, the activation of the view transition should be done, so
     53  // we have updated the pseudo-element styles.
     54  await transition.ready;
     55 
     56  assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "absolute", "raf ::view-transition");
     57  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute", "raf container(target)");
     58  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "multiply", "raf container(target)");
     59  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "upright", "raf container(target)");
     60  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "dark light", "raf container(target)");
     61  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed", "raf wrapper(target)");
     62  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute", "raf outgoing(target)");
     63 
     64  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute", "raf container(root)");
     65  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").mixBlendMode, "normal", "raf container(root)");
     66  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute", "raf wrapper(root)");
     67  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute", "raf outgoing(root)");
     68 
     69  await transition.finished;
     70 }, "properties of pseudo elements in update callback");
     71 
     72 promise_test(async () => {
     73  assert_implements(document.startViewTransition, "Missing document.startViewTransition");
     74  let transition = document.startViewTransition(() => {
     75    assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "absolute");
     76    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");
     77    // The position is set via the style rules, so it should be applied once
     78    // we create the pseudo elements.
     79    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed");
     80    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute");
     81 
     82    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute");
     83    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute");
     84    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute");
     85 
     86    target.remove();
     87  });
     88 
     89  await transition.ready;
     90 
     91  assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "absolute");
     92  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");
     93  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "multiply");
     94  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "upright");
     95  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "dark light");
     96  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed");
     97 
     98  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute");
     99  assert_equals(getComputedStyle(document.documentElement, "::view-transition-new(target)").position, "absolute");
    100 
    101  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute");
    102  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute");
    103  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute");
    104  assert_equals(getComputedStyle(document.documentElement, "::view-transition-new(root)").position, "absolute");
    105 
    106  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");
    107 
    108  await transition.finished;
    109 
    110  // The spec doesn't mention whether we should apply the custom ua sheets to
    111  // the non-existing pseudo elements. In Chromium, it doesn't apply it, so it
    112  // would be the default (i.e. static). However, in WebKit and Gecko, they
    113  // still apply the costom ua sheets. Therefore, we accept both cases for now.
    114  assert_in_array(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, ["static", "absolute"]);
    115 }, "properties of pseudo elements outside of transition");
    116 </script>