Bug 1302648 part 6 - Add animationcancel test to legacy tests. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 10 Feb 2017 12:32:44 +0900
changeset 481638 ca5aa204837e3100bf98b123ce1370f53bdfdef7
parent 481637 e15baf78be03d20bffd1113f2a7129bcb33a2929
child 481639 2396a5cbc7c13b3a5f7b4b5c15744b37a676136e
push id44889
push usermantaroh@gmail.com
push dateFri, 10 Feb 2017 08:41:14 +0000
reviewersbirtles
bugs1302648
milestone54.0a1
Bug 1302648 part 6 - Add animationcancel test to legacy tests. r?birtles MozReview-Commit-ID: ETOWjRQxUor
layout/style/test/test_animations_event_handler_attribute.html
layout/style/test/test_animations_event_order.html
--- a/layout/style/test/test_animations_event_handler_attribute.html
+++ b/layout/style/test/test_animations_event_handler_attribute.html
@@ -62,37 +62,61 @@ function checkReceivedEvents(eventType, 
         using ${element.handlerType}`);
     element.receivedEventType = undefined;
   });
 }
 
 // Take over the refresh driver right from the start.
 advance_clock(0);
 
-// 1. Test CSS Animation event handlers.
+// 1a. Test CSS Animation event handlers (without animationcancel)
 
 var targets = createAndRegisterTargets([ 'onanimationstart',
                                          'onanimationiteration',
-                                         'onanimationend' ]);
+                                         'onanimationend',
+                                         'onanimationcancel']);
 targets.forEach(div => {
   div.setAttribute('style', 'animation: anim 100ms 2');
   getComputedStyle(div).animationName;  // flush
 });
 
 advance_clock(0);
 checkReceivedEvents("animationstart", targets);
 
 advance_clock(100);
 checkReceivedEvents("animationiteration", targets);
 
 advance_clock(200);
 checkReceivedEvents("animationend", targets);
 
 targets.forEach(div => { div.remove(); });
 
+// 1b. Test CSS Animation cancel event handler
+var targets = createAndRegisterTargets([ 'onanimationcancel' ]);
+
+targets.forEach(div => {
+  div.setAttribute('style', 'animation: anim 100ms 2 200ms');
+  getComputedStyle(div).animationName;  // flush
+});
+
+advance_clock(200);
+
+targets.forEach(div => {
+  div.style.display = "none"
+  getComputedStyle(div).display; // flush
+});
+
+advance_clock(0);
+checkReceivedEvents("animationcancel", targets);
+
+advance_clock(200);
+
+targets.forEach(div => { div.remove(); });
+
+
 // 2a. Test CSS Transition event handlers (without transitioncancel)
 
 var targets = createAndRegisterTargets([ 'ontransitionrun',
                                          'ontransitionstart',
                                          'ontransitionend',
                                          'ontransitioncancel' ]);
 targets.forEach(div => {
   div.style.transition = 'margin-left 100ms 200ms';
--- a/layout/style/test/test_animations_event_order.html
+++ b/layout/style/test/test_animations_event_order.html
@@ -41,16 +41,17 @@ advance_clock(0);
 // Common test scaffolding
 
 var gEventsReceived = [];
 var gDisplay = document.getElementById('display');
 
 [ 'animationstart',
   'animationiteration',
   'animationend',
+  'animationcancel',
   'transitionrun',
   'transitionstart',
   'transitionend',
   'transitioncancel' ]
   .forEach(event =>
              gDisplay.addEventListener(event,
                                        event => gEventsReceived.push(event)));
 
@@ -655,13 +656,42 @@ checkEventOrder([ divs[0], 'transitionru
                 [ divs[0], 'transitionstart' ],
                 [ divs[1], 'transitioncancel' ],
                 [ divs[0], 'transitioncancel' ],
                 'Simultaneous transitionrun/start/cancel on siblings');
 
 divs.forEach(div => div.remove());
 divs = [];
 
+
+// 4k. Test sorting animations with cancel
+
+divs = [ document.createElement('div'),
+         document.createElement('div') ];
+
+divs.forEach((div, i) => {
+  gDisplay.appendChild(div);
+  div.style.marginLeft = '0px';
+  div.setAttribute('id', 'div' + i);
+});
+
+divs[0].style.animation = 'anim 10s 5s';
+divs[1].style.animation = 'anim 10s';
+
+getComputedStyle(divs[0]).animation; // flush
+
+advance_clock(0);  // divs[1]'s animation start
+advance_clock(5 * 1000);  // divs[0]'s animation start
+divs.forEach(div => div.style.display = 'none' );
+getComputedStyle(divs[0]).display;
+advance_clock(10 * 1000);
+
+checkEventOrder([ divs[1], 'animationstart' ],
+                [ divs[0], 'animationstart' ],
+                [ divs[1], 'animationcancel' ],
+                [ divs[0], 'animationcancel' ],
+                'Simultaneous animationcancel on siblings');
+
 SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
 
 </script>
 </body>
 </html>