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

Side by Side Diff: LayoutTests/animations/keyframes-cssom-updates-animation.html

Issue 814083003: Update animation when changes in animation keyframes are detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Detect when style changes to a different object 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 <!doctype html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <style>
5 @keyframes anim {
6 0% { left: 0px; }
7 50% { left: 500px; }
8 100% { left: 100px; }
9 }
10
11 #target1 {
12 animation: anim 10s -3s linear paused;
13 }
14
15 #target2 {
16 animation: anim 10s -2s linear paused;
17 }
18 </style>
19 <div id="target1"></div>
20 <div id="target2"></div>
21 <script>
22 test(function() {
23 assert_equals(parseInt(getComputedStyle(target1).left), 300, 'left offset');
24 assert_equals(parseInt(getComputedStyle(target2).left), 200, 'left offset');
25
26 var sheet = document.styleSheets[0];
27 var rules = sheet.rules;
28 for (var i = 0; i < rules.length; i++) {
29 if (rules[i].type == CSSRule.KEYFRAMES_RULE) {
30 rules[i].appendRule('20% { left: 500px; }');
31 rules[i].deleteRule('50%');
32 }
33 }
34
35 assert_equals(parseInt(getComputedStyle(target1).left), 450, 'left offset');
36 assert_equals(parseInt(getComputedStyle(target2).left), 500, 'left offset');
37
38 var newKeyframeRuleIndex = sheet.rules.length;
39 sheet.insertRule('@keyframes anim { 0% { left: 0px; } 100% { left: 300px; } }', newKeyframeRuleIndex); // Should override 'anim'
40
41 assert_equals(parseInt(getComputedStyle(target1).left), 90, 'left offset');
42 assert_equals(parseInt(getComputedStyle(target2).left), 60, 'left offset');
43
44 sheet.deleteRule(newKeyframeRuleIndex); // Should revert to original 'anim'
45
46 assert_equals(parseInt(getComputedStyle(target1).left), 450, 'left offset');
47 assert_equals(parseInt(getComputedStyle(target2).left), 500, 'left offset');
48
49 newStyle = document.createElement('style');
50 newStyle.appendChild(document.createTextNode('@keyframes anim { 0% { left: 1 00px; } 100% { left: 400px; } }'));
51 document.head.appendChild(newStyle);
52
53 assert_equals(parseInt(getComputedStyle(target1).left), 190, 'left offset');
54 assert_equals(parseInt(getComputedStyle(target2).left), 160, 'left offset');
55
56 newStyle.innerHTML = '@keyframes anim { 0% { left: 200px; } 100% { left: 400 px; } }';
57 console.log(newStyle.innerHTML);
58
59 assert_equals(parseInt(getComputedStyle(target1).left), 260, 'left offset');
60 assert_equals(parseInt(getComputedStyle(target2).left), 240, 'left offset');
61
62 }, "Check that changes to animation via CSSOM update it accordingly");
63 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698