Don't take the slow async path when source maps are not enabled or present (bug 873224); r=rcampbell f=nfitzgerald

This commit is contained in:
Panos Astithas 2013-06-11 10:58:57 +03:00
Родитель 88cfb34510
Коммит c3fa5c9c0d
4 изменённых файлов: 83 добавлений и 4 удалений

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

@ -5,6 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// A time interval sufficient for the options popup panel to finish hiding
// itself.
const POPUP_HIDDEN_DELAY = 100; // ms
/**
* Functions handling the toolbar view: close button, expand/collapse button,
* pause/resume and stepping buttons etc.
@ -233,6 +237,13 @@ OptionsView.prototype = {
this._button.removeAttribute("open");
},
/**
* Listener handling the 'gear menu' popup hidden event.
*/
_onPopupHidden: function() {
window.dispatchEvent(document, "Debugger:OptionsPopupHidden");
},
/**
* Listener handling the 'pause on exceptions' menuitem command.
*/
@ -269,10 +280,19 @@ OptionsView.prototype = {
* Listener handling the 'show original source' menuitem command.
*/
_toggleShowOriginalSource: function() {
function reconfigure() {
window.removeEventListener("Debugger:OptionsPopupHidden", reconfigure, false);
// The popup panel needs more time to hide after triggering onpopuphidden.
window.setTimeout(function() {
DebuggerController.reconfigureThread(pref);
}, POPUP_HIDDEN_DELAY);
}
let pref = Prefs.sourceMapsEnabled =
this._showOriginalSourceItem.getAttribute("checked") == "true";
DebuggerController.reconfigureThread(pref);
// Don't block the UI while reconfiguring the server.
window.addEventListener("Debugger:OptionsPopupHidden", reconfigure, false);
},
_button: null,

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

@ -145,7 +145,8 @@
<menupopup id="debuggerPrefsContextMenu"
position="before_end"
onpopupshowing="DebuggerView.Options._onPopupShowing()"
onpopuphiding="DebuggerView.Options._onPopupHiding()">
onpopuphiding="DebuggerView.Options._onPopupHiding()"
onpopuphidden="DebuggerView.Options._onPopupHidden()">
<menuitem id="pause-on-exceptions"
type="checkbox"
label="&debuggerUI.pauseExceptions;"

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

@ -80,6 +80,7 @@ function testToggleGeneratedSource() {
gDebugger.DebuggerView.Options._showOriginalSourceItem.setAttribute("checked",
"false");
gDebugger.DebuggerView.Options._toggleShowOriginalSource();
gDebugger.DebuggerView.Options._onPopupHidden();
}
function testSetBreakpoint() {
@ -157,6 +158,7 @@ function testToggleOnPause() {
gDebugger.DebuggerView.Options._showOriginalSourceItem.setAttribute("checked",
"true");
gDebugger.DebuggerView.Options._toggleShowOriginalSource();
gDebugger.DebuggerView.Options._onPopupHidden();
}
function resumeAndFinish()

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

@ -716,8 +716,30 @@ ThreadActor.prototype = {
* Get the script and source lists from the debugger.
*/
_discoverScriptsAndSources: function TA__discoverScriptsAndSources() {
return all([this._addScript(s)
for (s of this.dbg.findScripts())]);
let promises = [];
let foundSourceMaps = false;
let scripts = this.dbg.findScripts();
for (let s of scripts) {
if (s.sourceMapURL && !foundSourceMaps) {
foundSourceMaps = true;
break;
}
}
if (this._options.useSourceMaps && foundSourceMaps) {
for (let s of scripts) {
promises.push(this._addScript(s));
}
return all(promises);
}
// When source maps are not enabled or not used in the page _addScript is
// synchronous, since it doesn't need to wait for fetching source maps, so
// resolves immediately. This eliminates a huge slowdown in script-heavy
// pages like G+ or chrome debugging, where the GC takes a long time to
// clean up after Promise.all.
for (let s of scripts) {
this._addScriptSync(s);
}
return resolve(null);
},
onSources: function TA_onSources(aRequest) {
@ -1248,6 +1270,40 @@ ThreadActor.prototype = {
return true;
},
/**
* Add the provided script to the server cache synchronously, without checking
* for any declared source maps.
*
* @param aScript Debugger.Script
* The source script that will be stored.
* @returns true, if the script was added; false otherwise.
*/
_addScriptSync: function TA__addScriptSync(aScript) {
if (!this._allowSource(aScript.url)) {
return false;
}
this.sources.source(aScript.url);
// Set any stored breakpoints.
let existing = this._breakpointStore[aScript.url];
if (existing) {
let endLine = aScript.startLine + aScript.lineCount - 1;
// Iterate over the lines backwards, so that sliding breakpoints don't
// affect the loop.
for (let line = existing.length - 1; line >= 0; line--) {
let bp = existing[line];
// Only consider breakpoints that are not already associated with
// scripts, and limit search to the line numbers contained in the new
// script.
if (bp && !bp.actor.scripts.length &&
line >= aScript.startLine && line <= endLine) {
this._setBreakpoint(bp);
}
}
}
return true;
},
/**
* Add the provided script to the server cache.
*