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

Side by Side 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, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 suite('effect-callback', function() {
2 setup(function() {
3 document.timeline._players = [];
4 webAnimationsMinifill.timeline._players = [];
5 });
6
7 test('animations starting in the future are not in effect', function() {
8 var fractions = [];
9 tick(100);
10 var player = document.body.animate(function(fraction) { fractions.push(fract ion); }, 1000);
11 player.startTime = 1000;
12 tick(200);
13 tick(1000);
14 tick(1100);
15 assert.deepEqual(fractions, [null, 0, 0.1]);
16 });
17
18 test('duration 0 players get sampled at least once', function() {
19 var timeFraction;
20 tick(0);
21 var player = document.body.animate(function(t) {
22 timeFraction = t;
23 }, {duration: 0, fill: 'both'});
24 tick(100);
25 assert.equal(timeFraction, 1);
26 assert.equal(isTicking(), false);
27 });
28
29 test('players added during custom effect callbacks get updated in the same tic k', function() {
30 var player;
31 var called = false;
32 tick(0);
33 document.body.animate(function() {
34 player = document.body.animate(function() {
35 called = true;
36 }, 1);
37 }, 2);
38 tick(1);
39 assert.isTrue(player.startTime >= 0);
40 assert.isFalse(called);
41 });
42
43 test('custom effect should be called after cancel', function() {
44 var fractions = [];
45 var player = document.body.animate(function(fraction) { fractions.push(fract ion); }, 1000);
46 tick(0);
47 tick(500);
48 player.cancel();
49 tick(501);
50 assert.deepEqual(fractions, [0, 0.5, null]);
51 });
52
53 test('element.animate is given animation', function() {
54 var callbackAnim;
55 var player = document.body.animate(function(t, target, a) {
56 callbackAnim = a;
57 }, 100);
58 tick(50);
59 tick(150);
60 assert.equal(isTicking(), false);
61 assert(callbackAnim, 'callback should be set');
62 assert.equal(callbackAnim.target, document.body);
63 });
64
65 test('effect callback on animation is given source animation', function() {
66 var callbackAnim;
67 var anim = new Animation(document.body, function(t, target, a) {
68 callbackAnim = a;
69 }, 1000);
70 var player = document.timeline.play(anim);
71 tick(50);
72 tick(550);
73 assert.equal(player.currentTime, 500);
74 assert.equal(callbackAnim, anim);
75 });
76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698