Bug 1543753 - Don't view sources that can't be loaded in the debugger, r=loganfsmyth.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 15 May 2019 07:52:42 -1000
changeset 474121 846d0d928675e4017254197e5eba61a6af552378
parent 474120 f8516287a42503baa4cce8bee1a6025fa92f6095
child 474122 0e8d68920793aca5c383e4977aa3899a2bc5876b
push id36023
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:56:43 +0000
treeherdermozilla-central@786f094a30ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1543753
milestone68.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 1543753 - Don't view sources that can't be loaded in the debugger, r=loganfsmyth.
devtools/client/debugger/panel.js
devtools/client/debugger/src/reducers/sources.js
devtools/client/shared/view-source.js
--- a/devtools/client/debugger/panel.js
+++ b/devtools/client/debugger/panel.js
@@ -157,16 +157,20 @@ DebuggerPanel.prototype = {
     return this._actions.selectSourceURL(cx, url, { line, column });
   },
 
   selectSource(sourceId, line, column) {
     const cx = this._selectors.getContext(this._getState());
     return this._actions.selectSource(cx, sourceId, { line, column });
   },
 
+  canLoadSource(sourceId) {
+    return this._selectors.canLoadSource(this._getState(), sourceId);
+  },
+
   getSourceByActorId(sourceId) {
     return this._selectors.getSourceByActorId(this._getState(), sourceId);
   },
 
   getSourceByURL(sourceURL) {
     return this._selectors.getSourceByURL(this._getState(), sourceURL);
   },
 
--- a/devtools/client/debugger/src/reducers/sources.js
+++ b/devtools/client/debugger/src/reducers/sources.js
@@ -883,16 +883,35 @@ export function getSourceActorsForSource
   const actors = state.sources.actors[id];
   if (!actors) {
     return [];
   }
 
   return getSourceActors(state, actors);
 }
 
+export function canLoadSource(
+  state: OuterState & SourceActorOuterState,
+  sourceId: string)
+{
+  // Return false if we know that loadSourceText() will fail if called on this
+  // source. This is used to avoid viewing such sources in the debugger.
+  const source = getSource(state, sourceId);
+  if (!source) {
+    return false;
+  }
+
+  if (isOriginalSource(source)) {
+    return true;
+  }
+
+  const actors = getSourceActorsForSource(state, sourceId);
+  return actors.length != 0;
+}
+
 export function getBreakpointPositions(
   state: OuterState
 ): BreakpointPositionsMap {
   return state.sources.breakpointPositions;
 }
 
 export function getBreakpointPositionsForSource(
   state: OuterState,
--- a/devtools/client/shared/view-source.js
+++ b/devtools/client/shared/view-source.js
@@ -58,17 +58,17 @@ exports.viewSourceInDebugger = async fun
   sourceLine,
   sourceColumn,
   sourceId,
   reason = "unknown"
 ) {
   const dbg = await toolbox.loadTool("jsdebugger");
   const source =
     sourceId ? dbg.getSourceByActorId(sourceId) : dbg.getSourceByURL(sourceURL);
-  if (source) {
+  if (source && dbg.canLoadSource(source.id)) {
     await toolbox.selectTool("jsdebugger", reason);
     try {
       await dbg.selectSource(source.id, sourceLine, sourceColumn);
     } catch (err) {
       console.error("Failed to view source in debugger", err);
       return false;
     }
     return true;