Bug 1206345 - Force a state update in browser_animation_reconstructState.js; r=jdescottes draft
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 12 Apr 2016 15:24:38 +0200
changeset 349876 14d896fe895876346f1d52c3e8f72880d5bdfec6
parent 349818 adbe62e4a9748eb9570e9bf72eaf7bd19af4da2b
child 518214 b0a0baced3ecb12a5c2aac8be9d6c7482355ae47
push id15208
push userpbrosset@mozilla.com
push dateTue, 12 Apr 2016 14:52:07 +0000
reviewersjdescottes
bugs1206345
milestone48.0a1
Bug 1206345 - Force a state update in browser_animation_reconstructState.js; r=jdescottes This test wasn't using refreshState, instead it used getCurrentState. What refreshState does on top of getCurrentState is it stores the new state locally. getCurrentState isn't meant to be called externally, it is only meant to be an actor method interceptor that reconstructs the missing state. So the test should have used refreshState from the start. Turns out it worked in most cases because the animation did have a startTime when the test retrieved it, so it had a previousStartTime. But, if for some reason, the animation has a startTime=null when the test starts, then the value never gets to the front, and bad things happen. MozReview-Commit-ID: 2nEIKHMHsCS
devtools/server/tests/browser/browser_animation_reconstructState.js
--- a/devtools/server/tests/browser/browser_animation_reconstructState.js
+++ b/devtools/server/tests/browser/browser_animation_reconstructState.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Check that, even though the AnimationPlayerActor only sends the bits of its
 // state that change, the front reconstructs the whole state everytime.
 
-add_task(function*() {
+add_task(function* () {
   let {client, walker, animations} =
     yield initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
 
   yield playerHasCompleteStateAtAllTimes(walker, animations);
 
   yield closeDebuggerClient(client);
   gBrowser.removeCurrentTab();
 });
@@ -24,15 +24,15 @@ function* playerHasCompleteStateAtAllTim
 
   // Get the list of state key names from the initialstate.
   let keys = Object.keys(player.initialState);
 
   // Get the state over and over again and check that the object returned
   // contains all keys.
   // Normally, only the currentTime will have changed in between 2 calls.
   for (let i = 0; i < 10; i++) {
-    let state = yield player.getCurrentState();
+    yield player.refreshState();
     keys.forEach(key => {
-      ok(typeof state[key] !== "undefined",
+      ok(typeof player.state[key] !== "undefined",
          "The state retrieved has key " + key);
     });
   }
 }