File: auto-name-on-descendant.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 4,609,436 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,463; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (110 lines) | stat: -rw-r--r-- 3,130 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- TODO update link -->
  <link rel="help" href="https://www.w3.org/TR/css-view-transitions-2/">
  <title>Scoped element with name auto on descendant</title>
</head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  #container {
    display: flex;
    flex-direction: row;
    position: relative;
    /* Currently needed to force a stacking context in the absence of an
       animation-name.
    */
    will-change: opacity;
  }

  .item {
    background-color: teal;
    color: white;
    text-align: center;
    line-height: 50px;
    width: 50px;
    height: 50px;
    margin: 5px;
    position: relative;
    will-change: opacity;
    view-transition-name: auto;
  }

  #item1.active {
    background-color: orange;
    transform: scale(1.2);
  }

  #item2.active {
    background-color: salmon;
    transform: scale(0.9);
  }

  #item3.active {
    background-color: hotpink;
    transform: scale(0.8) translateX(-10px);
  }

  ::view-transition-group(*) {
    animation-duration: 2s;
  }

  ::view-transition-old(*) {
    animation-name: -ua-view-transition-fade-out;
  }

  ::view-transition-new(*) {
    animation-name: -ua-view-transition-fade-in;
  }

</style>
<body>
  <div id="container">
    <div id="item1" class="item">A</div>
    <div id="item2" class="item">B</div>
    <div id="item3" class="item">C</div>
  </div>
</body>
<script>
  function assert_has_animations_with_name(name, count, message) {
    const results =
        document.getAnimations().filter(a => a.animationName == name);
    assert_equals(results.length, count, message);
  }

  promise_test(async t => {
    const element = document.getElementById("container");
    const vt = element.startViewTransition(() => {
      element.querySelectorAll('.item').forEach(el => {
        el.classList.toggle('active');
      });
    });
    await vt.ready;
    const results =
        document.getAnimations().map((a) => {
          return `${a.effect.target.id}${a.effect.pseudoElement}`;
      }).sort();
    const expected = [
      'container::view-transition-group(match-element)',
      'container::view-transition-group(match-element)',
      'container::view-transition-group(match-element)',
      'container::view-transition-new(match-element)',
      'container::view-transition-new(match-element)',
      'container::view-transition-new(match-element)',
      'container::view-transition-old(match-element)',
      'container::view-transition-old(match-element)',
      'container::view-transition-old(match-element)',
    ];

    assert_array_equals(results, expected, 'Matched pseudo-elements');

    assert_has_animations_with_name('-ua-view-transition-fade-in', 3,
                                    'Fade in animation');
    assert_has_animations_with_name('-ua-view-transition-fade-out', 3,
                                    'Fade out animation');
  }, 'Scoped view transition with name auto on the scoped element');
</script>
</html>