Commit e6d08aad authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Rewrite wpt/svg/animations/slider-switch.html to use 'begin' as trigger

The interval timer could end up racing with the animation update timer,
meaning that the new animation values had not yet been applied when
the |retries| counter reached zero and the assertions were made.
Refactor the test to trigger the next "action" (new pair of clicks or
checking the result) when one of the timed elements listening on the
"b.click" event has begun. Also change |retries| into counting how many
clicks are remaining (rather than how many interval timer firings).

Bug: 1013736
Change-Id: I374cb9c499ca18a791f76dabcb1db8bcd6f38461
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1859955Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#705574}
parent 95ce24e7
<!doctype html> <!doctype html>
<title>Check correct event bases for onclick</title> <title>Check correct event bases for onclick</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#interact-EventAttributes"> <link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#interact-EventAttributes">
<link rel="author" title="Edvard Thörnros" href="mailto:edvardt@opera.com"> <link rel="author" title="Edvard Thörnros" href="mailto:edvardt@opera.com">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<svg width="200" height="100"> <svg width="200" height="100">
<rect x="0" y="0" width="100" height="100" id="a" fill="#0AA"> <rect x="0" y="0" width="100" height="100" id="a" fill="#0AA">
<set begin="a.click" attributeName="display" to="none" fill="freeze"/> <set begin="a.click" attributeName="display" to="none" fill="freeze"/>
...@@ -18,24 +15,33 @@ ...@@ -18,24 +15,33 @@
<set begin="b.click" attributeName="display" to="none" fill="freeze"/> <set begin="b.click" attributeName="display" to="none" fill="freeze"/>
</rect> </rect>
</svg> </svg>
<script> <script>
let retries = 3; let clicks_remaining = 2;
let a = document.querySelector("#a"); let a = document.querySelector("#a");
let b = document.querySelector("#b"); let b = document.querySelector("#b");
let t = async_test(); function perform_clicks(t) {
let interval = setInterval(t.step_func(function() {
retries--;
if (retries == 0) {
clearInterval(interval);
assert_equals(window.getComputedStyle(a).display, "block");
assert_equals(window.getComputedStyle(b).display, "none");
t.done();
return;
}
a.dispatchEvent(new Event("click"));
t.step_timeout(function() { t.step_timeout(function() {
b.dispatchEvent(new Event("click")); a.dispatchEvent(new Event("click"));
t.step_timeout(function() {
b.dispatchEvent(new Event("click"));
}, 20);
}, 20); }, 20);
}), 20 * 2); }
async_test(t => {
let observer = document.querySelector("#b > set + set");
observer.addEventListener('beginEvent', t.step_func(function() {
if (clicks_remaining == 0) {
assert_equals(window.getComputedStyle(a).display, "block");
assert_equals(window.getComputedStyle(b).display, "none");
t.done();
return;
}
perform_clicks(t);
clicks_remaining--;
}));
window.onload = t.step_func(() => {
perform_clicks(t);
clicks_remaining--;
});
});
</script> </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