| Index: LayoutTests/animations/keyframes-cssom-updates-animation.html
|
| diff --git a/LayoutTests/animations/keyframes-cssom-updates-animation.html b/LayoutTests/animations/keyframes-cssom-updates-animation.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..563970f2c6eaef7583c48640b8281b92e5cc3d59
|
| --- /dev/null
|
| +++ b/LayoutTests/animations/keyframes-cssom-updates-animation.html
|
| @@ -0,0 +1,63 @@
|
| +<!doctype html>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<style>
|
| + @keyframes anim {
|
| + 0% { left: 0px; }
|
| + 50% { left: 500px; }
|
| + 100% { left: 100px; }
|
| + }
|
| +
|
| + #target1 {
|
| + animation: anim 10s -3s linear paused;
|
| + }
|
| +
|
| + #target2 {
|
| + animation: anim 10s -2s linear paused;
|
| + }
|
| +</style>
|
| +<div id="target1"></div>
|
| +<div id="target2"></div>
|
| +<script>
|
| + test(function() {
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 300, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 200, 'left offset');
|
| +
|
| + var sheet = document.styleSheets[0];
|
| + var rules = sheet.rules;
|
| + for (var i = 0; i < rules.length; i++) {
|
| + if (rules[i].type == CSSRule.KEYFRAMES_RULE) {
|
| + rules[i].appendRule('20% { left: 500px; }');
|
| + rules[i].deleteRule('50%');
|
| + }
|
| + }
|
| +
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 450, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 500, 'left offset');
|
| +
|
| + var newKeyframeRuleIndex = sheet.rules.length;
|
| + sheet.insertRule('@keyframes anim { 0% { left: 0px; } 100% { left: 300px; } }', newKeyframeRuleIndex); // Should override 'anim'
|
| +
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 90, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 60, 'left offset');
|
| +
|
| + sheet.deleteRule(newKeyframeRuleIndex); // Should revert to original 'anim'
|
| +
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 450, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 500, 'left offset');
|
| +
|
| + newStyle = document.createElement('style');
|
| + newStyle.appendChild(document.createTextNode('@keyframes anim { 0% { left: 100px; } 100% { left: 400px; } }'));
|
| + document.head.appendChild(newStyle);
|
| +
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 190, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 160, 'left offset');
|
| +
|
| + newStyle.innerHTML = '@keyframes anim { 0% { left: 200px; } 100% { left: 400px; } }';
|
| + console.log(newStyle.innerHTML);
|
| +
|
| + assert_equals(parseInt(getComputedStyle(target1).left), 260, 'left offset');
|
| + assert_equals(parseInt(getComputedStyle(target2).left), 240, 'left offset');
|
| +
|
| + }, "Check that changes to animation via CSSOM update it accordingly");
|
| +</script>
|
|
|