From c05fed43cfffe2f2a99bcb6a40d50c44d20fdbdc Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Wed, 17 Jan 2018 17:58:26 +0100 Subject: [PATCH] Bug 1430855 - Update Debugger Frontend v9.1. r=jdescottes MozReview-Commit-ID: CnJ3iP3tjAw --- devtools/client/debugger/new/README.mozilla | 6 +-- devtools/client/debugger/new/debugger.css | 2 +- devtools/client/debugger/new/debugger.js | 45 ++++++++++++------- devtools/client/debugger/new/parser-worker.js | 28 +++++++----- .../test/mochitest/browser_dbg-minified.js | 2 + .../test/mochitest/browser_dbg-sourcemaps3.js | 1 + devtools/client/preferences/debugger.js | 2 +- 7 files changed, 53 insertions(+), 33 deletions(-) diff --git a/devtools/client/debugger/new/README.mozilla b/devtools/client/debugger/new/README.mozilla index 3c3f9a97906d..fa7ffd5f85a5 100644 --- a/devtools/client/debugger/new/README.mozilla +++ b/devtools/client/debugger/new/README.mozilla @@ -1,9 +1,9 @@ This is the debugger.html project output. See https://github.com/devtools-html/debugger.html -Version 9.0 -commit: https://github.com/devtools-html/debugger.html/commit/0de8d3f673ee0f0030d666f1827380e17bef8036 -comparison: https://github.com/devtools-html/debugger.html/compare/release-8...release-9 +Version 9.1 +commit: https://github.com/devtools-html/debugger.html/commit/3fbfed14525b26de4716db2a6447e2d612f4ff6a +comparison: https://github.com/devtools-html/debugger.html/compare/release-9...release-9-1 Packages: - babel-plugin-transform-es2015-modules-commonjs @6.26.0 diff --git a/devtools/client/debugger/new/debugger.css b/devtools/client/debugger/new/debugger.css index b31eb585629f..f83253083e43 100644 --- a/devtools/client/debugger/new/debugger.css +++ b/devtools/client/debugger/new/debugger.css @@ -1533,7 +1533,7 @@ html[dir="rtl"] .managed-tree .tree .node > div { margin-bottom: -2px; } -.sources-list .managed-tree .tree .node.focused img.blackBox { +.sources-list .managed-tree .tree .node.focused img { background-color: white; } diff --git a/devtools/client/debugger/new/debugger.js b/devtools/client/debugger/new/debugger.js index 272089bd30f1..2bf46afc37eb 100644 --- a/devtools/client/debugger/new/debugger.js +++ b/devtools/client/debugger/new/debugger.js @@ -18740,7 +18740,7 @@ function isNotJavaScript(source) { } function isInvalidUrl(url, source) { - return IGNORED_URLS.indexOf(url) != -1 || !source.get("url") || source.get("loadedState") === "loading" || !url.group || (0, _source.isPretty)(source) || isNotJavaScript(source); + return IGNORED_URLS.indexOf(url) != -1 || !source.get("url") || !url.group || (0, _source.isPretty)(source) || isNotJavaScript(source); } function partIsFile(index, parts, url) { @@ -21547,8 +21547,8 @@ function setSymbols(sourceId) { const symbols = await (0, _parser.getSymbols)(source); dispatch({ type: "SET_SYMBOLS", source, symbols }); - dispatch(setEmptyLines(source.id)); - dispatch(setSourceMetaData(source.id)); + dispatch(setEmptyLines(sourceId)); + dispatch(setSourceMetaData(sourceId)); }; } @@ -21584,7 +21584,10 @@ function setOutOfScopeLocations() { const source = (0, _selectors.getSource)(getState(), location.sourceId); - const locations = !location.line || !source ? null : await (0, _parser.findOutOfScopeLocations)(source.toJS(), location); + let locations = null; + if (location.line && source && (0, _selectors.isPaused)(getState())) { + locations = await (0, _parser.findOutOfScopeLocations)(source.toJS(), location); + } dispatch({ type: "OUT_OF_SCOPE_LOCATIONS", @@ -24436,8 +24439,6 @@ var _devtoolsSourceMap = __webpack_require__(1360); var _promise = __webpack_require__(1653); -var _ast = __webpack_require__(1399); - var _selectors = __webpack_require__(1352); var _parser = __webpack_require__(1365); @@ -24456,11 +24457,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at . */ - -const requests = new Map(); +const requests = new Map(); /* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ async function loadSource(source, { sourceMaps, client }) { const id = source.get("id"); @@ -24536,7 +24535,6 @@ function loadSourceText(source) { if (!newSource.isWasm) { await parser.setSource(newSource); - dispatch((0, _ast.setSymbols)(id)); } // signal that the action is finished @@ -49179,14 +49177,23 @@ function createOriginalSource(originalUrl, generatedSource, sourceMaps) { }; } +// TODO: It would be nice to make getOriginalURLs a safer api +async function loadOriginalSourceUrls(sourceMaps, generatedSource) { + try { + return await sourceMaps.getOriginalURLs(generatedSource); + } catch (e) { + console.error(e); + return null; + } +} + /** * @memberof actions/sources * @static */ function loadSourceMap(generatedSource) { return async function ({ dispatch, getState, sourceMaps }) { - const urls = await sourceMaps.getOriginalURLs(generatedSource); - + const urls = await loadOriginalSourceUrls(sourceMaps, generatedSource); if (!urls) { // If this source doesn't have a sourcemap, do nothing. return; @@ -49448,11 +49455,17 @@ function selectLocation(location, tabIndex = "") { await dispatch((0, _loadSourceText.loadSourceText)(source)); const selectedSource = (0, _selectors.getSelectedSource)(getState()); - if (_prefs.prefs.autoPrettyPrint && !(0, _selectors.getPrettySource)(getState(), selectedSource.get("id")) && (0, _source.shouldPrettyPrint)(selectedSource) && (0, _source.isMinified)(selectedSource)) { - await dispatch((0, _prettyPrint.togglePrettyPrint)(source.get("id"))); + if (!selectedSource) { + return; + } + + const sourceId = selectedSource.get("id"); + if (_prefs.prefs.autoPrettyPrint && !(0, _selectors.getPrettySource)(getState(), sourceId) && (0, _source.shouldPrettyPrint)(selectedSource) && (0, _source.isMinified)(selectedSource)) { + await dispatch((0, _prettyPrint.togglePrettyPrint)(sourceId)); dispatch((0, _tabs.closeTab)(source.get("url"))); } + dispatch((0, _ast.setSymbols)(sourceId)); dispatch((0, _ast.setOutOfScopeLocations)()); }; } diff --git a/devtools/client/debugger/new/parser-worker.js b/devtools/client/debugger/new/parser-worker.js index 533d8c7b2ac6..410574e9026d 100644 --- a/devtools/client/debugger/new/parser-worker.js +++ b/devtools/client/debugger/new/parser-worker.js @@ -35475,11 +35475,6 @@ module.exports = { Object.defineProperty(exports, "__esModule", { value: true }); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at . */ - exports.parseScript = parseScript; exports.getAst = getAst; exports.clearASTs = clearASTs; @@ -35505,14 +35500,23 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ + let ASTs = new Map(); function _parse(code, opts) { - return babylon.parse(code, _extends({}, opts, { + return babylon.parse(code, opts); +} + +const sourceOptions = { + generated: {}, + original: { sourceType: "module", plugins: ["jsx", "flow", "doExpressions", "objectRestSpread", "classProperties", "exportExtensions", "asyncGenerators", "functionBind", "functionSent", "dynamicImport", "templateInvalidEscapes"] - })); -} + } +}; function parse(text, opts) { let ast; @@ -35532,9 +35536,7 @@ function parse(text, opts) { // Custom parser for parse-script-tags that adapts its input structure to // our parser's signature function htmlParser({ source, line }) { - return parse(source, { - startLine: line - }); + return parse(source, { startLine: line }); } function parseScript(text, opts) { @@ -35555,7 +35557,9 @@ function getAst(source) { if (contentType == "text/html") { ast = (0, _parseScriptTags2.default)(source.text, htmlParser) || {}; } else if (contentType && contentType.match(/(javascript|jsx)/)) { - ast = parse(source.text); + const type = source.id.includes("original") ? "original" : "generated"; + const options = sourceOptions[type]; + ast = parse(source.text, options); } ASTs.set(source.id, ast); diff --git a/devtools/client/debugger/new/test/mochitest/browser_dbg-minified.js b/devtools/client/debugger/new/test/mochitest/browser_dbg-minified.js index a878d6370de5..946a85d00f91 100644 --- a/devtools/client/debugger/new/test/mochitest/browser_dbg-minified.js +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-minified.js @@ -16,6 +16,8 @@ function getScopeNodeValue(dbg, index) { } add_task(async function() { + await pushPref("devtools.debugger.features.map-scopes", true); + const dbg = await initDebugger("doc-minified2.html"); await waitForSources(dbg, "sum.js"); diff --git a/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps3.js b/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps3.js index a89e9c079bf5..27abc9359b94 100644 --- a/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps3.js +++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps3.js @@ -25,6 +25,7 @@ async function waitForScopeNode(dbg, index) { add_task(async function() { // NOTE: the CORS call makes the test run times inconsistent requestLongerTimeout(2); + await pushPref("devtools.debugger.features.map-scopes", true); const dbg = await initDebugger("doc-sourcemaps3.html"); const { selectors: { getBreakpoint, getBreakpoints }, getState } = dbg; diff --git a/devtools/client/preferences/debugger.js b/devtools/client/preferences/debugger.js index d331ab14f4d8..da35d4126de4 100644 --- a/devtools/client/preferences/debugger.js +++ b/devtools/client/preferences/debugger.js @@ -48,7 +48,7 @@ pref("devtools.debugger.features.shortcuts", true); pref("devtools.debugger.features.root", false); pref("devtools.debugger.features.column-breakpoints", false); pref("devtools.debugger.features.chrome-scopes", false); -pref("devtools.debugger.features.map-scopes", true); +pref("devtools.debugger.features.map-scopes", false); pref("devtools.debugger.features.breakpoints-dropdown", true); pref("devtools.debugger.features.remove-command-bar-options", false); pref("devtools.debugger.features.workers", true);