Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- TODO update link -->
<title>Scoped element with name auto</title>
</head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#container {
display: flex;
flex-direction: row;
view-transition-name: auto;
position: relative;
}
.item {
background-color: teal;
color: white;
text-align: center;
line-height: 50px;
width: 50px;
height: 50px;
margin: 5px;
display: inline-block;
}
::view-transition-group(*) {
animation-duration: 2s;
}
::view-transition-old(*) {
animation-name: -ua-view-transition-fade-out;
}
::view-transition-new(*) {
animation-name: -ua-view-transition-fade-in;
}
</style>
<body>
<div id="container">
<div class="item">A</div>
<div class="item">B</div>
<div class="item">C</div>
</div>
</body>
<script>
function assert_has_animation_with_name(name, message) {
const results =
document.getAnimations().filter(a => a.animationName == name);
assert_equals(results.length, 1, message);
}
promise_test(async t => {
const element = document.getElementById("container");
const vt = element.startViewTransition(() => {
element.style.flexDirection = 'column';
});
assert_equals(vt.transitionRoot, element);
await vt.ready;
const results =
document.getAnimations().map((a) => {
return `${a.effect.target.id}${a.effect.pseudoElement}`;
}).sort();
const expected = [
'container::view-transition-group(match-element)',
'container::view-transition-new(match-element)',
'container::view-transition-old(match-element)',
];
assert_array_equals(results, expected, 'Matched pseudo-elements');
assert_has_animation_with_name('-ua-view-transition-fade-in',
'Fade in animation');
assert_has_animation_with_name('-ua-view-transition-fade-out',
'Fade out animation');
}, 'Scoped view transition with name auto on the scoped element');
</script>
</html>