|
4 | 4 | <link rel="help" href="https://w3c.github.io/web-animations/#the-documents-default-timeline">
|
5 | 5 | <script src="/resources/testharness.js"></script>
|
6 | 6 | <script src="/resources/testharnessreport.js"></script>
|
| 7 | +<script src="../../testcommon.js"></script> |
7 | 8 | <div id="log"></div>
|
8 | 9 | <iframe width="10" height="10" id="iframe"></iframe>
|
9 | 10 | <script>
|
|
20 | 21 | }, 'document.timeline identity tests');
|
21 | 22 |
|
22 | 23 | promise_test(function(t) {
|
| 24 | + var baseTime = document.timeline.currentTime; |
| 25 | + var iframe = document.getElementById('iframe'); |
| 26 | + var iframeBaseTime = iframe.contentDocument.timeline.currentTime; |
| 27 | + return waitForAnimationFrames(4).then(function() { |
| 28 | + var delta = document.timeline.currentTime - baseTime; |
| 29 | + var iframeDelta = iframe.contentDocument.timeline.currentTime - iframeBaseTime; |
| 30 | + assert_greater_than(delta, 0); |
| 31 | + assert_times_equal(delta, iframeDelta, 'different document timelines should progress at the same rate'); |
| 32 | + }); |
| 33 | +}, 'document.timeline should tick consistently across frames'); |
| 34 | + |
| 35 | +async_test(function(t) { |
23 | 36 | assert_true(document.timeline.currentTime > 0,
|
24 | 37 | 'document.timeline.currentTime is positive');
|
25 | 38 | // document.timeline.currentTime should be set even before document
|
|
35 | 48 | // We can't just compare document.timeline.currentTime to
|
36 | 49 | // window.performance.now() because currentTime is only updated on a sample
|
37 | 50 | // so we use requestAnimationFrame instead.
|
38 |
| - return window.requestAnimationFrame(t.step_func(function(rafTime) { |
39 |
| - assert_equals(document.timeline.currentTime, rafTime, |
40 |
| - 'document.timeline.currentTime matches' + |
41 |
| - ' requestAnimationFrame time'); |
42 |
| - })); |
| 51 | + window.requestAnimationFrame(function(rafTime) { |
| 52 | + t.step(function() { |
| 53 | + assert_equals(document.timeline.currentTime, rafTime, |
| 54 | + 'document.timeline.currentTime matches' + |
| 55 | + ' requestAnimationFrame time'); |
| 56 | + }); |
| 57 | + t.done(); |
| 58 | + }); |
43 | 59 | }, 'document.timeline.currentTime value tests');
|
44 | 60 |
|
45 | 61 | promise_test(function(t) {
|
|
50 | 66 | }
|
51 | 67 | assert_equals(document.timeline.currentTime, valueAtStart,
|
52 | 68 | 'document.timeline.currentTime does not change within a script block');
|
53 |
| - return window.requestAnimationFrame(t.step_func(function() { |
54 |
| - assert_true(document.timeline.currentTime > valueAtStart, |
| 69 | + return waitForAnimationFrames(1).then(function() { |
| 70 | + assert_greater_than(document.timeline.currentTime, valueAtStart, |
55 | 71 | 'document.timeline.currentTime increases between script blocks');
|
56 |
| - })); |
| 72 | + }); |
57 | 73 | }, 'document.timeline.currentTime liveness tests');
|
58 | 74 |
|
| 75 | +promise_test(function(t) { |
| 76 | + var iframeTimeline = iframe.contentDocument.timeline; |
| 77 | + var valueAtStart = iframeTimeline.currentTime; |
| 78 | + var timeAtStart = window.performance.now(); |
| 79 | + while (window.performance.now() - timeAtStart < 100) { |
| 80 | + // Wait 100ms |
| 81 | + } |
| 82 | + assert_equals(iframeTimeline.currentTime, valueAtStart, |
| 83 | + 'iframe document.timeline.currentTime does not change within a script block'); |
| 84 | + return waitForAnimationFrames(1).then(function() { |
| 85 | + assert_greater_than(iframeTimeline.currentTime, valueAtStart, |
| 86 | + 'iframe document.timeline.currentTime increases between script blocks'); |
| 87 | + }); |
| 88 | +}, 'iframe document.timeline.currentTime liveness tests'); |
| 89 | + |
59 | 90 | async_test(function(t) {
|
60 | 91 | var startTime = document.timeline.currentTime;
|
61 | 92 | var firstRafTime;
|
|
0 commit comments