Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit c82be71

Browse files
Edvard Thörnroschromium-wpt-export-bot
authored andcommitted
Translate another 25 more svg/animation tests to WPT
This is the third commit in the series of updating all the old svg animation tests. The usage of testharness has replaced the older SVGAnimationTest.js for all where it's suitable. No functionality should have changed and the tests should cover almost the same. In all of the animations where there is a sampling at T=0, where it was assumed that no animations had started. Which didn't work flawlessly when moved to the new system, it has thus been removed. Bug: 985335 Change-Id: Ib458e6da3017e51cb06437daf22bf5eddedaf6b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735576 Reviewed-by: Stephen Chenney <[email protected]> Commit-Queue: Edvard Thörnros <[email protected]> Cr-Commit-Position: refs/heads/master@{#684662}
1 parent fd22d04 commit c82be71

23 files changed

+2358
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!doctype html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>Test the behavior of one discard applied on another discard</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
8+
9+
<?xml version="1.0" encoding="UTF-8"?>
10+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
11+
<animate id="anim" attributeName="visibility" to="visible" begin="0s" end="5s"/>
12+
<rect x="0" y="0" width="50" height="50" fill="rgb(255, 0, 0)">
13+
<set id="set1" attributeName="fill" to="rgb(0, 255, 0)" begin="2s" fill="freeze"/>
14+
<set id="set2" attributeName="fill" to="rgb(0, 0, 255)" begin="3s" fill="freeze"/>
15+
</rect>
16+
17+
<discard id="discard1" xlink:href="#set1" begin="1s"/>
18+
<discard id="discard2" xlink:href="#set2"/>
19+
<discard id="discard3" xlink:href="#discard1"/>
20+
</svg>
21+
22+
<script>
23+
var rootSVGElement = document.querySelector("svg");
24+
var epsilon = 1.0;
25+
26+
// Setup animation test
27+
function sample1() {
28+
expectFillColor(rect1, 255, 0, 0);
29+
}
30+
31+
function sample2() {
32+
expectFillColor(rect1, 0, 255, 0);
33+
}
34+
35+
smil_async_test((t) => {
36+
var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect");
37+
rect1 = rects[0];
38+
39+
const expectedValues = [
40+
// [animationId, time, sampleCallback]
41+
["anim", 0.0, sample1],
42+
["anim", 0.01, sample1],
43+
["anim", 2.0, sample2],
44+
["anim", 2.01, sample2],
45+
["anim", 3.0, sample2],
46+
["anim", 3.01, sample2]
47+
];
48+
49+
runAnimationTest(t, expectedValues);
50+
});
51+
52+
window.animationStartsImmediately = true;
53+
54+
</script>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!doctype html>
2+
<html>
3+
<meta charset="utf-8">
4+
<title>This test forces use shadow tree recreation while an animating is running</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
8+
9+
<?xml version="1.0" encoding="UTF-8"?>
10+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
11+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
12+
13+
<defs>
14+
<rect id="rect" width="10" height="100" fill="red">
15+
<animate id="an1" attributeName="width" fill="freeze" from="10" to="100" begin="0s" dur="4s"/>
16+
</rect>
17+
</defs>
18+
19+
<use xlink:href="#rect"/>
20+
21+
</svg>
22+
23+
<script>
24+
var rootSVGElement = document.querySelector("svg");
25+
var epsilon = 1.0;
26+
27+
// Setup animation test
28+
function sample1() {
29+
assert_approx_equals(rect.width.animVal.value, 10, epsilon);
30+
assert_equals(rect.width.baseVal.value, 10);
31+
}
32+
33+
function sample2() {
34+
assert_approx_equals(rect.width.animVal.value, 55, epsilon);
35+
assert_equals(rect.width.baseVal.value, 10);
36+
}
37+
38+
function forceUseShadowTreeRecreation() {
39+
rect.setAttribute("fill", "green");
40+
}
41+
42+
function sample3() {
43+
assert_approx_equals(rect.width.animVal.value, 100, epsilon);
44+
assert_equals(rect.width.baseVal.value, 10);
45+
}
46+
47+
smil_async_test((t) => {
48+
rect = rootSVGElement.ownerDocument.getElementsByTagName("rect")[0];
49+
50+
const expectedValues = [
51+
// [animationId, time, sampleCallback]
52+
["an1", 0.0, sample1],
53+
["an1", 1.999, sample2],
54+
["an1", 2.0, forceUseShadowTreeRecreation],
55+
["an1", 2.001, sample2],
56+
["an1", 4.0, sample3],
57+
["an1", 60.0, sample3],
58+
];
59+
60+
runAnimationTest(t, expectedValues);
61+
});
62+
63+
window.animationStartsImmediately = true;
64+
65+
</script>

0 commit comments

Comments
 (0)