summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-view-transitions/duplicate-tag-rejects-capture.html
blob: 951294babc2731eb1f86c32bc90c0beab95d70e4 (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
<!DOCTYPE html>
<html>
<title>View transitions: duplicate tags in the old DOM skip the transition</title>
<link rel="help" href="https://www.w3.org/TR/css-view-transitions-1/">
<link rel="author" href="mailto:khushalsagar@chromium.org">

<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";
    second.style = "view-transition-name: target";
    let transition = document.startViewTransition();

    // Ready rejected first since invoking the dom callback is an async task.
    let readyRejected = false;
    transition.ready.then(reject, () => {readyRejected = true;});

    // The domUpdate promise resolves (since there is no callback).
    let updateCallbackDoneResolved = false;
    transition.updateCallbackDone.then(() => {
      assert_true(readyRejected, "ready not rejected before updateCallbackDone");
      updateCallbackDoneResolved = true;
    }, reject);

    // Finally finish resolves.
    transition.finished.then(() => {
      assert_true(updateCallbackDoneResolved, "updateCallbackDone not resolved before finish");
      resolve();
    }, reject);
  });
}, "Two different elements with the same name in the old DOM should skip the transition");
</script>