summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-view-transitions/iframe-and-main-frame-transition-with-name-on-iframe.html
blob: f948e89dc7d13429008da1d9418209f46fb1da54 (plain)
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
<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: iframe and main frame transition at the same time with name on iframe</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<link rel="author" href="mailto:khushalsagar@chromium.org">
<link rel="match" href="iframe-and-main-frame-transition-with-name-on-iframe-ref.html">
<script src="/common/reftest-wait.js"></script>
<style>
iframe {
  position: fixed;
  top: 0;
  left: 0;
  width: 50vw;
  height: 50vh;
  view-transition-name: inner;
}

.old {
  border: 1px solid black;
}

.new {
  border: 1px solid orange;
}

/* The main frame is showing the old screenshot for the root */
::view-transition-group(root) {
  animation-duration: 300s;
}
::view-transition-new(root) {
  animation: unset;
  opacity: 0;
}
::view-transition-old(root) {
  animation: unset;
  opacity: 1;
}

/* The iframe is showing the live screenshot */
::view-transition-new(inner) {
  animation: unset;
  opacity: 1;
}
::view-transition-old(inner) {
  animation: unset;
  opacity: 0;
}

</style>

<iframe id="inner" srcdoc="
<style>
  /* The iframe document itself is showing an old screenshot */
  ::view-transition-group(root) {
    animation-duration: 300s;
  }
  ::view-transition-new(root) {
    animation: unset;
    opacity: 0;
  }
  ::view-transition-old(root) {
    animation: unset;
    opacity: 1;
  }
</style>
<body></body>"></iframe>
<script>
  onload = runTest;

  async function startTransition(document, oldColor, newColor, nestedFrame) {
    document.documentElement.style.background = oldColor;
    if (nestedFrame != null)
      nestedFrame.classList.add("old");

    await document.startViewTransition(() => {
      document.documentElement.style.background = newColor;
      if (nestedFrame != null) {
        nestedFrame.classList.remove("old");
        nestedFrame.classList.add("new");
      }
    }).ready;
  }

  async function runTest() {
    await startTransition(document, "green", "lightgreen", document.getElementById("inner"));

    const iframeDocument = document.querySelector("iframe").contentDocument;
    await startTransition(iframeDocument, "blue", "lightblue", null);

    takeScreenshot();
  }
</script>