chromium/third_party/blink/web_tests/external/wpt/css/css-view-transitions/duplicate-tag-rejects-start.html

<!DOCTYPE html>
<html>
<title>View transitions: duplicate tags in the new DOM skip the transition</title>
<link rel="help" href="https://www.w3.org/TR/css-view-transitions-1/">
<link rel="author" href="mailto:[email protected]">

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

<style>
div {
  width: 100px;
  height: 100px;
  background: blue;
  contain: paint;
}
</style>

<div id=first></div>
<div id=second></div>

<script>
promise_test(async t => {
  assert_implements(document.startViewTransition, "Missing document.startViewTransition");
  return new Promise((resolve, reject) => {
    first.style = "view-transition-name: target";
    let transition = document.startViewTransition(() => {
      first.style = "view-transition-name: target";
      second.style = "view-transition-name: target";
    });

    // First updateCallbackDone resolves since the callback runs successfully.
    let updateCallbackDoneResolved = false;
    transition.updateCallbackDone.then(() => { updateCallbackDoneResolved = true; }, reject);

    // Ready rejects.
    let readyRejected = false;
    transition.ready.then(reject, () => {
      readyRejected = true;
      assert_true(updateCallbackDoneResolved, "updateCallbackDone should resolve before ready was rejected");
    });

    // Then finished resolves since updateCallbackDone was already resolved.
    transition.finished.then(() => {
      assert_true(readyRejected, "finished should resolve after ready was rejected");
      resolve();
    }, reject);
  });
}, "Two different elements with the same name in the new DOM should skip the transition");
</script>