Bug 1262014 - Cleanup and refactor browser_dbg_stack-03.js to fix intermittent timeouts. r=ejpbruel, a=test-only
authorJason Laster <jlaster@mozilla.com>
Mon, 25 Apr 2016 07:04:00 -0400
changeset 332617 b57ff9533be3351cf1540754b373a4de3b820baa
parent 332616 480fb9568d5dd175362be22361c114b362d8cb51
child 332618 e4f374edfb91f304b2b44b0f09694b32a1b5d6cd
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel, test-only
bugs1262014
milestone48.0a2
Bug 1262014 - Cleanup and refactor browser_dbg_stack-03.js to fix intermittent timeouts. r=ejpbruel, a=test-only
devtools/client/debugger/test/mochitest/browser_dbg_stack-03.js
--- a/devtools/client/debugger/test/mochitest/browser_dbg_stack-03.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_stack-03.js
@@ -3,73 +3,58 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Test that stackframes are scrollable.
  */
 
 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
-
-var gTab, gDebuggee, gPanel, gDebugger;
-var gFrames, gClassicFrames, gFramesScrollingInterval;
+let framesScrollingInterval;
 
 function test() {
   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
-    gTab = aTab;
-    gDebuggee = aDebuggee;
-    gPanel = aPanel;
-    gDebugger = gPanel.panelWin;
-    gFrames = gDebugger.DebuggerView.StackFrames;
-    gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList;
+    const tab = aTab;
+    const debuggee = aDebuggee;
+    const panel = aPanel;
+    const gDebugger = panel.panelWin;
+    const frames = gDebugger.DebuggerView.StackFrames;
+    const classicFrames = gDebugger.DebuggerView.StackFramesClassicList;
+
+    Task.spawn(function*() {
+      framesScrollingInterval = window.setInterval(() => {
+        frames.widget._list.scrollByIndex(-1);
+      }, 100);
+
+      yield waitForDebuggerEvents(panel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED);
+
+      is(gDebugger.gThreadClient.state, "paused",
+        "Should only be getting stack frames while paused.");
+      is(frames.itemCount, gDebugger.gCallStackPageSize,
+        "Should have only the max limit of frames.");
+      is(classicFrames.itemCount, gDebugger.gCallStackPageSize,
+        "Should have only the max limit of frames in the mirrored view as well.");
+
+      yield waitForDebuggerEvents(panel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED);
+
+      is(frames.itemCount, gDebugger.gCallStackPageSize * 2,
+        "Should now have twice the max limit of frames.");
+      is(classicFrames.itemCount, gDebugger.gCallStackPageSize * 2,
+        "Should now have twice the max limit of frames in the mirrored view as well.");
+
+      yield waitForDebuggerEvents(panel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED);
+
+      is(frames.itemCount, debuggee.gRecurseLimit,
+        "Should have reached the recurse limit.");
+      is(classicFrames.itemCount, debuggee.gRecurseLimit,
+        "Should have reached the recurse limit in the mirrored view as well.");
 
 
-    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED)
-      .then(performTest);
+      // Call stack frame scrolling should stop before
+      // we resume the gDebugger as it could be a source of race conditions.
+      window.clearInterval(framesScrollingInterval);
+      resumeDebuggerThenCloseAndFinish(panel);
+    });
 
-    gDebuggee.gRecurseLimit = (gDebugger.gCallStackPageSize * 2) + 1;
-    gDebuggee.recurse();
+    debuggee.gRecurseLimit = (gDebugger.gCallStackPageSize * 2) + 1;
+    debuggee.recurse();
   });
 }
-
-function performTest() {
-  is(gDebugger.gThreadClient.state, "paused",
-    "Should only be getting stack frames while paused.");
-  is(gFrames.itemCount, gDebugger.gCallStackPageSize,
-    "Should have only the max limit of frames.");
-  is(gClassicFrames.itemCount, gDebugger.gCallStackPageSize,
-    "Should have only the max limit of frames in the mirrored view as well.");
-
-  waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED).then(() => {
-    is(gFrames.itemCount, gDebugger.gCallStackPageSize * 2,
-      "Should now have twice the max limit of frames.");
-    is(gClassicFrames.itemCount, gDebugger.gCallStackPageSize * 2,
-      "Should now have twice the max limit of frames in the mirrored view as well.");
-
-    waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED).then(() => {
-      is(gFrames.itemCount, gDebuggee.gRecurseLimit,
-        "Should have reached the recurse limit.");
-      is(gClassicFrames.itemCount, gDebuggee.gRecurseLimit,
-        "Should have reached the recurse limit in the mirrored view as well.");
-
-      gDebugger.gThreadClient.resume(() => {
-        window.clearInterval(gFramesScrollingInterval);
-        closeDebuggerAndFinish(gPanel);
-      });
-    });
-  });
-
-  gFramesScrollingInterval = window.setInterval(() => {
-    gFrames.widget._list.scrollByIndex(-1);
-  }, 100);
-}
-
-registerCleanupFunction(function() {
-  window.clearInterval(gFramesScrollingInterval);
-  gFramesScrollingInterval = null;
-
-  gTab = null;
-  gDebuggee = null;
-  gPanel = null;
-  gDebugger = null;
-  gFrames = null;
-  gClassicFrames = null;
-});