- Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathpagereveal-microtask-sequence.html
57 lines (54 loc) · 1.58 KB
/
pagereveal-microtask-sequence.html
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
<!DOCTYPE html>
<title>
View transition promise reactions in incoming page should resolve before
the rendering continues (rAF, style/layout etc)
</title>
<linkrel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<scriptsrc="/resources/testharness.js"></script>
<scriptsrc="/resources/testharnessreport.js"></script>
<script>
constparams=newURLSearchParams(location.search);
switch(params.get("mode")||"test"){
case"test":
promise_test(asynct=>{
constsequence=awaitnewPromise(resolve=>{
window.test_finished=s=>{resolve(s)};
constpopup=window.open("?mode=old");
t.add_cleanup(()=>popup.close());
});
assert_array_equals(sequence,["pagereveal","updateCallbackDone","ready","rAF","rAF-microtask","finished"]);
});
break;
case"old":
onload=()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{
location.replace('?mode=new');
}));
break;
case"new":
constsequence=[];
requestAnimationFrame(()=>{
sequence.push("rAF");
Promise.resolve().then(()=>{
sequence.push("rAF-microtask");
});
});
addEventListener('pagereveal',event=>{
sequence.push("pagereveal");
event.viewTransition.ready.then(()=>{
sequence.push("ready");
});
event.viewTransition.updateCallbackDone.then(()=>{
sequence.push("updateCallbackDone");
});
event.viewTransition.finished.then(()=>{
sequence.push("finished");
window.opener.test_finished(sequence);
});
});
}
</script>
<style>
@view-transition {
navigation: auto;
}
</style>