mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 866950 - Errors from files loaded through loader.js not showing source in browser console; r=robcee
This commit is contained in:
parent
6cc708a8d0
commit
b113afcecf
@ -133,6 +133,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_console_private_browsing.js \
|
||||
browser_console_nsiconsolemessage.js \
|
||||
browser_webconsole_bug_817834_add_edited_input_to_history.js \
|
||||
browser_console_addonsdk_loader_exception.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Check that exceptions from scripts loaded with the addon-sdk loader are
|
||||
// opened correctly in View Source from the Browser Console.
|
||||
// See bug 866950.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<p>hello world from bug 866950";
|
||||
|
||||
function test()
|
||||
{
|
||||
let webconsole, browserconsole;
|
||||
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
|
||||
function consoleOpened(hud)
|
||||
{
|
||||
ok(hud, "web console opened");
|
||||
webconsole = hud;
|
||||
HUDConsoleUI.toggleBrowserConsole().then(browserConsoleOpened);
|
||||
}
|
||||
|
||||
function browserConsoleOpened(hud)
|
||||
{
|
||||
ok(hud, "browser console opened");
|
||||
browserconsole = hud;
|
||||
|
||||
// Cause an exception in a script loaded with the addon-sdk loader.
|
||||
let toolbox = gDevTools.getToolbox(webconsole.target);
|
||||
let oldPanels = toolbox._toolPanels;
|
||||
toolbox._toolPanels = null;
|
||||
function fixToolbox()
|
||||
{
|
||||
toolbox._toolPanels = oldPanels;
|
||||
}
|
||||
|
||||
info("generate exception and wait for message");
|
||||
|
||||
executeSoon(() => {
|
||||
executeSoon(fixToolbox);
|
||||
expectUncaughtException();
|
||||
toolbox.getToolPanels();
|
||||
});
|
||||
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
text: "TypeError: this._toolPanels is null",
|
||||
category: CATEGORY_JS,
|
||||
severity: SEVERITY_ERROR,
|
||||
},
|
||||
],
|
||||
}).then((results) => {
|
||||
fixToolbox();
|
||||
onMessageFound(results);
|
||||
});
|
||||
}
|
||||
|
||||
function onMessageFound(results)
|
||||
{
|
||||
let msg = [...results[0].matched][0];
|
||||
ok(msg, "message element found");
|
||||
let locationNode = msg.querySelector(".webconsole-location");
|
||||
ok(locationNode, "message location element found");
|
||||
|
||||
let title = locationNode.getAttribute("title");
|
||||
info("location node title: " + title);
|
||||
isnot(title.indexOf(" -> "), -1, "error comes from a subscript");
|
||||
|
||||
let viewSource = browserconsole.viewSource;
|
||||
let URL = null;
|
||||
browserconsole.viewSource = (aURL) => URL = aURL;
|
||||
|
||||
EventUtils.synthesizeMouse(locationNode, 2, 2, {},
|
||||
browserconsole.iframeWindow);
|
||||
|
||||
info("view-source url: " + URL);
|
||||
isnot(URL.indexOf("toolbox.js"), -1, "expected view source URL");
|
||||
is(URL.indexOf("->"), -1, "no -> in the URL given to view-source");
|
||||
|
||||
browserconsole.viewSource = viewSource;
|
||||
|
||||
finishTest();
|
||||
}
|
||||
}
|
@ -2373,21 +2373,24 @@ WebConsoleFrame.prototype = {
|
||||
|
||||
// Create the text, which consists of an abbreviated version of the URL
|
||||
// plus an optional line number. Scratchpad URLs should not be abbreviated.
|
||||
let text;
|
||||
let displayLocation;
|
||||
let fullURL;
|
||||
|
||||
if (/^Scratchpad\/\d+$/.test(aSourceURL)) {
|
||||
text = aSourceURL;
|
||||
displayLocation = aSourceURL;
|
||||
fullURL = aSourceURL;
|
||||
}
|
||||
else {
|
||||
text = WebConsoleUtils.abbreviateSourceURL(aSourceURL);
|
||||
fullURL = aSourceURL.split(" -> ").pop();
|
||||
displayLocation = WebConsoleUtils.abbreviateSourceURL(fullURL);
|
||||
}
|
||||
|
||||
if (aSourceLine) {
|
||||
text += ":" + aSourceLine;
|
||||
displayLocation += ":" + aSourceLine;
|
||||
locationNode.sourceLine = aSourceLine;
|
||||
}
|
||||
|
||||
locationNode.setAttribute("value", text);
|
||||
locationNode.setAttribute("value", displayLocation);
|
||||
|
||||
// Style appropriately.
|
||||
locationNode.setAttribute("crop", "center");
|
||||
@ -2397,7 +2400,7 @@ WebConsoleFrame.prototype = {
|
||||
locationNode.classList.add("text-link");
|
||||
|
||||
// Make the location clickable.
|
||||
locationNode.addEventListener("click", function() {
|
||||
locationNode.addEventListener("click", () => {
|
||||
if (/^Scratchpad\/\d+$/.test(aSourceURL)) {
|
||||
let wins = Services.wm.getEnumerator("devtools:scratchpad");
|
||||
|
||||
@ -2411,16 +2414,16 @@ WebConsoleFrame.prototype = {
|
||||
}
|
||||
}
|
||||
else if (locationNode.parentNode.category == CATEGORY_CSS) {
|
||||
this.owner.viewSourceInStyleEditor(aSourceURL, aSourceLine);
|
||||
this.owner.viewSourceInStyleEditor(fullURL, aSourceLine);
|
||||
}
|
||||
else if (locationNode.parentNode.category == CATEGORY_JS ||
|
||||
locationNode.parentNode.category == CATEGORY_WEBDEV) {
|
||||
this.owner.viewSourceInDebugger(aSourceURL, aSourceLine);
|
||||
this.owner.viewSourceInDebugger(fullURL, aSourceLine);
|
||||
}
|
||||
else {
|
||||
this.owner.viewSource(aSourceURL, aSourceLine);
|
||||
this.owner.viewSource(fullURL, aSourceLine);
|
||||
}
|
||||
}.bind(this), true);
|
||||
}, true);
|
||||
|
||||
return locationNode;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user