Bug 1320474 - Add tests for the use of <string> as keyframes-name. r=birtles
authorJonathan Kew <jkew@mozilla.com>
Tue, 29 Nov 2016 12:58:57 +0000
changeset 324703 f41a419197de988085637d058a9d86f1a9cc4014
parent 324702 bed1ca42b7b4a29ef1638bee5156ba27ff3c4c7d
child 324704 78f16019ce10c8a587501283e6bff54a838d8a8e
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbirtles
bugs1320474
milestone53.0a1
Bug 1320474 - Add tests for the use of <string> as keyframes-name. r=birtles
layout/style/test/test_animations.html
layout/style/test/test_animations_omta.html
--- a/layout/style/test/test_animations.html
+++ b/layout/style/test/test_animations.html
@@ -158,16 +158,48 @@ https://bugzilla.mozilla.org/show_bug.cg
   @keyframes overridetop {
     0%, 100% { top: 0px }
   }
 
   @keyframes opacitymid {
     0% { opacity: 0.2 }
     100% { opacity: 0.8 }
   }
+
+  @keyframes "string name 1" { /* using string for keyframes name */
+    0%, 100% { left: 1px }
+  }
+
+  @keyframes "string name 2" {
+    0%, 100% { left: 2px }
+  }
+
+  @keyframes custom\ ident\ 1 {
+    0%, 100% { left: 3px }
+  }
+
+  @keyframes custom\ ident\ 2 {
+    0%, 100% { left: 4px }
+  }
+
+  @keyframes "initial" {
+    0%, 100% { left: 5px }
+  }
+
+  @keyframes initial { /* illegal as an identifier, should be dropped */
+    0%, 100% { left: 6px }
+  }
+
+  @keyframes "none" {
+    0%, 100% { left: 7px }
+  }
+
+  @keyframes none { /* illegal as an identifier, should be dropped */
+    0%, 100% { left: 8px }
+  }
   </style>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435442">Mozilla Bug 435442</a>
 <div id="display"></div>
 <pre id="test">
 <script type="application/javascript">
 "use strict";
@@ -2034,14 +2066,41 @@ is(cs.getPropertyValue("opacity"), "0.8"
 advance_clock(500);
 is(cs.getPropertyValue("opacity"), "0.65", "opacity transition at 0.5s");
 div.style.animation = "opacitymid 2s linear";
 is(cs.getPropertyValue("opacity"), "0.2", "opacity animation overriding transition at 0s");
 advance_clock(500);
 is(cs.getPropertyValue("opacity"), "0.35", "opacity animation overriding transition at 0.5s");
 done_div();
 
+
+/*
+ * Bug 1320474 - keyframes-name may be a string, allows names that would otherwise be excluded
+ */
+new_div("position: relative; animation: \"string name 1\" 1s linear");
+advance_clock(0);
+is(cs.getPropertyValue("left"), "1px", "animation name as a string");
+div.style.animation = "string\\ name\\ 2 1s linear";
+is(cs.getPropertyValue("left"), "2px", "animation name specified as string, referenced using custom ident");
+div.style.animation = "custom\\ ident\\ 1 1s linear";
+is(cs.getPropertyValue("left"), "3px", "animation name specified as custom-ident");
+div.style.animation = "\"custom ident 2\" 1s linear";
+is(cs.getPropertyValue("left"), "4px", "animation name specified as custom-ident, referenced using string");
+div.style.animation = "unset";
+div.style.animation = "initial 1s linear";
+is(cs.getPropertyValue("left"), "0px", "animation name 'initial' as identifier is ignored");
+div.style.animation = "unset";
+div.style.animation = "\"initial\" 1s linear";
+is(cs.getPropertyValue("left"), "5px", "animation name 'initial' as string is accepted");
+div.style.animation = "unset";
+div.style.animation = "none 1s linear";
+is(cs.getPropertyValue("left"), "0px", "animation name 'none' as identifier is ignored");
+div.style.animation = "unset";
+div.style.animation = "\"none\" 1s linear";
+is(cs.getPropertyValue("left"), "7px", "animation name 'none' as string is accepted");
+done_div();
+
 SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
 
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_animations_omta.html
+++ b/layout/style/test/test_animations_omta.html
@@ -2232,16 +2232,22 @@ addAsyncAnimTest(function *() {
   omta_is("opacity", 0.2, RunningOn.Compositor,
           "opacity animation overriding transition at 0s");
   advance_clock(500);
   omta_is("opacity", 0.35, RunningOn.Compositor,
           "opacity animation overriding transition at 0.5s");
   done_div();
 });
 
+// Bug 1320474 - keyframes-name may be a string, allows names that would
+// otherwise be excluded.
+// These tests don't need to be duplicated here as they relate purely to
+// the animation setup which is common to both main-thread and compositor
+// animations.
+
 // Bug 847287 - Test that changes of when an animation is dynamically
 // overridden work correctly.
 addAsyncAnimTest(function *() {
   // anim2 and anim3 are both animations from opacity 0 to 1
 
   new_div("animation: anim2 1s linear forwards; opacity: 0.5 ! important");
   yield waitForPaintsFlushed();
   omta_is("opacity", 0.5, RunningOn.MainThread,