File: pseudo-get-computed-style.html

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (116 lines) | stat: -rw-r--r-- 7,683 bytes parent folder | download | duplicates (7)
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
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<title>View transitions: check pseudo element's default styles</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:vmpstr@chromium.org">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
#target {
  width: 100px;
  height: 100px;
  background: blue;
  contain: paint;
  view-transition-name: target;
  mix-blend-mode: multiply;
  text-orientation: upright;
  color-scheme: dark light;
}
::view-transition-image-pair(target) {
  position: fixed;
}
</style>

<div id=target></div>

<script>
promise_test(async () => {
  assert_implements(document.startViewTransition, "Missing document.startViewTransition");
  let transition = document.startViewTransition(() => {
    assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "fixed", "::view-transition");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute", "container(target)");
    // The position is set via the style rules, so it should be applied once
    // we create the pseudo elements.
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed", "wrapper(target)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute", "outgoing(target)");

    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute", "container(root)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute", "wrapper(root)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute", "outgoing(root)");

    // Per spec, we update pseudo-element styles when activating the
    // transition, and this is after we invoke the update callback. Therefore,
    // these computed values should be the default values at this moment.
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "mixed", "container(target)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "normal", "container(target)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "normal", "container(target)");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").mixBlendMode, "normal", "container(root)");
  });

  // When transition is ready, the activation of the view transition should be done, so
  // we have updated the pseudo-element styles.
  await transition.ready;

  assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "fixed", "raf ::view-transition");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute", "raf container(target)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "multiply", "raf container(target)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "upright", "raf container(target)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "dark light", "raf container(target)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed", "raf wrapper(target)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute", "raf outgoing(target)");

  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute", "raf container(root)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").mixBlendMode, "normal", "raf container(root)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute", "raf wrapper(root)");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute", "raf outgoing(root)");

  await transition.finished;
}, "properties of pseudo elements in update callback");

promise_test(async () => {
  assert_implements(document.startViewTransition, "Missing document.startViewTransition");
  let transition = document.startViewTransition(() => {
    assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "fixed");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");
    // The position is set via the style rules, so it should be applied once
    // we create the pseudo elements.
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute");

    assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute");
    assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute");

    target.remove();
  });

  await transition.ready;

  assert_equals(getComputedStyle(document.documentElement, "::view-transition").position, "fixed");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").mixBlendMode, "multiply");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").textOrientation, "upright");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").colorScheme, "dark light");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(target)").position, "fixed");

  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(target)").position, "absolute");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-new(target)").position, "absolute");

  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(root)").position, "absolute");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-image-pair(root)").position, "absolute");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-old(root)").position, "absolute");
  assert_equals(getComputedStyle(document.documentElement, "::view-transition-new(root)").position, "absolute");

  assert_equals(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, "absolute");

  await transition.finished;

  // The spec doesn't mention whether we should apply the custom ua sheets to
  // the non-existing pseudo elements. In Chromium, it doesn't apply it, so it
  // would be the default (i.e. static). However, in WebKit and Gecko, they
  // still apply the costom ua sheets. Therefore, we accept both cases for now.
  assert_in_array(getComputedStyle(document.documentElement, "::view-transition-group(target)").position, ["static", "absolute"]);
}, "properties of pseudo elements outside of transition");
</script>