Bug 1099370 - Destroy remaining toolboxes and tabs after debugger test has finished. r=ejpbruel, a=test-only
authorSami Jaktholm <sjakthol@outlook.com>
Sun, 11 Jan 2015 14:17:56 +0200
changeset 249478 2f54a6683cf5e240e889db3188be562132cb90a8
parent 249477 ba6239fc70f5b316ee8e50a40e369d9676a34dcc
child 249479 bc8330374bd74733b2fa6d46a42863a82d82df76
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel, test-only
bugs1099370
milestone37.0a2
Bug 1099370 - Destroy remaining toolboxes and tabs after debugger test has finished. r=ejpbruel, a=test-only
browser/devtools/debugger/test/browser_dbg_break-on-dom-event-01.js
browser/devtools/debugger/test/browser_dbg_break-on-dom-event-02.js
browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
browser/devtools/debugger/test/browser_dbg_debugger-statement.js
browser/devtools/debugger/test/browser_dbg_event-listeners-01.js
browser/devtools/debugger/test/browser_dbg_event-listeners-02.js
browser/devtools/debugger/test/browser_dbg_event-listeners-03.js
browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
browser/devtools/debugger/test/head.js
--- a/browser/devtools/debugger/test/browser_dbg_break-on-dom-event-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-event-01.js
@@ -217,14 +217,13 @@ function triggerButtonClick() {
 
 function triggerInputChange() {
   gInput.focus();
   gInput.value = "foo";
   gInput.blur();
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
   gThreadClient = null;
   gInput = null;
   gButton = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_break-on-dom-event-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-event-02.js
@@ -99,12 +99,11 @@ function triggerButtonClick(aNodeId) {
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
   gThreadClient = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
+++ b/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
@@ -84,17 +84,16 @@ function onNewSource(aEvent, aPacket) {
 
 function resumeAndCloseConnection() {
   let deferred = promise.defer();
   gThreadClient.resume(() => gClient.close(deferred.resolve));
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
   gThreadClient = null;
   gAttached = null;
   gNewGlobal = null;
   gNewChromeSource = null;
 
   loader = null;
   DebuggerServer = null;
--- a/browser/devtools/debugger/test/browser_dbg_debugger-statement.js
+++ b/browser/devtools/debugger/test/browser_dbg_debugger-statement.js
@@ -80,12 +80,10 @@ function testDebuggerStatement([aGrip, a
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
 });
-
--- a/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-01.js
@@ -142,11 +142,10 @@ function testEventListeners(aThreadClien
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-02.js
@@ -118,11 +118,10 @@ function testEventListeners(aThreadClien
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js
+++ b/browser/devtools/debugger/test/browser_dbg_event-listeners-03.js
@@ -77,11 +77,10 @@ function testEventListeners(aThreadClien
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gBrowser.selectedTab);
   gClient = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
+++ b/browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
@@ -3,17 +3,17 @@
 
 /**
  * Tests that the toolbox is raised when the debugger gets paused.
  */
 
 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
 
 let gTab, gPanel, gDebugger;
-let gNewTab, gFocusedWindow, gToolbox, gToolboxTab;
+let gFocusedWindow, gToolbox, gToolboxTab;
 
 function test() {
   initDebugger(TAB_URL).then(([aTab,, aPanel]) => {
     gTab = aTab;
     gPanel = aPanel;
     gDebugger = gPanel.panelWin;
     gToolbox = gPanel._toolbox;
     gToolboxTab = gToolbox.doc.getElementById("toolbox-tab-jsdebugger");
@@ -24,17 +24,16 @@ function test() {
 
 function performTest() {
   addTab(TAB_URL).then(aTab => {
     isnot(aTab, gTab,
       "The newly added tab is different from the debugger's tab.");
     is(gBrowser.selectedTab, aTab,
       "Debugger's tab is not the selected tab.");
 
-    gNewTab = aTab;
     gFocusedWindow = window;
     testPause();
   });
 }
 
 function focusMainWindow() {
   // Make sure toolbox is not focused.
   window.addEventListener("focus", onFocus, true);
@@ -129,14 +128,12 @@ registerCleanupFunction(function() {
   // Revert to the default toolbox host, so that the following tests proceed
   // normally and not inside a non-default host.
   Services.prefs.setCharPref("devtools.toolbox.host", devtools.Toolbox.HostType.BOTTOM);
 
   gTab = null;
   gPanel = null;
   gDebugger = null;
 
-  removeTab(gNewTab);
-  gNewTab = null;
   gFocusedWindow = null;
   gToolbox = null;
   gToolboxTab = null;
 });
--- a/browser/devtools/debugger/test/head.js
+++ b/browser/devtools/debugger/test/head.js
@@ -33,20 +33,29 @@ const FRAME_SCRIPT_URL = getRootDirector
 gDevTools.testing = true;
 SimpleTest.registerCleanupFunction(() => {
   gDevTools.testing = false;
 });
 
 // All tests are asynchronous.
 waitForExplicitFinish();
 
-registerCleanupFunction(function() {
+registerCleanupFunction(function* () {
   info("finish() was called, cleaning up...");
   Services.prefs.setBoolPref("devtools.debugger.log", gEnableLogging);
 
+  while (gBrowser && gBrowser.tabs && gBrowser.tabs.length > 1) {
+    info("Destroying toolbox.");
+    let target = TargetFactory.forTab(gBrowser.selectedTab);
+    yield gDevTools.closeToolbox(target);
+
+    info("Removing tab.");
+    gBrowser.removeCurrentTab();
+  }
+
   // Properly shut down the server to avoid memory leaks.
   DebuggerServer.destroy();
 
   // Debugger tests use a lot of memory, so force a GC to help fragmentation.
   info("Forcing GC after debugger test.");
   Cu.forceGC();
 });