Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: LayoutTests/web-animations-api/timeline-time.html

Issue 251183006: Web Animations: Timeline should not advance during task execution (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tick animation clock using approximate frame time. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/animation/AnimationClock.h » ('j') | Source/core/animation/AnimationClock.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/web-animations-api/timeline-time.html
diff --git a/LayoutTests/web-animations-api/timeline-time.html b/LayoutTests/web-animations-api/timeline-time.html
index 359e22662fd636f74fc37d8e8e7173f7386501d4..abe1a6b562e27a6189f6c760310d45b55a2e6d1d 100644
--- a/LayoutTests/web-animations-api/timeline-time.html
+++ b/LayoutTests/web-animations-api/timeline-time.html
@@ -2,25 +2,66 @@
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
-<body>
- <div id='element'></div>
-</body>
-
<script>
-var element = document.getElementById('element');
-var duration = 1;
-
-var animation = new Animation(element,
- [{opacity: '1', offset: 0},
- {opacity: '0', offset: 1}],
- duration);
-
test(function() {
- var startTime = document.timeline.currentTime;
- var player = document.timeline.play(animation);
- player.finish();
- var finishTime = document.timeline.currentTime;
- assert_greater_than_equal(startTime, 0);
- assert_equals(startTime, finishTime);
+ var startTime = document.timeline.currentTime;
+ assert_greater_than_equal(startTime, 0);
+ var start = performance.now();
+ while (performance.now() < start + 250)
+ /* wait */;
+ assert_equals(document.timeline.currentTime, startTime);
}, 'document.timeline.currentTime should not change within a script block.');
+
+(function() {
+ var timeoutTest = async_test('document.timeline.currentTime time should change after a script timeout');
+ var startTime = document.timeline.currentTime;
+
+ setTimeout(function() {
+ timeoutTest.step(function() {
+ assert_greater_than(document.timeline.currentTime, startTime);
+ });
+ timeoutTest.done();
+ }, 100);
+})();
+
+(function() {
+ var rafTest = async_test('document.timeline.currentTime time should be the same for all RAF callbacks in a frame');
+ var startTime = document.timeline.currentTime;
+ var firstRafTime;
+
+ requestAnimationFrame(function() {
+ rafTest.step(function() {
+ assert_greater_than(document.timeline.currentTime, startTime);
+ firstRafTime = document.timeline.currentTime;
+ });
+ });
+
+ requestAnimationFrame(function() {
+ rafTest.step(function() {
+ assert_equals(document.timeline.currentTime, firstRafTime);
+ });
+ rafTest.done();
+ });
+})();
+
+(function() {
+ var rafTest = async_test('document.timeline.currentTime time should be consistent with the time value passed to RAF callbacks');
+ var firstRafTime;
+ var firstRafDelta;
+
+ requestAnimationFrame(function(t) {
+ rafTest.step(function() {
+ firstRafTime = document.timeline.currentTime;
+ firstRafDelta = document.timeline.currentTime - t;
+ });
+
+ requestAnimationFrame(function(t) {
+ rafTest.step(function() {
+ assert_greater_than(document.timeline.currentTime, firstRafTime);
+ assert_equals(document.timeline.currentTime - t, firstRafDelta);
+ });
+ rafTest.done();
+ });
+ });
+})();
</script>
« no previous file with comments | « no previous file | Source/core/animation/AnimationClock.h » ('j') | Source/core/animation/AnimationClock.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698