Bug 1302648 part 6 - Add animationcancel test to legacy tests. r?birtles
MozReview-Commit-ID: ETOWjRQxUor
--- 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>