Bug 951828 - Always select the variables tab when pausing, r=fitzgen
authorVictor Porof <vporof@mozilla.com>
Thu, 19 Dec 2013 13:41:46 +0200
changeset 161345 07b3207166bab80d23d8ee9e086b09a8b51690eb
parent 161344 e252f97728cc079122b58fe64e2068c87ef50830
child 161346 31a801812dcea371376da5234de891353f235c19
push id25878
push userkwierso@gmail.com
push dateFri, 20 Dec 2013 03:09:21 +0000
treeherdermozilla-central@599100c4ebfe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs951828
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 951828 - Always select the variables tab when pausing, r=fitzgen
browser/devtools/debugger/debugger-view.js
browser/devtools/debugger/test/browser.ini
browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js
browser/devtools/debugger/test/doc_event-listeners-02.html
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -532,17 +532,17 @@ let DebuggerView = {
    *        A function to invoke when the toggle finishes.
    */
   showInstrumentsPane: function(aCallback) {
     DebuggerView.toggleInstrumentsPane({
       visible: true,
       animated: true,
       delayed: true,
       callback: aCallback
-    });
+    }, 0);
   },
 
   /**
    * Handles a tab selection event on the instruments pane.
    */
   _onInstrumentsPaneTabSelect: function() {
     if (this._instrumentsPane.selectedTab.id == "events-tab") {
       DebuggerController.Breakpoints.DOM.scheduleEventListenersFetch();
--- a/browser/devtools/debugger/test/browser.ini
+++ b/browser/devtools/debugger/test/browser.ini
@@ -75,16 +75,17 @@ support-files =
 [browser_dbg_breadcrumbs-access.js]
 [browser_dbg_break-on-dom-01.js]
 [browser_dbg_break-on-dom-02.js]
 [browser_dbg_break-on-dom-03.js]
 [browser_dbg_break-on-dom-04.js]
 [browser_dbg_break-on-dom-05.js]
 [browser_dbg_break-on-dom-06.js]
 [browser_dbg_break-on-dom-07.js]
+[browser_dbg_break-on-dom-08.js]
 [browser_dbg_breakpoints-actual-location.js]
 [browser_dbg_breakpoints-button-01.js]
 [browser_dbg_breakpoints-button-02.js]
 [browser_dbg_breakpoints-contextmenu.js]
 [browser_dbg_breakpoints-disabled-reload.js]
 [browser_dbg_breakpoints-editor.js]
 [browser_dbg_breakpoints-highlight.js]
 [browser_dbg_breakpoints-new-script.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-08.js
@@ -0,0 +1,57 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that breaking on an event selects the variables view tab.
+ */
+
+const TAB_URL = EXAMPLE_URL + "doc_event-listeners-02.html";
+
+function test() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    let gDebugger = aPanel.panelWin;
+    let gView = gDebugger.DebuggerView;
+    let gEvents = gView.EventListeners;
+
+    Task.spawn(function() {
+      yield waitForSourceShown(aPanel, ".html");
+      aDebuggee.addBodyClickEventListener();
+
+      let fetched = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_LISTENERS_FETCHED);
+      gView.toggleInstrumentsPane({ visible: true, animated: false }, 1);
+      yield fetched;
+      yield ensureThreadClientState(aPanel, "resumed");
+
+      is(gView.instrumentsPaneHidden, false,
+        "The instruments pane should be visible.");
+      is(gView.instrumentsPaneTab, "events-tab",
+        "The events tab should be selected.");
+
+      let updated = waitForDebuggerEvents(aPanel, gDebugger.EVENTS.EVENT_BREAKPOINTS_UPDATED);
+      EventUtils.sendMouseEvent({ type: "click" }, getItemCheckboxNode(1), gDebugger);
+      yield updated;
+      yield ensureThreadClientState(aPanel, "resumed");
+
+      let paused = waitForCaretAndScopes(aPanel, 48);
+      // Spin the event loop before causing the debuggee to pause, to allow
+      // this function to yield first.
+      executeSoon(() => {
+        EventUtils.sendMouseEvent({ type: "click" }, aDebuggee.document.body, aDebuggee);
+      });
+      yield paused;
+      yield ensureThreadClientState(aPanel, "paused");
+
+      is(gView.instrumentsPaneHidden, false,
+        "The instruments pane should be visible.");
+      is(gView.instrumentsPaneTab, "variables-tab",
+        "The variables tab should be selected.");
+
+      yield resumeDebuggerThenCloseAndFinish(aPanel);
+    });
+
+    function getItemCheckboxNode(index) {
+      return gEvents.items[index].target.parentNode
+        .querySelector(".side-menu-widget-item-checkbox");
+    }
+  });
+}
--- a/browser/devtools/debugger/test/doc_event-listeners-02.html
+++ b/browser/devtools/debugger/test/doc_event-listeners-02.html
@@ -38,12 +38,16 @@
         var input = document.querySelector("input");
         input.addEventListener("keyup", keyupHandler, true);
 
         window.addEventListener("keydown", keydownHandler, true);
         document.body.addEventListener("keydown", keydownHandler, true);
 
         window.changeHandler = changeHandler;
       });
+
+      function addBodyClickEventListener() {
+        document.body.addEventListener("click", function() { debugger; });
+      }
     </script>
   </body>
 
 </html>