dino@apple.com | fefa7b1 | 2014-11-13 01:23:15 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../resources/js-test-pre.js"></script> |
| 5 | </head> |
| 6 | <body> |
| 7 | <p id="description"></p> |
| 8 | <div id="console"></div> |
| 9 | <script> |
| 10 | |
| 11 | description("Test the unprefixed animation shorthand."); |
| 12 | |
| 13 | // These have to be global for the test helpers to see them. |
| 14 | var stylesheet, animationStyle; |
| 15 | var styleElement = document.createElement("style"); |
| 16 | document.head.appendChild(styleElement); |
| 17 | stylesheet = styleElement.sheet; |
| 18 | |
| 19 | function testAnimationShorthand(value, expectedName, expectedDuration, expectedDelay, expectedTimingFunction, expectedIterationCount, expectedDirection, expectedFillMode) |
| 20 | { |
| 21 | debug(""); |
| 22 | debug("Setting animation: " + value); |
| 23 | stylesheet.insertRule("body { animation: " + value + "; }", 0); |
| 24 | |
| 25 | debug("Check animation-name"); |
| 26 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-name"); |
| 27 | shouldBe("animationStyle.cssText", "'" + expectedName + "'"); |
| 28 | |
| 29 | debug("Check animation-duration"); |
| 30 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-duration"); |
| 31 | shouldBe("animationStyle.cssText", "'" + expectedDuration + "'"); |
| 32 | |
| 33 | debug("Check animation-delay"); |
| 34 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-delay"); |
| 35 | shouldBe("animationStyle.cssText", "'" + expectedDelay + "'"); |
| 36 | |
| 37 | debug("Check animation-timing-function"); |
| 38 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-timing-function"); |
| 39 | shouldBe("animationStyle.cssText", "'" + expectedTimingFunction + "'"); |
| 40 | |
| 41 | debug("Check animation-iteration-count"); |
| 42 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-iteration-count"); |
| 43 | shouldBe("animationStyle.cssText", "'" + expectedIterationCount + "'"); |
| 44 | |
| 45 | debug("Check animation-direction"); |
| 46 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-direction"); |
| 47 | shouldBe("animationStyle.cssText", "'" + expectedDirection + "'"); |
| 48 | |
| 49 | debug("Check animation-fill-mode"); |
| 50 | animationStyle = window.getComputedStyle(document.body).getPropertyCSSValue("animation-fill-mode"); |
| 51 | shouldBe("animationStyle.cssText", "'" + expectedFillMode + "'"); |
| 52 | |
| 53 | stylesheet.deleteRule(0); |
| 54 | } |
| 55 | |
| 56 | testAnimationShorthand("waldo", |
| 57 | "waldo", |
| 58 | "0s", |
| 59 | "0s", |
| 60 | "ease", |
| 61 | "1", |
| 62 | "normal", |
| 63 | "none"); |
| 64 | |
| 65 | testAnimationShorthand("waldo 2s", |
| 66 | "waldo", |
| 67 | "2s", |
| 68 | "0s", |
| 69 | "ease", |
| 70 | "1", |
| 71 | "normal", |
| 72 | "none"); |
| 73 | |
| 74 | testAnimationShorthand("3s banana 500ms", |
| 75 | "banana", |
| 76 | "3s", |
| 77 | "0.5s", |
| 78 | "ease", |
| 79 | "1", |
| 80 | "normal", |
| 81 | "none"); |
| 82 | |
| 83 | testAnimationShorthand("infinite alternate eggs 5s", |
| 84 | "eggs", |
| 85 | "5s", |
| 86 | "0s", |
| 87 | "ease", |
| 88 | "infinite", |
| 89 | "alternate", |
| 90 | "none"); |
| 91 | |
| 92 | testAnimationShorthand("forwards normal ease-in-out bacon 1s 2s", |
| 93 | "bacon", |
| 94 | "1s", |
| 95 | "2s", |
| 96 | "ease-in-out", |
| 97 | "1", |
| 98 | "normal", |
| 99 | "forwards"); |
| 100 | |
| 101 | testAnimationShorthand("pastrami 100ms cubic-bezier(0, 0, 1, 1) alternate-reverse", |
| 102 | "pastrami", |
| 103 | "0.1s", |
| 104 | "0s", |
| 105 | "cubic-bezier(0, 0, 1, 1)", |
| 106 | "1", |
| 107 | "alternate-reverse", |
| 108 | "none"); |
| 109 | |
| 110 | testAnimationShorthand("slightly-invalid 2s a", |
| 111 | "none", |
| 112 | "0s", |
| 113 | "0s", |
| 114 | "ease", |
| 115 | "1", |
| 116 | "normal", |
| 117 | "none"); |
| 118 | |
| 119 | testAnimationShorthand("completely invalid", |
| 120 | "none", |
| 121 | "0s", |
| 122 | "0s", |
| 123 | "ease", |
| 124 | "1", |
| 125 | "normal", |
| 126 | "none"); |
| 127 | |
| 128 | successfullyParsed = true; |
| 129 | |
| 130 | </script> |
| 131 | <script src="../resources/js-test-post.js"></script> |
| 132 | </body> |
| 133 | </html> |