Backed out changeset 589aafc2bb13 (bug 1134500) for a rebase error.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 07 Apr 2015 12:39:25 -0400
changeset 258328 88bda8094530
parent 258327 8f0271f2c153
child 258329 16c909280059
push id4646
push userryanvm@gmail.com
push date2015-04-07 16:40 +0000
treeherdermozilla-beta@16c909280059 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1134500
milestone38.0
backs out589aafc2bb13
Backed out changeset 589aafc2bb13 (bug 1134500) for a rebase error.
browser/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js
browser/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js
browser/devtools/animationinspector/test/browser_animation_toggle_button_updates_playerWidgets.js
browser/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js
browser/devtools/animationinspector/test/head.js
--- a/browser/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js
+++ b/browser/devtools/animationinspector/test/browser_animation_playerWidgets_disables_on_finished.js
@@ -16,17 +16,25 @@ add_task(function*() {
   info("Select the test node");
   yield selectNode(".still", inspector);
 
   is(controller.animationPlayers.length, 2, "2 animation players exist");
 
   info("Wait for both animations to end");
 
   let promises = controller.animationPlayers.map(front => {
-    return waitForPlayState(front, "finished");
+    let def = promise.defer();
+    let onStateChanged = () => {
+      if (front.state.playState === "finished") {
+        front.off(front.AUTO_REFRESH_EVENT, onStateChanged);
+        def.resolve();
+      }
+    };
+    front.on(front.AUTO_REFRESH_EVENT, onStateChanged);
+    return def.promise;
   });
 
   yield promise.all(promises);
 
   for (let widgetEl of panel.playersEl.querySelectorAll(".player-widget")) {
     ok(widgetEl.classList.contains("finished"), "The player widget has the right class");
   }
 });
--- a/browser/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js
+++ b/browser/devtools/animationinspector/test/browser_animation_playerWidgets_dont_show_time_after_duration.js
@@ -19,16 +19,24 @@ add_task(function*() {
 
   info("Select the node");
   yield selectNode(".still", inspector);
 
   info("Wait until the animation ends");
   let widget = panel.playerWidgets[0];
   let front = widget.player;
 
-  yield waitForPlayState(front, "finished");
+  let def = promise.defer();
+  let onStateChanged = () => {
+    if (front.state.playState === "finished") {
+      front.off(front.AUTO_REFRESH_EVENT, onStateChanged);
+      def.resolve();
+    }
+  };
+  front.on(front.AUTO_REFRESH_EVENT, onStateChanged);
+  yield def.promise;
 
   is(widget.currentTimeEl.value, front.state.duration,
     "The timeline slider has the right value");
   is(widget.timeDisplayEl.textContent,
     L10N.numberWithDecimals(front.state.duration / 1000, 2) + "s",
     "The timeline slider has the right value");
 });
--- a/browser/devtools/animationinspector/test/browser_animation_toggle_button_updates_playerWidgets.js
+++ b/browser/devtools/animationinspector/test/browser_animation_toggle_button_updates_playerWidgets.js
@@ -9,30 +9,27 @@
 
 add_task(function*() {
   yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
   let {inspector, panel} = yield openAnimationInspector();
 
   info("Select an animated node");
   yield selectNode(".animated", inspector);
   let widget = panel.playerWidgets[0];
-  let player = widget.player;
 
-  info("Listen to animation state changes and click the toggle button to " +
-    "pause all animations");
-  let onPaused = waitForPlayState(player, "paused");
+  info("Click the toggle button to pause all animations");
+  let onRefresh = widget.player.once(widget.player.AUTO_REFRESH_EVENT);
   yield panel.toggleAll();
-  yield onPaused;
+  yield onRefresh;
 
   info("Checking the selected node's animation player widget's state");
-  is(player.state.playState, "paused", "The player front's state is paused");
+  is(widget.player.state.playState, "paused", "The player front's state is paused");
   ok(widget.el.classList.contains("paused"), "The widget's UI is in paused state");
 
-  info("Listen to animation state changes and click the toggle button to " +
-    "play all animations");
-  let onRunning = waitForPlayState(player, "running");
+  info("Click the toggle button to play all animations");
+  onRefresh = widget.player.once(widget.player.AUTO_REFRESH_EVENT);
   yield panel.toggleAll();
-  yield onRunning;
+  yield onRefresh;
 
   info("Checking the selected node's animation player widget's state again");
-  is(player.state.playState, "running", "The player front's state is running");
+  is(widget.player.state.playState, "running", "The player front's state is running");
   ok(widget.el.classList.contains("running"), "The widget's UI is in running state");
 });
--- a/browser/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js
+++ b/browser/devtools/animationinspector/test/browser_animation_ui_updates_when_animation_changes.js
@@ -11,44 +11,39 @@ add_task(function*() {
   yield addTab(TEST_URL_ROOT + "doc_simple_animation.html");
   let {panel, inspector} = yield openAnimationInspector();
 
   info("Select the test node");
   yield selectNode(".animated", inspector);
 
   info("Get the player widget");
   let widget = panel.playerWidgets[0];
-  let player = widget.player;
-
-  info("Wait for paused playState");
-  let onPaused = waitForPlayState(player, "paused");
 
   info("Pause the animation via the content DOM");
   yield executeInContent("Test:ToggleAnimationPlayer", {
     animationIndex: 0,
     pause: true
   }, {
     node: getNode(".animated")
   });
 
-  yield onPaused;
+  info("Wait for the next state update");
+  yield widget.player.once(widget.player.AUTO_REFRESH_EVENT);
 
-  is(player.state.playState, "paused", "The AnimationPlayerFront is paused");
+  is(widget.player.state.playState, "paused", "The AnimationPlayerFront is paused");
   ok(widget.el.classList.contains("paused"), "The button's state has changed");
   ok(!widget.rafID, "The smooth timeline animation has been stopped");
 
-  info("Wait for running playState");
-  let onRunning = waitForPlayState(player, "running");
-
   info("Play the animation via the content DOM");
   yield executeInContent("Test:ToggleAnimationPlayer", {
     animationIndex: 0,
     pause: false
   }, {
     node: getNode(".animated")
   });
 
-  yield onRunning;
+  info("Wait for the next state update");
+  yield widget.player.once(widget.player.AUTO_REFRESH_EVENT);
 
-  is(player.state.playState, "running", "The AnimationPlayerFront is running");
+  is(widget.player.state.playState, "running", "The AnimationPlayerFront is running");
   ok(widget.el.classList.contains("running"), "The button's state has changed");
   ok(widget.rafID, "The smooth timeline animation has been started");
 });
--- a/browser/devtools/animationinspector/test/head.js
+++ b/browser/devtools/animationinspector/test/head.js
@@ -287,18 +287,20 @@ let togglePlayPauseButton = Task.async(f
 
   // Verify that the button's state is changed immediately, even if it will be
   // changed anyway with the next auto-refresh.
   ok(widget.el.classList.contains(nextState),
     "The button's state was changed in the UI before the request was sent");
 
   yield onClicked;
 
-  // Wait until the state changes.
-  yield waitForPlayState(widget.player, nextState);
+  // Wait for the next sate change event to make sure the state is updated
+  yield waitForStateCondition(widget.player, state => {
+    return state.playState === nextState;
+  }, "after clicking the toggle button");
 });
 
 /**
  * Wait for a player's auto-refresh events and stop when a condition becomes
  * truthy.
  * @param {AnimationPlayerFront} player
  * @param {Function} conditionCheck Will be called over and over again when the
  * player state changes, passing the state as argument. This method must return
@@ -319,47 +321,16 @@ let waitForStateCondition = Task.async(f
       player.off(player.AUTO_REFRESH_EVENT, onNewState);
       def.resolve();
     }
   });
   return def.promise;
 });
 
 /**
- * Wait for a player's auto-refresh events and stop when the playState is the
- * provided string.
- * @param {AnimationPlayerFront} player
- * @param {String} playState The playState to expect.
- * @return {Promise} Resolves when the playState has changed to the expected value.
- */
-function waitForPlayState(player, playState) {
-  return waitForStateCondition(player, state => {
-    return state.playState === playState;
-  }, "Waiting for animation to be " + playState);
-}
-
-/**
- * Wait for the player's auto-refresh events until the animation is paused.
- * When done, check its currentTime.
- * @param {PlayerWidget} widget.
- * @param {Numer} time.
- * @return {Promise} Resolves when the animation is paused and tests have ran.
- */
-let checkPausedAt = Task.async(function*(widget, time) {
-  info("Wait for the next auto-refresh");
-
-  yield waitForPlayState(widget.player, "paused");
-
-  ok(widget.el.classList.contains("paused"), "The widget is in paused mode");
-  is(widget.player.state.currentTime, time,
-    "The player front's currentTime was set to " + time);
-  is(widget.currentTimeEl.value, time, "The input's value was set to " + time);
-});
-
-+/**
  * Get the current playState of an animation player on a given node.
  */
 let getAnimationPlayerState = Task.async(function*(selector, animationIndex=0) {
   let playState = yield executeInContent("Test:GetAnimationPlayerState",
                                          {animationIndex},
                                          {node: getNode(selector)});
   return playState;
 });