Bug 1349360 - Expose client-side source map service on toolbox. r=ochameau
This makes the new client-side mapping service available from the toolbox. Note
that it's not actually _used_ from here yet, as that will happen in separately.
MozReview-Commit-ID: 5Bq774CANfC
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -520,16 +520,33 @@ Toolbox.prototype = {
get ReactRedux() {
return this.browserRequire("devtools/client/shared/vendor/react-redux");
},
get ToolboxController() {
return this.browserRequire("devtools/client/framework/components/toolbox-controller");
},
+ /**
+ * A common access point for the client-side mapping service for source maps that
+ * any panel can use.
+ */
+ get sourceMapService() {
+ if (!Services.prefs.getBoolPref("devtools.source-map.client-service.enabled")) {
+ return null;
+ }
+ if (this._sourceMapService) {
+ return this._sourceMapService;
+ }
+ // Uses browser loader to access the `Worker` global.
+ this._sourceMapService =
+ this.browserRequire("devtools/client/shared/source-map/index");
+ return this._sourceMapService;
+ },
+
// Return HostType id for telemetry
_getTelemetryHostId: function () {
switch (this.hostType) {
case Toolbox.HostType.BOTTOM: return 0;
case Toolbox.HostType.SIDE: return 1;
case Toolbox.HostType.WINDOW: return 2;
case Toolbox.HostType.CUSTOM: return 3;
default: return 9;
@@ -2271,16 +2288,21 @@ Toolbox.prototype = {
this._lastFocusedElement = null;
if (this._deprecatedServerSourceMapService) {
this._deprecatedServerSourceMapService.destroy();
this._deprecatedServerSourceMapService = null;
}
+ if (this._sourceMapService) {
+ this._sourceMapService.destroyWorker();
+ this._sourceMapService = null;
+ }
+
if (this.webconsolePanel) {
this._saveSplitConsoleHeight();
this.webconsolePanel.removeEventListener("resize",
this._saveSplitConsoleHeight);
this.webconsolePanel = null;
}
if (this.textBoxContextMenuPopup) {
this.textBoxContextMenuPopup.removeEventListener("popupshowing",
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -303,16 +303,19 @@ pref("devtools.webconsole.new-frontend-e
// Enable the server-side mapping service for source maps in console (deprecated)
// NOTE: This approach to source maps uses server-side source maps, which we are
// replacing with client-side source maps. Do not use this in new code paths.
// To be removed in bug 1349354. Read more about ongoing work with source maps:
// https://docs.google.com/document/d/19TKnMJD3CMBzwByNE4aBBVWnl-AEan8Sf4hxi6J-eps/edit
pref("devtools.source-map.locations.enabled", false);
+// Enable client-side mapping service for source maps
+pref("devtools.source-map.client-service.enabled", true);
+
// The number of lines that are displayed in the web console.
pref("devtools.hud.loglimit", 1000);
// The number of lines that are displayed in the web console for the Net,
// CSS, JS and Web Developer categories. These defaults should be kept in sync
// with DEFAULT_LOG_LIMIT in the webconsole frontend.
pref("devtools.hud.loglimit.network", 1000);
pref("devtools.hud.loglimit.cssparser", 1000);