wpt / css / css-view-transitions / snapshot-containing-block-static-iframe.html

Status: PASS | Duration: 7ms | Subtests: 1/1 | Open test on wpt.live | Open ref on wpt.live | wpt.fyi

/css/css-view-transitions/snapshot-containing-block-static-iframe.html

<!DOCTYPE html>
<html class=reftest-wait>
<title>View transitions: use snapshot containing block for static position in iframe</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block-concept/">
<link rel="match" href="snapshot-containing-block-static-iframe-ref.html">

<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>

<style>
#inner {
  width: 400px;
  height: 200px;
}
</style>
<iframe id="inner" srcdoc="
  <style>
  body {
    height: 200vh;
    overflow: hidden;
  }
  ::view-transition {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    background: limegreen;
  }
  ::view-transition-group(*),
  ::view-transition-image-pair(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation-play-state: paused;
  }

  </style>
  <body></body>
"></iframe>
<script>
failIfNot(document.startViewTransition, "Missing document.startViewTransition");

async function runTest() {
  // Start the view transition at a scroll offset so that the snapshot
  // containing block differs from the initial containing block.
  inner.contentWindow.scrollTo(0, 100);
  await waitForAtLeastOneFrame();

  const contentDocument = inner.contentDocument;
  let vt = inner.contentDocument.startViewTransition();
  await vt.ready;
  takeScreenshot();
}

onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>

/css/css-view-transitions/snapshot-containing-block-static-iframe-ref.html

<!DOCTYPE html>
<html>
<title>View transitions: use snapshot containing block for static position in iframe (ref)</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/#snapshot-containing-block-concept/">

<style>
#inner {
  width: 400px;
  height: 200px;
}
</style>
<iframe id="inner" srcdoc="
  <style>
  body {
    height: 200vh;
    background: limegreen;
    overflow: hidden;
  }
  </style>
  <body></body>
"></iframe>

<script>
onload = () => {
  inner.contentWindow.scrollTo(0, 100);
};
</script>