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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/web-animations/interfaces/KeyframeEffect/setTarget.html

Issue 1999243002: Import wpt@5df9b57edb3307a87d5187804b29c8ddd2aa14e1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add expectations files (using run-webkit-tests --new-baseline) Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Writable effect.target tests</title>
4 <link rel="help"
5 href="https://w3c.github.io/web-animations/#dom-keyframeeffect-target">
6 <script src="../../../../../resources/testharness.js"></script>
7 <script src="../../../../../resources/testharnessreport.js"></script>
8 <script src="../../testcommon.js"></script>
9 <body>
10 <div id="log"></div>
11 <script>
12 "use strict";
13
14 var gKeyFrames = { 'marginLeft': ['0px', '100px'] };
15
16 test(function(t) {
17 var div = createDiv(t);
18 var effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
19 effect.target = div;
20
21 var anim = new Animation(effect, document.timeline);
22 anim.play();
23
24 anim.currentTime = 50 * MS_PER_SEC;
25 assert_equals(getComputedStyle(div).marginLeft, '50px',
26 'Value at 50% progress');
27 }, 'Test setting target before constructing the associated animation');
28
29 test(function(t) {
30 var div = createDiv(t);
31 div.style.marginLeft = '10px';
32 var effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
33 var anim = new Animation(effect, document.timeline);
34 anim.play();
35
36 anim.currentTime = 50 * MS_PER_SEC;
37 assert_equals(getComputedStyle(div).marginLeft, '10px',
38 'Value at 50% progress before setting new target');
39 effect.target = div;
40 assert_equals(getComputedStyle(div).marginLeft, '50px',
41 'Value at 50% progress after setting new target');
42 }, 'Test setting target from null to a valid target');
43
44 test(function(t) {
45 var div = createDiv(t);
46 div.style.marginLeft = '10px';
47 var anim = div.animate(gKeyFrames, 100 * MS_PER_SEC);
48
49 anim.currentTime = 50 * MS_PER_SEC;
50 assert_equals(getComputedStyle(div).marginLeft, '50px',
51 'Value at 50% progress before clearing the target')
52
53 anim.effect.target = null;
54 assert_equals(getComputedStyle(div).marginLeft, '10px',
55 'Value after clearing the target')
56 }, 'Test setting target from a valid target to null');
57
58 test(function(t) {
59 var a = createDiv(t);
60 var b = createDiv(t);
61 a.style.marginLeft = '10px';
62 b.style.marginLeft = '20px';
63 var anim = a.animate(gKeyFrames, 100 * MS_PER_SEC);
64
65 anim.currentTime = 50 * MS_PER_SEC;
66 assert_equals(getComputedStyle(a).marginLeft, '50px',
67 'Value of 1st element (currently targeted) before ' +
68 'changing the effect target');
69 assert_equals(getComputedStyle(b).marginLeft, '20px',
70 'Value of 2nd element (currently not targeted) before ' +
71 'changing the effect target');
72 anim.effect.target = b;
73 assert_equals(getComputedStyle(a).marginLeft, '10px',
74 'Value of 1st element (currently not targeted) after ' +
75 'changing the effect target');
76 assert_equals(getComputedStyle(b).marginLeft, '50px',
77 'Value of 2nd element (currently targeted) after ' +
78 'changing the effect target');
79
80 // This makes sure the animation property is changed correctly on new
81 // targeted element.
82 anim.currentTime = 75 * MS_PER_SEC;
83 assert_equals(getComputedStyle(b).marginLeft, '75px',
84 'Value of 2nd target (currently targeted) after ' +
85 'changing the animation current time.');
86 }, 'Test setting target from a valid target to another target');
87
88 </script>
89 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698