зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1415346 - Bind onxx event handler before creating EventWatcher. r=birtles
MozReview-Commit-ID: 83KwkxBq7pK --HG-- extra : rebase_source : 1fb4b31a290f9bc354513970a9f48e26130af65f
This commit is contained in:
Родитель
db1806bf05
Коммит
1bd79ec0e6
|
@ -43,18 +43,22 @@ AnimationEventHandler.prototype.clear = () => {
|
|||
|
||||
function setupAnimation(t, animationStyle) {
|
||||
const div = addDiv(t, { style: 'animation: ' + animationStyle });
|
||||
// Note that this AnimationEventHandler should be created before EventWatcher
|
||||
// to capture all events in the handler prior to the EventWatcher since
|
||||
// testharness.js proceeds when the EventWatcher received watching events.
|
||||
const handler = new AnimationEventHandler(div);
|
||||
const watcher = new EventWatcher(t, div, [ 'animationstart',
|
||||
'animationiteration',
|
||||
'animationend',
|
||||
'animationcancel' ]);
|
||||
const animation = div.getAnimations()[0];
|
||||
|
||||
return [animation, watcher, div];
|
||||
return { animation, watcher, div, handler };
|
||||
}
|
||||
|
||||
promise_test(t => {
|
||||
// Add 1ms delay to ensure that the delay is not included in the elapsedTime.
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s 1ms');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s 1ms');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
assert_equals(evt.elapsedTime, 0.0);
|
||||
|
@ -62,8 +66,7 @@ promise_test(t => {
|
|||
}, 'Idle -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] = setupAnimation(t, 'anim 100s');
|
||||
const handler = new AnimationEventHandler(div);
|
||||
const { animation, watcher, div, handler } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
// Seek to After phase.
|
||||
animation.finish();
|
||||
|
@ -75,7 +78,7 @@ promise_test(t => {
|
|||
}, 'Idle -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] =
|
||||
const { animation, watcher } =
|
||||
setupAnimation(t, 'anim 100s 100s paused');
|
||||
|
||||
return animation.ready.then(() => {
|
||||
|
@ -88,9 +91,8 @@ promise_test(t => {
|
|||
}, 'Before -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] =
|
||||
const { animation, watcher, div, handler } =
|
||||
setupAnimation(t, 'anim 100s 100s paused');
|
||||
const handler = new AnimationEventHandler(div);
|
||||
|
||||
return animation.ready.then(() => {
|
||||
// Seek to After phase.
|
||||
|
@ -103,7 +105,7 @@ promise_test(t => {
|
|||
}, 'Before -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] = setupAnimation(t, 'anim 100s paused');
|
||||
const { animation, watcher, div } = setupAnimation(t, 'anim 100s paused');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -115,7 +117,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, display: none');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
animation.currentTime = 100.0;
|
||||
|
@ -129,7 +131,7 @@ promise_test(t => {
|
|||
|
||||
promise_test(t => {
|
||||
// we should NOT pause animation since calling cancel synchronously.
|
||||
const [animation, watcher, div] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
animation.currentTime = 50.0;
|
||||
|
@ -141,7 +143,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, calling Animation.cancel()');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] =
|
||||
const { animation, watcher } =
|
||||
setupAnimation(t, 'anim 100s 100s paused');
|
||||
|
||||
// Seek to Active phase.
|
||||
|
@ -156,7 +158,7 @@ promise_test(t => {
|
|||
}, 'Active -> Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s paused');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s paused');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Seek to After phase.
|
||||
|
@ -168,9 +170,8 @@ promise_test(t => {
|
|||
}, 'Active -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] =
|
||||
const { animation, watcher, div, handler } =
|
||||
setupAnimation(t, 'anim 100s 100s paused');
|
||||
const handler = new AnimationEventHandler(div);
|
||||
|
||||
// Seek to After phase.
|
||||
animation.finish();
|
||||
|
@ -187,7 +188,7 @@ promise_test(t => {
|
|||
}, 'After -> Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] =
|
||||
const { animation, watcher, div } =
|
||||
setupAnimation(t, 'anim 100s 100s paused');
|
||||
|
||||
// Seek to After phase.
|
||||
|
@ -203,7 +204,7 @@ promise_test(t => {
|
|||
}, 'After -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div]
|
||||
const { animation, watcher, div }
|
||||
= setupAnimation(t, 'anim 100s 100s 3 paused');
|
||||
|
||||
return animation.ready.then(() => {
|
||||
|
@ -225,7 +226,7 @@ promise_test(t => {
|
|||
}, 'Active -> Active (forwards)');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s 100s 3');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s 100s 3');
|
||||
|
||||
// Seek to After phase.
|
||||
animation.finish();
|
||||
|
@ -248,7 +249,7 @@ promise_test(t => {
|
|||
}, 'Active -> Active (backwards)');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher, div] =
|
||||
const { animation, watcher, div } =
|
||||
setupAnimation(t, 'anim 100s paused');
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Seek to Idle phase.
|
||||
|
@ -264,7 +265,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle -> Active: animationstart is fired by restarting animation');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] =
|
||||
const { animation, watcher } =
|
||||
setupAnimation(t, 'anim 100s 100s 2 paused');
|
||||
|
||||
// Make After.
|
||||
|
@ -290,7 +291,7 @@ promise_test(t => {
|
|||
}, 'Negative playbackRate sanity test(Before -> Active -> Before)');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -304,7 +305,7 @@ promise_test(t => {
|
|||
}, 'Call Animation.cancel after cancelling animation.');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -316,7 +317,7 @@ promise_test(t => {
|
|||
}, 'Restart animation after cancelling animation immediately.');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -331,7 +332,7 @@ promise_test(t => {
|
|||
}, 'Call Animation.cancel after restarting animation immediately.');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -345,7 +346,7 @@ promise_test(t => {
|
|||
}, 'Set timeline and play transition after clearing the timeline.');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
// Make idle
|
||||
|
@ -359,7 +360,7 @@ promise_test(t => {
|
|||
}, 'Set null target effect after cancelling the animation.');
|
||||
|
||||
promise_test(t => {
|
||||
const [animation, watcher] = setupAnimation(t, 'anim 100s');
|
||||
const { animation, watcher } = setupAnimation(t, 'anim 100s');
|
||||
|
||||
return watcher.wait_for('animationstart').then(evt => {
|
||||
animation.effect = null;
|
||||
|
|
|
@ -38,6 +38,10 @@ TransitionEventHandler.prototype.clear = () => {
|
|||
|
||||
function setupTransition(t, transitionStyle) {
|
||||
const div = addDiv(t, { style: 'transition: ' + transitionStyle });
|
||||
// Note that this TransitionEventHandler should be created before EventWatcher
|
||||
// to capture all events in the handler prior to the EventWatcher since
|
||||
// testharness.js proceeds when the EventWatcher received watching events.
|
||||
const handler = new TransitionEventHandler(div);
|
||||
const watcher = new EventWatcher(t, div, [ 'transitionrun',
|
||||
'transitionstart',
|
||||
'transitionend',
|
||||
|
@ -47,13 +51,13 @@ function setupTransition(t, transitionStyle) {
|
|||
div.style.marginLeft = '100px';
|
||||
const transition = div.getAnimations()[0];
|
||||
|
||||
return [transition, watcher, div];
|
||||
return { transition, watcher, div, handler };
|
||||
}
|
||||
|
||||
// On the next frame (i.e. when events are queued), whether or not the
|
||||
// transition is still pending depends on the implementation.
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
return watcher.wait_for('transitionrun').then(evt => {
|
||||
assert_equals(evt.elapsedTime, 0.0);
|
||||
|
@ -61,7 +65,7 @@ promise_test(t => {
|
|||
}, 'Idle -> Pending or Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
// Force the transition to leave the idle phase
|
||||
transition.startTime = document.timeline.currentTime;
|
||||
|
@ -71,9 +75,8 @@ promise_test(t => {
|
|||
}, 'Idle -> Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
// Seek to Active phase.
|
||||
transition.currentTime = 100 * MS_PER_SEC;
|
||||
|
@ -86,9 +89,8 @@ promise_test(t => {
|
|||
}, 'Idle or Pending -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
// Seek to After phase.
|
||||
transition.finish();
|
||||
|
@ -102,7 +104,7 @@ promise_test(t => {
|
|||
}, 'Idle or Pending -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return Promise.all([ watcher.wait_for('transitionrun'),
|
||||
|
@ -117,7 +119,7 @@ promise_test(t => {
|
|||
}, 'Before -> Idle (display: none)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return Promise.all([ watcher.wait_for('transitionrun'),
|
||||
|
@ -131,7 +133,7 @@ promise_test(t => {
|
|||
}, 'Before -> Idle (Animation.timeline = null)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return Promise.all([ watcher.wait_for('transitionrun'),
|
||||
|
@ -144,9 +146,8 @@ promise_test(t => {
|
|||
}, 'Before -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
return Promise.all([ watcher.wait_for('transitionrun'),
|
||||
transition.ready ]).then(() => {
|
||||
|
@ -160,7 +161,7 @@ promise_test(t => {
|
|||
}, 'Before -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s');
|
||||
|
||||
// Seek to Active start position.
|
||||
|
@ -177,7 +178,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, no delay (display: none)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s');
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
|
@ -192,7 +193,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, no delay (Animation.timeline = null)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
// Pause so the currentTime is fixed and we can accurately compare the event
|
||||
// time in transition cancel events.
|
||||
|
@ -212,7 +213,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, with positive delay (display: none)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
// Seek to Active phase.
|
||||
|
@ -229,7 +230,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, with positive delay (Animation.timeline = null)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s -50s');
|
||||
|
||||
// Pause so the currentTime is fixed and we can accurately compare the event
|
||||
|
@ -248,7 +249,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, with negative delay (display: none)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s -50s');
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
|
@ -263,7 +264,7 @@ promise_test(t => {
|
|||
}, 'Active -> Idle, with negative delay (Animation.timeline = null)');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
// Seek to Active phase.
|
||||
transition.currentTime = 100 * MS_PER_SEC;
|
||||
|
@ -278,7 +279,7 @@ promise_test(t => {
|
|||
}, 'Active -> Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
// Seek to Active phase.
|
||||
transition.currentTime = 100 * MS_PER_SEC;
|
||||
|
@ -293,9 +294,8 @@ promise_test(t => {
|
|||
}, 'Active -> After');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
// Seek to After phase.
|
||||
transition.finish();
|
||||
|
@ -312,7 +312,7 @@ promise_test(t => {
|
|||
}, 'After -> Before');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
// Seek to After phase.
|
||||
transition.finish();
|
||||
|
@ -328,9 +328,8 @@ promise_test(t => {
|
|||
}, 'After -> Active');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s -50s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
'transitionstart' ]).then(() => {
|
||||
|
@ -344,9 +343,8 @@ promise_test(t => {
|
|||
}, 'Calculating the interval start and end time with negative start delay.');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div, handler } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
const handler = new TransitionEventHandler(div);
|
||||
|
||||
return watcher.wait_for('transitionrun').then(evt => {
|
||||
// We can't set the end delay via generated effect timing.
|
||||
|
@ -373,7 +371,7 @@ promise_test(t => {
|
|||
}, 'Calculating the interval start and end time with negative end delay.');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return watcher.wait_for('transitionrun').then(() => {
|
||||
|
@ -389,7 +387,7 @@ promise_test(t => {
|
|||
}, 'Call Animation.cancel after cancelling transition.');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return watcher.wait_for('transitionrun').then(evt => {
|
||||
|
@ -404,7 +402,7 @@ promise_test(t => {
|
|||
}, 'Restart transition after cancelling transition immediately');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s 100s');
|
||||
|
||||
return watcher.wait_for('transitionrun').then(evt => {
|
||||
|
@ -421,7 +419,7 @@ promise_test(t => {
|
|||
}, 'Call Animation.cancel after restarting transition immediately');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher] =
|
||||
const { transition, watcher } =
|
||||
setupTransition(t, 'margin-left 100s');
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
|
@ -438,7 +436,7 @@ promise_test(t => {
|
|||
}, 'Set timeline and play transition after clear the timeline');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s');
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
|
@ -455,7 +453,7 @@ promise_test(t => {
|
|||
}, 'Set null target effect after cancel the transition');
|
||||
|
||||
promise_test(t => {
|
||||
const [transition, watcher, div] =
|
||||
const { transition, watcher, div } =
|
||||
setupTransition(t, 'margin-left 100s');
|
||||
|
||||
return watcher.wait_for([ 'transitionrun',
|
||||
|
|
Загрузка…
Ссылка в новой задаче