Debian Codegraph @

testing/web-platform/mozilla/tests/svg/smil-sampling.html

raw
1 <!doctype html>
2 <meta charset="utf-8">
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <svg width="100" height="100">
6 <rect width="100" height="100" fill="blue">
7 <animate attributeName="fill" from="brown" to="red" dur="1000s"/>
8 </rect>
9 </svg>
10 <script>
11 function isSampling() {
12 return SpecialPowers.wrap(window).windowUtils.refreshDriverHasPendingTick;
13 }
14 function tick() {
15 return new Promise(r => {
16 requestAnimationFrame(() => requestAnimationFrame(r));
17 });
18 }
19
20 // See comment in layout/base/tests/test_bug1756118.html about why the timeouts
21 // etc.
22 async function expectTicksToStop() {
23 for (let i = 0; i < 100; i++) {
24 await new Promise(r => setTimeout(r, 8));
25 if(!isSampling()) {
26 break;
27 }
28 }
29 assert_false(isSampling(), "refresh driver should have eventually stopped ticking");
30 }
31
32 promise_test(async function(t) {
33 await tick();
34 assert_true(isSampling(), "Animation should be running");
35 let svg = document.querySelector("svg");
36 svg.remove();
37 await tick();
38 await expectTicksToStop();
39
40 document.body.appendChild(svg);
41 await tick();
42 assert_true(isSampling(), "Animation should be running again");
43 });
44 </script>