Commit 4bf81422 authored by Edvard Thörnros's avatar Edvard Thörnros Committed by Commit Bot

Add new test for short animations

A new test was added that tests that short animations
still trigger some of their events when they should.

No functionality was added or changed only a test.

Bug: 379751, 981522
Change-Id: I7425c56ae528d9249fc0da76b47da1a5865e1571
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697007
Auto-Submit: Edvard Thörnros <edvardt@opera.com>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#676792}
parent 51feea97
<!DOCTYPE html>
<title>Correct events for short animations with syncbases</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<svg viewBox="0 0 250 50" xmlns="http://www.w3.org/2000/svg">
<g id="a" opacity="0">
<animate attributeName="opacity" from="0" to="1" begin="0ms;last.end+10ms" dur="10ms" fill="freeze"
id="first"/>
<animate attributeName="opacity" from="1" to="0" begin="last.end" dur="1ms" fill="freeze"/>
<rect x="0" y="0" width="50" height="50" fill="#0F0"/>
</g>
<g id="b" opacity="0">
<animate attributeName="opacity" from="1" to="1" begin="first.end+10ms" dur="1ms" fill="freeze"/>
<animate attributeName="opacity" from="1" to="0" begin="last.end" dur="1ms" fill="freeze"/>
<rect x="50" y="0" width="50" height="50" fill="#F00"/>
</g>
<g id="c" opacity="0">
<animate attributeName="opacity" from="1" to="1" begin="first.end+20ms" dur="1ms" fill="freeze"/>
<animate attributeName="opacity" from="1" to="0" begin="last.end" dur="1ms" fill="freeze"/>
<rect x="100" y="0" width="50" height="50" fill="#F00"/>
</g>
<g id="d" opacity="0">
<animate attributeName="opacity" from="1" to="1" begin="first.end+30ms" dur="1ms" fill="freeze"/>
<animate attributeName="opacity" from="1" to="0" begin="last.end" dur="1ms" fill="freeze"/>
<rect x="150" y="0" width="50" height="50" fill="#F00"/>
</g>
<g id="e" opacity="0">
<animate attributeName="opacity" from="1" to="1" begin="first.end+40ms" dur="1ms" fill="freeze"
id="last" onend="onend_filling()"/>
<animate attributeName="opacity" from="1" to="0" begin="last.end" dur="1ms" fill="freeze"
onbegin="onend_clearing()"/>
<rect x="200" y="0" width="50" height="50" fill="#F00"/>
</g>
</svg>
<script>
let onend_clearing = null;
let onend_filling = null;
async_test(t => {
let svg = document.querySelector("svg");
// Deliberate no a
let b = document.querySelector("#b");
let c = document.querySelector("#c");
let d = document.querySelector("#d");
let e = document.querySelector("#e");
let passed = false;
let triggers = 0;
let filling_steps = 0;
onend_filling = t.step_func(() => {
filling_steps++;
if (filling_steps < 5) return;
svg.pauseAnimations();
assert_unreached("Fired too many onend events.");
});
onend_clearing = t.step_func(() => {
triggers++;
if (triggers != 3) return;
svg.pauseAnimations();
// We don't check the first element, since it might have started fading in
assert_equals(window.getComputedStyle(b, null).opacity, "0");
assert_equals(window.getComputedStyle(c, null).opacity, "0");
assert_equals(window.getComputedStyle(d, null).opacity, "0");
assert_equals(window.getComputedStyle(e, null).opacity, "0");
t.done();
});
});
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment