Bug 1533489 - findBreakpoint should be context aware. r=loganfsmyth
authorJason Laster <jlaster@mozilla.com>
Fri, 08 Mar 2019 13:39:06 +0000
changeset 521047 3c6fab986e99
parent 521046 9a08f46db419
child 521048 bff0dee7c2ef
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1533489
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 1533489 - findBreakpoint should be context aware. r=loganfsmyth Differential Revision: https://phabricator.services.mozilla.com/D22558
devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js
devtools/client/debugger/new/src/utils/source-maps.js
--- a/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js
+++ b/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js
@@ -1,23 +1,22 @@
 // @flow
 
 /* 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 { comparePosition } from "../location";
-import type {
-  BreakpointPositions,
-  SourceLocation,
-  Position
-} from "../../types";
+import { getSelectedLocation } from "../source-maps";
+import type { BreakpointPositions, SourceLocation } from "../../types";
 
 export function findPosition(
   positions: ?BreakpointPositions,
-  location: Position | SourceLocation
+  location: SourceLocation
 ) {
   if (!positions) {
     return null;
   }
 
-  return positions.find(pos => comparePosition(pos.location, location));
+  return positions.find(pos =>
+    comparePosition(getSelectedLocation(pos, location), location)
+  );
 }
--- a/devtools/client/debugger/new/src/utils/source-maps.js
+++ b/devtools/client/debugger/new/src/utils/source-maps.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 { isOriginalId } from "devtools-source-map";
 import { getSource } from "../selectors";
-import { isGenerated } from "../utils/source";
 
 import type { SourceLocation, MappedLocation, Source } from "../types";
 import typeof SourceMaps from "../../packages/devtools-source-map/src";
 
 export async function getGeneratedLocation(
   state: Object,
   source: Source,
   location: SourceLocation,
@@ -99,14 +98,20 @@ export async function mapLocation(
 }
 
 export function isOriginalSource(source: ?Source) {
   return source && isOriginalId(source.id);
 }
 
 export function getSelectedLocation(
   mappedLocation: MappedLocation,
-  selectedSource: ?Source
+  context: ?(Source | SourceLocation)
 ): SourceLocation {
-  return selectedSource && isGenerated(selectedSource)
-    ? mappedLocation.generatedLocation
-    : mappedLocation.location;
+  if (!context) {
+    return mappedLocation.location;
+  }
+
+  // $FlowIgnore
+  const sourceId = context.sourceId || context.id;
+  return isOriginalId(sourceId)
+    ? mappedLocation.location
+    : mappedLocation.generatedLocation;
 }