Bug 1349360 - Expose client-side source map service on toolbox. r=ochameau draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 21 Mar 2017 17:11:17 -0500
changeset 503810 fba1b25d02f688492c23c11ba05ec425943d0c6c
parent 503809 0bb915acac7a3fe3f6ddb2f46cbb4436c10010e3
child 550504 3dcf50c1342bac2f5daba73636018ac9c79ed515
push id50657
push userbmo:jryans@gmail.com
push dateThu, 23 Mar 2017 14:54:24 +0000
reviewersochameau
bugs1349360
milestone55.0a1
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
devtools/client/framework/toolbox.js
devtools/client/preferences/devtools.js
--- 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);