Bug 1535607 - Breakpoint does not appear in the gutter until scrolling. r=bhackett
authorJason Laster <jlaster@mozilla.com>
Fri, 15 Mar 2019 19:35:54 +0000
changeset 464440 7a382dbe8dc831fa75b4f2ad011f35378068386f
parent 464439 11017d53d6bdf6e55c1ad181b930aee6589819da
child 464441 16f9f23229b21b64a85c92c0e01df2cc350bb193
push id35716
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:42:17 +0000
treeherdermozilla-central@8ee97c045359 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1535607
milestone67.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 1535607 - Breakpoint does not appear in the gutter until scrolling. r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D23699
devtools/client/debugger/new/src/reducers/pause.js
devtools/client/debugger/new/src/selectors/index.js
devtools/client/debugger/new/src/selectors/isSelectedFrameVisible.js
devtools/client/debugger/new/src/selectors/moz.build
devtools/client/debugger/new/src/selectors/pause.js
devtools/client/debugger/new/src/selectors/visibleSelectedFrame.js
devtools/client/debugger/new/test/mochitest/browser_dbg-expressions-focus.js
--- a/devtools/client/debugger/new/src/reducers/pause.js
+++ b/devtools/client/debugger/new/src/reducers/pause.js
@@ -8,16 +8,17 @@
 /**
  * Pause reducer
  * @module reducers/pause
  */
 
 import { isGeneratedId } from "devtools-source-map";
 import { prefs } from "../utils/prefs";
 import { getSelectedSourceId } from "./sources";
+import { getSelectedFrame } from "../selectors/pause";
 
 import type { OriginalScope } from "../utils/pause/mapScopes";
 import type { Action } from "../actions/types";
 import type { State } from "./types";
 import type {
   Why,
   Scope,
   SourceId,
@@ -559,27 +560,16 @@ export function getSelectedFrameId(state
   return getThreadPauseState(state.pause, thread).selectedFrameId;
 }
 
 export function getTopFrame(state: OuterState, thread: ThreadId) {
   const frames = getFrames(state, thread);
   return frames && frames[0];
 }
 
-export function getSelectedFrame(state: OuterState, thread: ThreadId) {
-  const selectedFrameId = getSelectedFrameId(state, thread);
-  const frames = getFrames(state, thread);
-
-  if (!frames) {
-    return null;
-  }
-
-  return frames.find(frame => frame.id == selectedFrameId);
-}
-
 export function getSkipPausing(state: OuterState) {
   return state.pause.skipPausing;
 }
 
 export function getMapScopes(state: OuterState) {
   return state.pause.mapScopes;
 }
 
--- a/devtools/client/debugger/new/src/selectors/index.js
+++ b/devtools/client/debugger/new/src/selectors/index.js
@@ -30,20 +30,24 @@ export {
 } from "./breakpointAtLocation";
 export {
   getVisibleBreakpoints,
   getFirstVisibleBreakpoints
 } from "./visibleBreakpoints";
 export { inComponent } from "./inComponent";
 export { isSelectedFrameVisible } from "./isSelectedFrameVisible";
 export { getCallStackFrames } from "./getCallStackFrames";
-export { getVisibleSelectedFrame } from "./visibleSelectedFrame";
 export { getBreakpointSources } from "./breakpointSources";
 export { getXHRBreakpoints, shouldPauseOnAnyXHR } from "./breakpoints";
 export * from "./visibleColumnBreakpoints";
+export {
+  getSelectedFrame,
+  getSelectedFrames,
+  getVisibleSelectedFrame
+} from "./pause";
 
 import { objectInspector } from "devtools-reps";
 
 const { reducer } = objectInspector;
 
 Object.keys(reducer).forEach(function(key) {
   if (key === "default" || key === "__esModule") {
     return;
--- a/devtools/client/debugger/new/src/selectors/isSelectedFrameVisible.js
+++ b/devtools/client/debugger/new/src/selectors/isSelectedFrameVisible.js
@@ -1,17 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 // @flow
 
 import { originalToGeneratedId, isOriginalId } from "devtools-source-map";
-import { getSelectedFrame, getCurrentThread } from "../reducers/pause";
-import { getSelectedLocation } from "../reducers/sources";
+import { getSelectedFrame, getSelectedLocation, getCurrentThread } from ".";
 import type { State } from "../reducers/types";
 
 function getGeneratedId(sourceId) {
   if (isOriginalId(sourceId)) {
     return originalToGeneratedId(sourceId);
   }
 
   return sourceId;
--- a/devtools/client/debugger/new/src/selectors/moz.build
+++ b/devtools/client/debugger/new/src/selectors/moz.build
@@ -10,12 +10,12 @@ DIRS += [
 CompiledModules(
     'breakpointAtLocation.js',
     'breakpoints.js',
     'breakpointSources.js',
     'getCallStackFrames.js',
     'inComponent.js',
     'index.js',
     'isSelectedFrameVisible.js',
+    'pause.js',
     'visibleBreakpoints.js',
     'visibleColumnBreakpoints.js',
-    'visibleSelectedFrame.js',
 )
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/src/selectors/pause.js
@@ -0,0 +1,57 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+import { getCurrentThread } from "../reducers/pause";
+import { getSelectedLocation } from "../reducers/sources";
+
+// eslint-disable-next-line
+import { getSelectedLocation as _getSelectedLocation } from "../utils/source-maps";
+import { createSelector } from "reselect";
+
+import type { Frame, SourceLocation } from "../types";
+import type { Selector, State } from "../reducers/types";
+
+export const getSelectedFrames: Selector<{ [string]: Frame }> = createSelector(
+  state => state.pause,
+  pauseState => {
+    const selectedFrames = {};
+    for (const thread in pauseState.threads) {
+      const pausedThread = pauseState.threads[thread];
+      const { selectedFrameId, frames } = pausedThread;
+      if (frames) {
+        selectedFrames[thread] = frames.find(
+          frame => frame.id == selectedFrameId
+        );
+      }
+    }
+    return selectedFrames;
+  }
+);
+
+export function getSelectedFrame(state: State, thread: ThreadId) {
+  const selectedFrames = getSelectedFrames(state);
+  return selectedFrames[thread];
+}
+
+export const getVisibleSelectedFrame: Selector<?{
+  id: string,
+  location: SourceLocation
+}> = createSelector(
+  getSelectedLocation,
+  getSelectedFrames,
+  getCurrentThread,
+  (selectedLocation, selectedFrames, thread) => {
+    const selectedFrame = selectedFrames[thread];
+    if (!selectedFrame) {
+      return null;
+    }
+
+    const { id } = selectedFrame;
+
+    return {
+      id,
+      location: _getSelectedLocation(selectedFrame, selectedLocation)
+    };
+  }
+);
deleted file mode 100644
--- a/devtools/client/debugger/new/src/selectors/visibleSelectedFrame.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
-
-// @flow
-
-import { getSelectedLocation, getSelectedFrame, getCurrentThread } from ".";
-import { isOriginalId } from "devtools-source-map";
-
-import type { Frame, SourceLocation } from "../types";
-import type { State } from "../reducers/types";
-
-function getLocation(frame: Frame, location: ?SourceLocation) {
-  if (!location) {
-    return frame.location;
-  }
-
-  return !isOriginalId(location.sourceId)
-    ? frame.generatedLocation || frame.location
-    : frame.location;
-}
-
-export function getVisibleSelectedFrame(state: State) {
-  const thread = getCurrentThread(state);
-  const selectedLocation = getSelectedLocation(state);
-  const selectedFrame = getSelectedFrame(state, thread);
-
-  if (!selectedFrame) {
-    return null;
-  }
-
-  const { id } = selectedFrame;
-
-  return {
-    id,
-    location: getLocation(selectedFrame, selectedLocation)
-  };
-}
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-expressions-focus.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-expressions-focus.js
@@ -1,19 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 // Ensures the input is displayed and focused when "+" is clicked
 add_task(async function() {
   const dbg = await initDebugger("doc-script-switching.html");
-  // Close the panel
+
+  info(">> Close the panel");
   clickElementWithSelector(dbg, ".watch-expressions-pane ._header");
-  // Click + to add the new expression
+
+  info(">> Click + to add the new expression");
   clickElementWithSelector(dbg, ".watch-expressions-pane ._header .plus");
-  // Ensure element gets focused
+
+  info(">> Ensure element gets focused");
   await waitForElementWithSelector(dbg, ".expression-input-container.focused");
-  // Ensure the element is focused
+
+  info(">> Ensure the element is focused");
   is(
     dbg.win.document.activeElement.classList.contains("input-expression"),
     true
   );
 });