Bug 1255908 - Replaced "/" with hostname when for root document in webconsole; r=jsnajdr

This commit is contained in:
Jaideep Bhoosreddy 2016-06-22 20:30:00 +02:00
Родитель 9fc49ca3c9
Коммит fbd4e8ea76
3 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -20,6 +20,7 @@ module.exports = createClass({
source: PropTypes.string.isRequired,
line: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
column: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
showEmptyPathAsHost: PropTypes.bool,
}).isRequired,
// Clicking on the frame link -- probably should link to the debugger.
onClick: PropTypes.func.isRequired,
@ -33,11 +34,13 @@ module.exports = createClass({
return {
showFunctionName: false,
showHost: false,
showEmptyPathAsHost: false,
};
},
render() {
let { onClick, frame, showFunctionName, showHost } = this.props;
let { showEmptyPathAsHost } = frame;
let source = frame.source ? String(frame.source) : "";
let line = frame.line != void 0 ? Number(frame.line) : null;
let column = frame.column != void 0 ? Number(frame.column) : null;
@ -77,9 +80,13 @@ module.exports = createClass({
);
}
let displaySource = short;
if (showEmptyPathAsHost && (short === "" || short === "/")) {
displaySource = host;
}
sourceElements.push(dom.span({
className: "frame-link-filename",
}, short));
}, displaySource));
// If source is linkable, and we have a line number > 0
if (isLinkable && line) {

Просмотреть файл

@ -141,6 +141,30 @@ window.onload = Task.async(function* () {
tooltip: "View source in Debugger → http://myfile.com/mahscripts.js",
});
// Check if file is rendered with "/" for root documents when showEmptyPathAsHost is false
yield checkFrameComponent({
source: "http://www.cnn.com/",
line: "1",
showEmptyPathAsHost: false,
}, {
file: "/",
line: "1",
shouldLink: true,
tooltip: "View source in Debugger → http://www.cnn.com/:1",
});
// Check if file is rendered with hostname for root documents when showEmptyPathAsHost is true
yield checkFrameComponent({
source: "http://www.cnn.com/",
line: "1",
showEmptyPathAsHost: true,
}, {
file: "www.cnn.com",
line: "1",
shouldLink: true,
tooltip: "View source in Debugger → http://www.cnn.com/:1",
});
function* checkFrameComponent (input, expected) {
let frame = ReactDOM.render(Frame({
frame: input,

Просмотреть файл

@ -2610,8 +2610,9 @@ WebConsoleFrame.prototype = {
source: fullURL,
line,
column,
showEmptyPathAsHost: true,
},
onClick
onClick,
}), locationNode);
return locationNode;