Bug 1442602 - Fix Frame component for browser-loader requested resources; r=miker.
There wasn't anything done for this kind of resources, so the URL looked
like resource://devtools/shared/base-loader.js -> resource://devtools/path/to/file.js
and was causing issue in the onClick handler.
MozReview-Commit-ID: GUJOpjDX1zG
--- a/devtools/client/shared/components/Frame.js
+++ b/devtools/client/shared/components/Frame.js
@@ -118,33 +118,37 @@ class Frame extends Component {
if (this.state && this.state.isSourceMapped && this.state.frame) {
frame = this.state.frame;
isSourceMapped = this.state.isSourceMapped;
} else {
frame = this.props.frame;
}
- let source = frame.source ? String(frame.source) : "";
+ // If the resource was loaded by browser-loader.js, `frame.source` looks like:
+ // resource://devtools/shared/base-loader.js -> resource://devtools/path/to/file.js .
+ // What's needed is only the last part after " -> ".
+ let source = frame.source
+ ? String(frame.source).split(" -> ").pop()
+ : "";
let line = frame.line != void 0 ? Number(frame.line) : null;
let column = frame.column != void 0 ? Number(frame.column) : null;
const { short, long, host } = getSourceNames(source);
// Reparse the URL to determine if we should link this; `getSourceNames`
// has already cached this indirectly. We don't want to attempt to
// link to "self-hosted" and "(unknown)". However, we do want to link
// to Scratchpad URIs.
// Source mapped sources might not necessary linkable, but they
// are still valid in the debugger.
const isLinkable = !!(isScratchpadScheme(source) || parseURL(source))
|| isSourceMapped;
const elements = [];
const sourceElements = [];
let sourceEl;
-
let tooltip = long;
// Exclude all falsy values, including `0`, as line numbers start with 1.
if (line) {
tooltip += `:${line}`;
// Intentionally exclude 0
if (column) {
tooltip += `:${column}`;
@@ -215,17 +219,17 @@ class Frame extends Component {
// If source is not a URL (self-hosted, eval, etc.), don't make
// it an anchor link, as we can't link to it.
if (isLinkable) {
sourceEl = dom.a({
onClick: e => {
e.preventDefault();
e.stopPropagation();
- onClick(this.getSourceForClick(frame));
+ onClick(this.getSourceForClick({...frame, source}));
},
href: source,
className: "frame-link-source",
draggable: false,
}, sourceInnerEl);
} else {
sourceEl = dom.span({
key: "source",