Bug 1543753 - Don't view sources that can't be loaded in the debugger, r=loganfsmyth.
☠☠ backed out by 22a3a17e5a41 ☠ ☠
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 01 May 2019 14:01:09 -1000
changeset 473694 60085ea6ff728115e1f61568702fd2348c15814d
parent 473693 274fb69f7d77a018cf66f0179e41fca38f9baaad
child 473695 3c5ff599ce3c6f922b8bb31f2344c199b82889e2
push id36010
push userapavel@mozilla.com
push dateTue, 14 May 2019 04:11:16 +0000
treeherdermozilla-central@e0a622476b77 [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. Differential Revision: https://phabricator.services.mozilla.com/D29593
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,32 @@ export function getSourceActorsForSource
   const actors = state.sources.actors[id];
   if (!actors) {
     return [];
   }
 
   return getSourceActors(state, actors);
 }
 
+export function canLoadSource(state: OuterState, 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;