зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1131756 - properly display anonymous sources when they are needed in the debugger r=ejpbruel
This commit is contained in:
Родитель
8586396a0c
Коммит
a4a62e7769
|
@ -690,9 +690,7 @@ StackFrames.prototype = {
|
|||
let { depth, source, where: { line } } = frame;
|
||||
|
||||
let isBlackBoxed = source ? this.activeThread.source(source).isBlackBoxed : false;
|
||||
let location = NetworkHelper.convertToUnicode(unescape(source.url || source.introductionUrl));
|
||||
let title = StackFrameUtils.getFrameTitle(frame);
|
||||
DebuggerView.StackFrames.addFrame(title, location, line, depth, isBlackBoxed);
|
||||
DebuggerView.StackFrames.addFrame(frame, line, depth, isBlackBoxed);
|
||||
}
|
||||
|
||||
DebuggerView.StackFrames.selectedDepth = Math.max(this.currentFrameDepth, 0);
|
||||
|
|
|
@ -129,6 +129,7 @@ skip-if = e10s || true # bug 1113935
|
|||
[browser_dbg_blackboxing-05.js]
|
||||
[browser_dbg_blackboxing-06.js]
|
||||
[browser_dbg_breadcrumbs-access.js]
|
||||
[browser_dbg_break-in-anon.js]
|
||||
[browser_dbg_break-on-dom-01.js]
|
||||
[browser_dbg_break-on-dom-02.js]
|
||||
[browser_dbg_break-on-dom-03.js]
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Make sure anonymous eval scripts can still break with a `debugger`
|
||||
* statement
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_script-eval.html";
|
||||
|
||||
function test() {
|
||||
let gTab, gPanel, gDebugger;
|
||||
let gSources, gBreakpoints;
|
||||
|
||||
initDebugger(TAB_URL).then(([aTab,, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
gSources = gDebugger.DebuggerView.Sources;
|
||||
gBreakpoints = gDebugger.DebuggerController.Breakpoints;
|
||||
|
||||
return Task.spawn(function*() {
|
||||
yield waitForSourceShown(gPanel, "-eval.js");
|
||||
is(gSources.values.length, 1, "Should have 1 source");
|
||||
|
||||
let hasFrames = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED);
|
||||
callInTab(gTab, "evalSourceWithDebugger");
|
||||
yield hasFrames;
|
||||
|
||||
is(gSources.values.length, 2, "Should have 2 sources");
|
||||
|
||||
let item = gSources.getItemForAttachment(e => e.label.indexOf("SCRIPT") === 0);
|
||||
ok(item, "Source label is incorrect.");
|
||||
is(item.attachment.group, gDebugger.L10N.getStr('anonymousSourcesLabel'),
|
||||
'Source group is incorrect');
|
||||
|
||||
yield resumeDebuggerThenCloseAndFinish(gPanel);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -41,7 +41,7 @@ function performTest() {
|
|||
is(gFrames.getItemAtIndex(1).attachment.title,
|
||||
"(eval)", "Newest frame name should be correct.");
|
||||
is(gFrames.getItemAtIndex(1).attachment.url,
|
||||
TAB_URL, "Newest frame url should be correct.");
|
||||
'SCRIPT0', "Newest frame url should be correct.");
|
||||
is(gClassicFrames.getItemAtIndex(1).attachment.depth,
|
||||
1, "Newest frame name is mirrored correctly.");
|
||||
|
||||
|
|
|
@ -8,3 +8,7 @@ function evalSource() {
|
|||
function evalSourceWithSourceURL() {
|
||||
eval('bar = function() {\nvar x = 6;\n} //# sourceURL=bar.js');
|
||||
}
|
||||
|
||||
function evalSourceWithDebugger() {
|
||||
eval('bar = function() {\nvar x = 7;\ndebugger; }\n bar();');
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ const KNOWN_SOURCE_GROUPS = {
|
|||
"Add-on SDK": "resource://gre/modules/commonjs/",
|
||||
};
|
||||
|
||||
KNOWN_SOURCE_GROUPS[L10N.getStr("evalGroupLabel")] = "eval";
|
||||
KNOWN_SOURCE_GROUPS[L10N.getStr("anonymousSourcesLabel")] = "anonymous";
|
||||
|
||||
/**
|
||||
* Functions handling the sources UI.
|
||||
|
@ -53,6 +53,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
showArrows: true
|
||||
});
|
||||
|
||||
this._unnamedSourceIndex = 0;
|
||||
this.emptyText = L10N.getStr("noSourcesText");
|
||||
this._blackBoxCheckboxTooltip = L10N.getStr("blackBoxCheckboxTooltip");
|
||||
|
||||
|
@ -121,6 +122,11 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this._newTabMenuItem.removeEventListener("command", this._onNewTabCommand, false);
|
||||
},
|
||||
|
||||
empty: function() {
|
||||
WidgetMethods.empty.call(this);
|
||||
this._unnamedSourceIndex = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
|
@ -161,7 +167,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
* - staged: true to stage the item to be appended later
|
||||
*/
|
||||
addSource: function(aSource, aOptions = {}) {
|
||||
if (!aSource.url) {
|
||||
if (!aSource.url && !aOptions.force) {
|
||||
// We don't show any unnamed eval scripts yet (see bug 1124106)
|
||||
return;
|
||||
}
|
||||
|
@ -195,14 +201,24 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
|
||||
_parseUrl: function(aSource) {
|
||||
let fullUrl = aSource.url;
|
||||
let url = fullUrl.split(" -> ").pop();
|
||||
let label = aSource.addonPath ? aSource.addonPath : SourceUtils.getSourceLabel(url);
|
||||
let group = aSource.addonID ? aSource.addonID : SourceUtils.getSourceGroup(url);
|
||||
let url, unicodeUrl, label, group;
|
||||
|
||||
if(!fullUrl) {
|
||||
unicodeUrl = 'SCRIPT' + this._unnamedSourceIndex++;
|
||||
label = unicodeUrl;
|
||||
group = L10N.getStr("anonymousSourcesLabel");
|
||||
}
|
||||
else {
|
||||
let url = fullUrl.split(" -> ").pop();
|
||||
label = aSource.addonPath ? aSource.addonPath : SourceUtils.getSourceLabel(url);
|
||||
group = aSource.addonID ? aSource.addonID : SourceUtils.getSourceGroup(url);
|
||||
unicodeUrl = NetworkHelper.convertToUnicode(unescape(fullUrl));
|
||||
}
|
||||
|
||||
return {
|
||||
label: label,
|
||||
group: group,
|
||||
unicodeUrl: NetworkHelper.convertToUnicode(unescape(fullUrl))
|
||||
unicodeUrl: unicodeUrl
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -642,6 +658,13 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
return aLocation.actor;
|
||||
},
|
||||
|
||||
getDisplayURL: function(source) {
|
||||
if(!source.url) {
|
||||
return this.getItemByValue(source.actor).attachment.label;
|
||||
}
|
||||
return NetworkHelper.convertToUnicode(unescape(source.url))
|
||||
},
|
||||
|
||||
/**
|
||||
* Marks a breakpoint as selected in this sources container.
|
||||
*
|
||||
|
|
|
@ -62,27 +62,40 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
* @param boolean aIsBlackBoxed
|
||||
* Whether or not the frame is black boxed.
|
||||
*/
|
||||
addFrame: function(aTitle, aUrl, aLine, aDepth, aIsBlackBoxed) {
|
||||
addFrame: function(aFrame, aLine, aDepth, aIsBlackBoxed) {
|
||||
let { source } = aFrame;
|
||||
|
||||
// The source may not exist in the source listing yet because it's
|
||||
// an unnamed eval source, which we hide, so we need to add it
|
||||
if(!DebuggerView.Sources.getItemByValue(source.actor)) {
|
||||
DebuggerView.Sources.addSource(source, { force: true });
|
||||
}
|
||||
|
||||
let location = DebuggerView.Sources.getDisplayURL(source);
|
||||
let title = StackFrameUtils.getFrameTitle(aFrame);
|
||||
|
||||
// Blackboxed stack frames are collapsed into a single entry in
|
||||
// the view. By convention, only the first frame is displayed.
|
||||
if (aIsBlackBoxed) {
|
||||
if (this._prevBlackBoxedUrl == aUrl) {
|
||||
if (this._prevBlackBoxedUrl == location) {
|
||||
return;
|
||||
}
|
||||
this._prevBlackBoxedUrl = aUrl;
|
||||
this._prevBlackBoxedUrl = location;
|
||||
} else {
|
||||
this._prevBlackBoxedUrl = null;
|
||||
}
|
||||
|
||||
// Create the element node for the stack frame item.
|
||||
let frameView = this._createFrameView.apply(this, arguments);
|
||||
let frameView = this._createFrameView(
|
||||
title, location, aLine, aDepth, aIsBlackBoxed
|
||||
);
|
||||
|
||||
// Append a stack frame item to this container.
|
||||
this.push([frameView], {
|
||||
index: 0, /* specifies on which position should the item be appended */
|
||||
attachment: {
|
||||
title: aTitle,
|
||||
url: aUrl,
|
||||
title: title,
|
||||
url: location,
|
||||
line: aLine,
|
||||
depth: aDepth
|
||||
},
|
||||
|
@ -92,7 +105,7 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
});
|
||||
|
||||
// Mirror this newly inserted item inside the "Call Stack" tab.
|
||||
this._mirror.addFrame(aTitle, aUrl, aLine, aDepth);
|
||||
this._mirror.addFrame(title, location, aLine, aDepth);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -320,5 +320,4 @@ variablesViewOptimizedOut=(optimized away)
|
|||
variablesViewUninitialized=(uninitialized)
|
||||
variablesViewMissingArgs=(unavailable)
|
||||
|
||||
evalGroupLabel=Evaluated Sources
|
||||
anonymousSourcesLabel=Anonymous Sources
|
||||
anonymousSourcesLabel=Anonymous Sources
|
Загрузка…
Ссылка в новой задаче