Bug 1507260 - Pretty Print fails with sourceMap error when Source Maps is off. r=lsmyth
authorJason Laster <jlaster@mozilla.com>
Wed, 14 Nov 2018 15:09:32 -0500
changeset 447405 8a25480541382c670e4f17148b218660ebc63ff1
parent 447404 004331df8823ee887cc787e29ef7efe4fa4e596f
child 447406 7b8ac6916321039ae4fc993853b851a98d65f8c3
push id35076
push usershindli@mozilla.com
push dateWed, 21 Nov 2018 04:05:31 +0000
treeherdermozilla-central@50785e9ffd05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsmyth
bugs1507260
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507260 - Pretty Print fails with sourceMap error when Source Maps is off. r=lsmyth Tags: Bug #: 1507260 Differential Revision: https://phabricator.services.mozilla.com/D11928
devtools/client/debugger/new/src/actions/sources/newSources.js
devtools/client/debugger/new/src/utils/source.js
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps-disabled.js
devtools/client/framework/toolbox.js
devtools/client/styleeditor/StyleEditorUI.jsm
--- a/devtools/client/debugger/new/src/actions/sources/newSources.js
+++ b/devtools/client/debugger/new/src/actions/sources/newSources.js
@@ -20,16 +20,18 @@ import { selectLocation } from "../sourc
 import { getRawSourceURL, isPrettyURL, isOriginal } from "../../utils/source";
 import {
   getBlackBoxList,
   getSource,
   getPendingSelectedLocation,
   getPendingBreakpointsForSource
 } from "../../selectors";
 
+import { prefs } from "../../utils/prefs";
+
 import type { Source, SourceId } from "../../types";
 import type { Action, ThunkArgs } from "../types";
 
 function createOriginalSource(
   originalUrl,
   generatedSource,
   sourceMaps
 ): Source {
@@ -41,17 +43,17 @@ function createOriginalSource(
     isWasm: false,
     isBlackBoxed: false,
     loadedState: "unloaded"
   };
 }
 
 function loadSourceMaps(sources) {
   return async function({ dispatch, sourceMaps }: ThunkArgs) {
-    if (!sourceMaps) {
+    if (!prefs.clientSourceMapsEnabled) {
       return;
     }
 
     let originalSources = await Promise.all(
       sources.map(({ id }) => dispatch(loadSourceMap(id)))
     );
 
     originalSources = flatten(originalSources).filter(Boolean);
--- a/devtools/client/debugger/new/src/utils/source.js
+++ b/devtools/client/debugger/new/src/utils/source.js
@@ -56,18 +56,17 @@ function trimUrlQuery(url: string): stri
 }
 
 export function shouldPrettyPrint(source: Source) {
   if (
     !source ||
     isPretty(source) ||
     !isJavaScript(source) ||
     isOriginal(source) ||
-    source.sourceMapURL ||
-    !prefs.clientSourceMapsEnabled
+    (prefs.clientSourceMapsEnabled && source.sourceMapURL)
   ) {
     return false;
   }
 
   return true;
 }
 
 /**
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -725,16 +725,17 @@ skip-if = true
 [browser_dbg-pause-points.js]
 [browser_dbg-scopes-mutations.js]
 [browser_dbg-search-file.js]
 skip-if = os == "win" # Bug 1393121
 [browser_dbg-quick-open.js]
 skip-if = os == "win"
 [browser_dbg-search-project.js]
 [browser_dbg-sourcemaps.js]
+[browser_dbg-sourcemaps-disabled.js]
 [browser_dbg-sourcemaps-reload.js]
 skip-if = os == "win" || (verify) # Bug 1434792
 [browser_dbg-sourcemaps-reloading.js]
 [browser_dbg-sourcemaps2.js]
 [browser_dbg-sourcemaps3.js]
 [browser_dbg-sourcemaps-bogus.js]
 skip-if = os == 'linux' && !asan # bug 1447118
 [browser_dbg-sources.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps-disabled.js
@@ -0,0 +1,19 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Tests loading and pretty printing bundles with sourcemaps disabled
+requestLongerTimeout(2);
+
+add_task(async function() {
+  await pushPref("devtools.source-map.client-service.enabled", false);
+  const dbg = await initDebugger("doc-sourcemaps.html");
+
+  await waitForSources(dbg, "bundle.js");
+  const bundleSrc = findSource(dbg, "bundle.js");
+
+  info('Pretty print the bundle');
+  await selectSource(dbg, bundleSrc);
+  clickElement(dbg, "prettyPrintButton");
+  await waitForSelectedSource(dbg, "bundle.js:formatted");
+  ok(true, 'everything finished');
+});
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -685,19 +685,16 @@ Toolbox.prototype = {
   },
 
   /**
    * A common access point for the client-side mapping service for source maps that
    * any panel can use.  This is a "low-level" API that connects to
    * the source map worker.
    */
   get sourceMapService() {
-    if (!Services.prefs.getBoolPref("devtools.source-map.client-service.enabled")) {
-      return null;
-    }
     return this._createSourceMapService();
   },
 
   /**
    * Clients wishing to use source maps but that want the toolbox to
    * track the source and style sheet actor mapping can use this
    * source map service.  This is a higher-level service than the one
    * returned by |sourceMapService|, in that it automatically tracks
--- a/devtools/client/styleeditor/StyleEditorUI.jsm
+++ b/devtools/client/styleeditor/StyleEditorUI.jsm
@@ -309,17 +309,18 @@ StyleEditorUI.prototype = {
     }
 
     if (!this._seenSheets.has(styleSheet)) {
       const promise = (async () => {
         let editor = await this._addStyleSheetEditor(styleSheet, isNew);
 
         const toolbox = gDevTools.getToolbox(this._target);
         const sourceMapService = toolbox.sourceMapService;
-        if (!sourceMapService) {
+
+        if (!sourceMapService || !Services.prefs.getBoolPref(PREF_ORIG_SOURCES)) {
           return editor;
         }
 
         const {href, nodeHref, actorID: id, sourceMapURL} = styleSheet;
         const url = href || nodeHref;
         const sources = await sourceMapService.getOriginalURLs({
           id,
           url,