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

Unified Diff: polymer_0.5.0/bower_components/web-animations-js/test/js/effect-callback.js

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 12 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
Index: polymer_0.5.0/bower_components/web-animations-js/test/js/effect-callback.js
diff --git a/polymer_0.5.0/bower_components/web-animations-js/test/js/effect-callback.js b/polymer_0.5.0/bower_components/web-animations-js/test/js/effect-callback.js
new file mode 100644
index 0000000000000000000000000000000000000000..d9dd897eb8fd06c62edc5e13e21e1cda937b7b10
--- /dev/null
+++ b/polymer_0.5.0/bower_components/web-animations-js/test/js/effect-callback.js
@@ -0,0 +1,76 @@
+suite('effect-callback', function() {
+ setup(function() {
+ document.timeline._players = [];
+ webAnimationsMinifill.timeline._players = [];
+ });
+
+ test('animations starting in the future are not in effect', function() {
+ var fractions = [];
+ tick(100);
+ var player = document.body.animate(function(fraction) { fractions.push(fraction); }, 1000);
+ player.startTime = 1000;
+ tick(200);
+ tick(1000);
+ tick(1100);
+ assert.deepEqual(fractions, [null, 0, 0.1]);
+ });
+
+ test('duration 0 players get sampled at least once', function() {
+ var timeFraction;
+ tick(0);
+ var player = document.body.animate(function(t) {
+ timeFraction = t;
+ }, {duration: 0, fill: 'both'});
+ tick(100);
+ assert.equal(timeFraction, 1);
+ assert.equal(isTicking(), false);
+ });
+
+ test('players added during custom effect callbacks get updated in the same tick', function() {
+ var player;
+ var called = false;
+ tick(0);
+ document.body.animate(function() {
+ player = document.body.animate(function() {
+ called = true;
+ }, 1);
+ }, 2);
+ tick(1);
+ assert.isTrue(player.startTime >= 0);
+ assert.isFalse(called);
+ });
+
+ test('custom effect should be called after cancel', function() {
+ var fractions = [];
+ var player = document.body.animate(function(fraction) { fractions.push(fraction); }, 1000);
+ tick(0);
+ tick(500);
+ player.cancel();
+ tick(501);
+ assert.deepEqual(fractions, [0, 0.5, null]);
+ });
+
+ test('element.animate is given animation', function() {
+ var callbackAnim;
+ var player = document.body.animate(function(t, target, a) {
+ callbackAnim = a;
+ }, 100);
+ tick(50);
+ tick(150);
+ assert.equal(isTicking(), false);
+ assert(callbackAnim, 'callback should be set');
+ assert.equal(callbackAnim.target, document.body);
+ });
+
+ test('effect callback on animation is given source animation', function() {
+ var callbackAnim;
+ var anim = new Animation(document.body, function(t, target, a) {
+ callbackAnim = a;
+ }, 1000);
+ var player = document.timeline.play(anim);
+ tick(50);
+ tick(550);
+ assert.equal(player.currentTime, 500);
+ assert.equal(callbackAnim, anim);
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698