Bug 1729584 [wpt PR 30389] - [@layer] Use layer order to resolve @keyframes name conflicts, a=testonly

Automatic update from web-platform-tests
[@layer] Use layer order to resolve @keyframes name conflicts

Bug: 1095765
Change-Id: I81019935a7307297d4e580a6b0f3d91e2ab5c5e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3146233
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#919516}

--

wpt-commits: e6b0a3452e666af467dfaa724222c9a11e854c4c
wpt-pr: 30389
This commit is contained in:
Xiaocheng Hu 2021-09-14 09:59:18 +00:00 коммит произвёл moz-wptsync-bot
Родитель 1b9c6c866d
Коммит b019f6da5a
1 изменённых файлов: 138 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,138 @@
<!DOCTYPE html>
<title>Resolving @keyframe name conflicts with cascade layers</title>
<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering">
<link rel="author" href="mailto:xiaochengh@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#target, #reference {
width: 100px;
height: 100px;
}
#reference {
background-color: green;
}
</style>
<div id="target"></div>
<div id="reference"></div>
<script>
// In all tests, background color of #target should be green, same as #reference
const testCases = [
{
title: '@keyframes layered overrides unlayered',
style: `
#target {
animation: anim 1s paused;
}
@layer {
@keyframes anim {
from { background-color: green; }
}
}
@keyframes anim {
from { background-color: red; }
}
`
},
{
title: '@keyframes override between layers',
style: `
@layer base, override;
#target {
animation: anim 1s paused;
}
@layer override {
@keyframes anim {
from { background-color: green; }
}
}
@layer base {
@keyframes anim {
from { background-color: red; }
}
}
`
},
{
title: '@keyframes override update with appended sheet 1',
style: `
@layer base, override;
#target {
animation: anim 1s paused;
}
@layer override {
@keyframes anim {
from { background-color: green; }
}
}
`,
append: `
@layer base {
@keyframes anim {
from { background-color: red; }
}
}
`
},
{
title: '@keyframes override update with appended sheet 2',
style: `
@layer base, override;
#target {
animation: anim 1s paused;
}
@layer base {
@keyframes anim {
from { background-color: red; }
}
}
`,
append: `
@layer override {
@keyframes anim {
from { background-color: green; }
}
}
`
},
];
for (let testCase of testCases) {
var documentStyle = document.createElement('style');
documentStyle.appendChild(document.createTextNode(testCase['style']));
document.head.appendChild(documentStyle);
var appendedStyle;
if (testCase['append']) {
document.body.offsetLeft; // Force style update
appendedStyle = document.createElement('style');
appendedStyle.appendChild(document.createTextNode(testCase['append']));
document.head.appendChild(appendedStyle);
}
test(function () {
assert_equals(getComputedStyle(target).backgroundColor,
getComputedStyle(reference).backgroundColor);
}, testCase['title']);
if (appendedStyle)
appendedStyle.remove();
documentStyle.remove();
}
</script>