Bug 1415346 - Bind onxx event handler before creating EventWatcher. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 08 Nov 2017 12:45:15 +0900
changeset 694700 8002e3ec351fb292dcfe8de5a15fe309e4d64edc
parent 694699 05aeb96b8fc197b379296be378007af3b266d53b
child 694701 88a84eb3dd920c3e97a78f2acc2b56e6022a31be
push id88205
push userhikezoe@mozilla.com
push dateWed, 08 Nov 2017 03:47:13 +0000
reviewersbirtles
bugs1415346
milestone58.0a1
Bug 1415346 - Bind onxx event handler before creating EventWatcher. r?birtles MozReview-Commit-ID: 83KwkxBq7pK
dom/animation/test/css-animations/file_event-dispatch.html
dom/animation/test/css-transitions/file_event-dispatch.html
--- a/dom/animation/test/css-animations/file_event-dispatch.html
+++ b/dom/animation/test/css-animations/file_event-dispatch.html
@@ -38,177 +38,178 @@ AnimationEventHandler.prototype.clear = 
   this.animationstart     = undefined;
   this.animationiteration = undefined;
   this.animationend       = undefined;
   this.animationcancel    = undefined;
 }
 
 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);
   });
 }, '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();
   return watcher.wait_for([ 'animationstart',
                             'animationend' ]).then(() => {
     assert_equals(handler.animationstart, 0.0);
     assert_equals(handler.animationend, 100);
   });
 }, 'Idle -> After');
 
 promise_test(t => {
-  const [animation, watcher] =
+  const { animation, watcher } =
     setupAnimation(t, 'anim 100s 100s paused');
 
   return animation.ready.then(() => {
     // Seek to Active phase.
     animation.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('animationstart');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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.
     animation.finish();
     return watcher.wait_for([ 'animationstart', 'animationend' ]);
   }).then(evt => {
     assert_equals(handler.animationstart, 0.0);
     assert_equals(handler.animationend, 100.0);
   });
 }, '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
     div.style.display = 'none';
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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;
     // Make idle
     animation.timeline = null;
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     assert_times_equal(evt.elapsedTime, 0.1);
   });
 }, 'Active -> Idle, setting Animation.timeline = null');
 
 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;
     animation.cancel();
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     assert_times_equal(evt.elapsedTime, 0.05);
   });
 }, 'Active -> Idle, calling Animation.cancel()');
 
 promise_test(t => {
-  const [animation, watcher] =
+  const { animation, watcher } =
     setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to Active phase.
   animation.currentTime = 100 * MS_PER_SEC;
   return watcher.wait_for('animationstart').then(() => {
     // Seek to Before phase.
     animation.currentTime = 0;
     return watcher.wait_for('animationend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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.
     animation.finish();
     return watcher.wait_for('animationend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, '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();
   return watcher.wait_for([ 'animationstart',
                             'animationend' ]).then(() => {
     // Seek to Before phase.
     animation.currentTime = 0;
     handler.clear();
     return watcher.wait_for([ 'animationstart', 'animationend' ]);
   }).then(() => {
     assert_equals(handler.animationstart, 100.0);
     assert_equals(handler.animationend, 0.0);
   });
 }, 'After -> Before');
 
 promise_test(t => {
-  const [animation, watcher, div] =
+  const { animation, watcher, div } =
     setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to After phase.
   animation.finish();
   return watcher.wait_for([ 'animationstart',
                             'animationend' ]).then(() => {
     // Seek to Active phase.
     animation.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('animationstart');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, 'After -> Active');
 
 promise_test(t => {
-  const [animation, watcher, div]
+  const { animation, watcher, div }
     = setupAnimation(t, 'anim 100s 100s 3 paused');
 
   return animation.ready.then(() => {
     // Seek to iteration 0 (no animationiteration event should be dispatched)
     animation.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('animationstart');
   }).then(evt => {
     // Seek to iteration 2
@@ -220,17 +221,17 @@ promise_test(t => {
     animation.currentTime = 400 * MS_PER_SEC;
     return watcher.wait_for('animationend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 300);
   });
 }, '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();
   return watcher.wait_for([ 'animationstart',
                             'animationend' ]).then(() => {
     // Seek to iteration 2 (no animationiteration event should be dispatched)
     animation.pause();
     animation.currentTime = 300 * MS_PER_SEC;
@@ -243,33 +244,33 @@ promise_test(t => {
     assert_equals(evt.elapsedTime, 200.0);
     // Seek to before phase (no animationiteration event should be dispatched)
     animation.currentTime = 0;
     return watcher.wait_for('animationend');
   });
 }, '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.
     div.style.display = 'none';
     flushComputedStyle(div);
 
     return watcher.wait_for('animationcancel');
   }).then(() => {
     // Restart this animation.
     div.style.display = '';
     return watcher.wait_for('animationstart');
   });
 }, '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.
   animation.finish();
   return watcher.wait_for([ 'animationstart',
                             'animationend' ]).then(evt => {
     animation.playbackRate = -1;
     return watcher.wait_for('animationstart');
@@ -285,86 +286,86 @@ promise_test(t => {
     return watcher.wait_for('animationend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0);
     assert_equals(animation.playState, 'running'); // delay
   });
 }, '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
     animation.cancel();
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     animation.cancel();
     // Then wait a couple of frames and check that no event was dispatched.
     return waitForAnimationFrames(2);
   });
 }, '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
     animation.cancel();
     animation.play();
     return watcher.wait_for([ 'animationcancel',
                               'animationstart' ]);
   });
 }, '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
     animation.cancel();
     animation.play();
     animation.cancel();
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     // Then wait a couple of frames and check that no event was dispatched.
     return waitForAnimationFrames(2);
   });
 }, '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
     animation.timeline = null;
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     animation.timeline = document.timeline;
     animation.play();
     return watcher.wait_for('animationstart');
   });
 }, '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
     animation.cancel();
     return watcher.wait_for('animationcancel');
   }).then(evt => {
     animation.effect = null;
     // Then wait a couple of frames and check that no event was dispatched.
     return waitForAnimationFrames(2);
   });
 }, '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;
     return watcher.wait_for('animationend');
   }).then(evt => {
     animation.cancel();
     // Then wait a couple of frames and check that no event was dispatched.
     return waitForAnimationFrames(2);
--- a/dom/animation/test/css-transitions/file_event-dispatch.html
+++ b/dom/animation/test/css-transitions/file_event-dispatch.html
@@ -33,171 +33,172 @@ TransitionEventHandler.prototype.clear =
   this.transitionrun    = undefined;
   this.transitionstart  = undefined;
   this.transitionend    = undefined;
   this.transitioncancel = undefined;
 };
 
 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',
                                            'transitioncancel' ]);
   flushComputedStyle(div);
 
   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);
   });
 }, '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;
   return watcher.wait_for('transitionrun').then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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;
   transition.pause();
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
     assert_equals(handler.transitionrun, 0.0);
     assert_equals(handler.transitionstart, 0.0);
   });
 }, '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();
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart',
                             'transitionend' ]).then(evt => {
     assert_equals(handler.transitionrun, 0.0);
     assert_equals(handler.transitionstart, 0.0);
     assert_equals(handler.transitionend, 100.0);
   });
 }, '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'),
                        transition.ready ]).then(() => {
     // Make idle
     div.style.display = 'none';
     flushComputedStyle(div);
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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'),
                        transition.ready ]).then(() => {
     // Make idle
     transition.timeline = null;
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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'),
                        transition.ready ]).then(() => {
     transition.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('transitionstart');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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(() => {
     // Seek to After phase.
     transition.currentTime = 200 * MS_PER_SEC;
     return watcher.wait_for([ 'transitionstart', 'transitionend' ]);
   }).then(evt => {
     assert_equals(handler.transitionstart, 0.0);
     assert_equals(handler.transitionend, 100.0);
   });
 }, 'Before -> After');
 
 promise_test(t => {
-  const [transition, watcher, div] =
+  const { transition, watcher, div } =
     setupTransition(t, 'margin-left 100s');
 
   // Seek to Active start position.
   transition.pause();
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
     // Make idle
     div.style.display = 'none';
     flushComputedStyle(div);
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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',
                             'transitionstart' ]).then(evt => {
     // Make idle
     transition.currentTime = 0;
     transition.timeline = null;
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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.
   transition.pause();
 
   // Seek to Active phase.
   transition.currentTime = 100 * MS_PER_SEC;
   return watcher.wait_for([ 'transitionrun',
@@ -207,34 +208,34 @@ promise_test(t => {
     flushComputedStyle(div);
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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.
   transition.currentTime = 100 * MS_PER_SEC;
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
     // Make idle
     transition.currentTime = 100 * MS_PER_SEC;
     transition.timeline = null;
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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
   // time in transition cancel events.
   transition.pause();
 
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
@@ -243,115 +244,112 @@ promise_test(t => {
     flushComputedStyle(div);
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 50.0);
   });
 }, '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',
                             'transitionstart' ]).then(evt => {
     // Make idle
     transition.currentTime = 50 * MS_PER_SEC;
     transition.timeline = null;
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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;
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
     // Seek to Before phase.
     transition.currentTime = 0;
     return watcher.wait_for('transitionend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 0.0);
   });
 }, '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;
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart' ]).then(evt => {
     // Seek to After phase.
     transition.currentTime = 200 * MS_PER_SEC;
     return watcher.wait_for('transitionend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, '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();
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart',
                             'transitionend' ]).then(evt => {
     // Seek to Before phase.
     transition.currentTime = 0;
     return watcher.wait_for([ 'transitionstart', 'transitionend' ]);
   }).then(evt => {
     assert_equals(handler.transitionstart, 100.0);
     assert_equals(handler.transitionend, 0.0);
   });
 }, 'After -> Before');
 
 promise_test(t => {
-  const [transition, watcher] =
+  const { transition, watcher } =
     setupTransition(t, 'margin-left 100s 100s');
   // Seek to After phase.
   transition.finish();
   return watcher.wait_for([ 'transitionrun',
                             'transitionstart',
                             'transitionend' ]).then(evt => {
     // Seek to Active phase.
     transition.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('transitionstart');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, '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(() => {
     assert_equals(handler.transitionrun, 50.0);
     assert_equals(handler.transitionstart, 50.0);
     transition.finish();
     return watcher.wait_for('transitionend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, '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.
     // Because CSS-Transition use the AnimationEffectTimingReadOnly.
     transition.effect = new KeyframeEffect(div,
                                            { marginleft: [ '0px', '100px' ]},
                                            { duration: 100 * MS_PER_SEC,
                                              endDelay: -50 * MS_PER_SEC });
@@ -368,99 +366,99 @@ promise_test(t => {
     transition.finish();
     return watcher.wait_for('transitionend');
   }).then(evt => {
     assert_equals(evt.elapsedTime, 50.0);
   });
 }, '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(() => {
     // Make idle
     div.style.display = 'none';
     flushComputedStyle(div);
     return watcher.wait_for('transitioncancel');
   }).then(() => {
     transition.cancel();
     // Then wait a couple of frames and check that no event was dispatched
     return waitForAnimationFrames(2);
   });
 }, '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 => {
     // Make idle
     div.style.display = 'none';
     flushComputedStyle(div);
     transition.play();
     watcher.wait_for([ 'transitioncancel',
                        'transitionrun',
                        'transitionstart' ]);
   });
 }, '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 => {
     // Make idle
     div.style.display = 'none';
     flushComputedStyle(div);
     transition.play();
     transition.cancel();
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     // Then wait a couple of frames and check that no event was dispatched
     return waitForAnimationFrames(2);
   });
 }, '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',
                             'transitionstart' ]).then(evt => {
     // Make idle
     transition.timeline = null;
     return watcher.wait_for('transitioncancel');
   }).then(evt => {
     transition.timeline = document.timeline;
     transition.play();
 
     return watcher.wait_for(['transitionrun', 'transitionstart']);
   });
 }, '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',
                             'transitionstart' ]).then(() => {
     transition.cancel();
     return watcher.wait_for('transitioncancel');
   }).then(() => {
     // Make After phase
     transition.effect = null;
 
     // Then wait a couple of frames and check that no event was dispatched
     return waitForAnimationFrames(2);
   });
 }, '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',
                             'transitionstart' ]).then(evt => {
     transition.effect = null;
     return watcher.wait_for('transitionend');
   }).then(evt => {
     transition.cancel();