Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/panel/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ pref("devtools.debugger.features.shortcuts", true);
pref("devtools.debugger.project-directory-root", "");
pref("devtools.debugger.features.root", false);
pref("devtools.debugger.features.column-breakpoints", false);
pref("devtools.debugger.features.map-scopes", true);
5 changes: 5 additions & 0 deletions flow-typed/debugger-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ declare module "debugger-html" {
location: Location,
parameterNames: string[]
},
syntheticScopes?: {
scopes: SyntheticScope[],
groupIndex: number,
groupLength: number
},
type: string
};
}
86 changes: 30 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,40 @@
"start": "node bin/dev-server",
"start-app": "TARGET=application node bin/dev-server",
"flow": "flow",
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"eslint-check":
"eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"prettier": "node bin/prettier.js",
"license-check": "devtools-license-check",
"links": "ls -l node_modules/ | grep ^l || echo 'no linked packages'",
"lint": "run-p lint-css lint-js lint-md",
"lint-css": "stylelint \"src/components/**/*.css\"",
"lint-js": "eslint *.js \"src/**/*.js\" --fix",
"lint-md": "remark -u devtools-linters/markdown/preset -qf *.md src configs docs",
"lint-md":
"remark -u devtools-linters/markdown/preset -qf *.md src configs docs",
"lint-fix": "yarn lint-js -- --fix",
"mochi": "mochii --mc ./firefox --interactive --default-test-path devtools/client/debugger/new",
"mochi":
"mochii --mc ./firefox --interactive --default-test-path devtools/client/debugger/new",
"mochid": "yarn mochi -- --jsdebugger --",
"mochir": "yarn mochi -- --repeat 10 --",
"mochih": "yarn mochi -- --setenv MOZ_HEADLESS=1 --",
"test": "jest",
"test:watch": "jest --watch",
"test-coverage": "yarn test -- --coverage",
"test-all": "yarn test; yarn lint; yarn flow",
"firefox": "start-firefox --start --location https://devtools-html.github.io/debugger-examples/",
"chrome": "start-chrome --location https://devtools-html.github.io/debugger-examples/",
"firefox":
"start-firefox --start --location https://devtools-html.github.io/debugger-examples/",
"chrome":
"start-chrome --location https://devtools-html.github.io/debugger-examples/",
"copy-assets": "node bin/copy-assets --symlink",
"copy-assets-watch": "node bin/copy-assets --watch --symlink",
"build-docs": "documentation build --format html --sort-order alpha --shallow --document-exported --output docs/reference/ src/types.js src/utils/ src/reducers/ src/actions/ src/test/mochitest/head.js",
"flow-coverage": "flow-coverage-report --threshold 50 -i 'src/actions/*.js' -i 'src/reducers/*.js' -i 'src/utils/*.js' -i 'src/components/*.js' -i 'src/components/**/*.js' -t html -t text",
"flow-utils": "flow-coverage-report -i 'src/utils/*.js' -i 'src/utils/**/*.js' -t text",
"flow-redux": "flow-coverage-report -i 'src/reducers/*.js' -i 'src/actions/*.js' -t text",
"build-docs":
"documentation build --format html --sort-order alpha --shallow --document-exported --output docs/reference/ src/types.js src/utils/ src/reducers/ src/actions/ src/test/mochitest/head.js",
"flow-coverage":
"flow-coverage-report --threshold 50 -i 'src/actions/*.js' -i 'src/reducers/*.js' -i 'src/utils/*.js' -i 'src/components/*.js' -i 'src/components/**/*.js' -t html -t text",
"flow-utils":
"flow-coverage-report -i 'src/utils/*.js' -i 'src/utils/**/*.js' -t text",
"flow-redux":
"flow-coverage-report -i 'src/reducers/*.js' -i 'src/actions/*.js' -t text",
"flow-react": "flow-coverage-report -i 'src/components/**/*.js' -t text",
"storybook": "start-storybook -p 6006",
"snapshot": "NODE_ENV='development' build-storybook && percy-storybook",
Expand All @@ -68,7 +77,7 @@
"devtools-map-bindings": "^0.3.2",
"devtools-reps": "^0.12.4",
"devtools-source-editor": "^0.0.8",
"devtools-source-map": "^0.14.5",
"devtools-source-map": "^0.14.7",
"devtools-splitter": "^0.0.5",
"devtools-utils": "^0.0.10",
"fuzzaldrin-plus": "^0.4.1",
Expand All @@ -90,18 +99,9 @@
"svg-inline-react": "^1.0.2",
"wasmparser": "^0.4.10"
},
"files": [
"src",
"assets"
],
"files": ["src", "assets"],
"greenkeeper": {
"ignore": [
"react",
"react-dom",
"react-redux",
"redux",
"codemirror"
]
"ignore": ["react", "react-dom", "react-redux", "redux", "codemirror"]
},
"main": "src/main.js",
"author": "Jason Laster <jlaster@mozilla.com>",
Expand Down Expand Up @@ -165,44 +165,18 @@
"workerjs": "github:jasonLaster/workerjs"
},
"lint-staged": {
"*.js": [
"prettier",
"git add"
],
"src/*.js": [
"prettier",
"git add"
],
"src/*/*.js": [
"prettier",
"git add"
],
"src/*/!(mochitest)**/*.js": [
"prettier",
"git add"
],
"src/*/!(mochitest)*/**/*.js": [
"prettier",
"git add"
]
"*.js": ["prettier", "git add"],
"src/*.js": ["prettier", "git add"],
"src/*/*.js": ["prettier", "git add"],
"src/*/!(mochitest)**/*.js": ["prettier", "git add"],
"src/*/!(mochitest)*/**/*.js": ["prettier", "git add"]
},
"jest": {
"rootDir": "src",
"testMatch": [
"**/tests/**/*.js"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/helpers/",
"/fixtures/"
],
"transformIgnorePatterns": [
"node_modules/(?!devtools-)"
],
"setupFiles": [
"<rootDir>/test/tests-setup.js",
"jest-localstorage-mock"
],
"testMatch": ["**/tests/**/*.js"],
"testPathIgnorePatterns": ["/node_modules/", "/helpers/", "/fixtures/"],
"transformIgnorePatterns": ["node_modules/(?!devtools-)"],
"setupFiles": ["<rootDir>/test/tests-setup.js", "jest-localstorage-mock"],
"snapshotSerializers": [
"jest-serializer-babel-ast",
"enzyme-to-json/serializer"
Expand Down
52 changes: 39 additions & 13 deletions src/actions/pause/fetchScopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,37 @@

import { getSource, getSelectedFrame, getFrameScope } from "../../selectors";
import { updateScopeBindings } from "../../utils/pause";
import { features } from "../../utils/prefs";
import { isGeneratedId } from "devtools-source-map";
import { loadSourceText } from "../sources/loadSourceText";

import type { ThunkArgs } from "../types";
import type { Scope, Frame } from "debugger-html";

function mapScopes(scopes: Scope, frame: Frame) {
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
const mappedScopes = await updateScopeBindings(
scopes,
frame.generatedLocation,
frame.location,
{
async getLocationScopes(location, astScopes) {
return sourceMaps.getLocationScopes(location, astScopes);
},
async loadSourceText(sourceId) {
const source = getSource(getState(), sourceId).toJS();
await dispatch(loadSourceText(source));
}
}
);

dispatch({
type: "MAP_SCOPES",
frame,
scopes: mappedScopes
});
};
}

export function fetchScopes() {
return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
Expand All @@ -25,29 +53,27 @@ export function fetchScopes() {
scopes
});

const sourceRecord = getSource(
const generatedSourceRecord = getSource(
getState(),
frame.generatedLocation.sourceId
);

if (sourceRecord.get("isWasm")) {
if (generatedSourceRecord.get("isWasm")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this down below add_scopes. can we move this to a different PR? b/c wasm is different and scary for some :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
}

if (isGeneratedId(frame.location.sourceId)) {
const sourceRecord = getSource(getState(), frame.location.sourceId);

if (sourceRecord.get("isPrettyPrinted")) {
return;
}

const mappedScopes = await updateScopeBindings(
scopes,
frame.generatedLocation,
sourceMaps
);
if (isGeneratedId(frame.location.sourceId)) {
return;
}

dispatch({
type: "MAP_SCOPES",
frame,
scopes: mappedScopes
});
if (features.mapScopes) {
dispatch(mapScopes(scopes, frame));
}
};
}
4 changes: 2 additions & 2 deletions src/actions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ export type ProjectTextSearchAction = {
type: "ADD_SEARCH_RESULT",
result: ProjectTextSearchResult
} & {
type: "CLEAR_QUERY"
};
type: "CLEAR_QUERY"
};

export type FileTextSearchAction =
| {
Expand Down
4 changes: 2 additions & 2 deletions src/components/SecondaryPanes/Scopes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
getFrameScope,
getPause
} from "../../selectors";
import { getScopes } from "../../utils/scopes";
import { getScopes } from "../../utils/pause/scopes";

import { ObjectInspector } from "devtools-reps";
import type { Pause, LoadedObject } from "debugger-html";
import type { NamedValue } from "../../utils/scopes";
import type { NamedValue } from "../../utils/pause/scopes/types";

import "./Scopes.css";

Expand Down
6 changes: 6 additions & 0 deletions src/test/mochitest/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ support-files =
examples/sourcemaps2/main.min.js
examples/sourcemaps2/main.js
examples/sourcemaps2/main.js.map
examples/sourcemaps3/bundle.js
examples/sourcemaps3/bundle.js.map
examples/sourcemaps3/sorted.js
examples/sourcemaps3/test.js
examples/wasm-sourcemaps/average.js
examples/wasm-sourcemaps/average.wasm
examples/wasm-sourcemaps/average.wasm.map
Expand All @@ -35,6 +39,7 @@ support-files =
examples/doc-minified2.html
examples/doc-sourcemaps.html
examples/doc-sourcemaps2.html
examples/doc-sourcemaps3.html
examples/doc-sourcemap-bogus.html
examples/doc-sources.html
examples/doc-return-values.html
Expand Down Expand Up @@ -104,6 +109,7 @@ skip-if = true # regular failures during release in Bug 1415300
[browser_dbg-sourcemaps.js]
[browser_dbg-sourcemaps-reloading.js]
[browser_dbg-sourcemaps2.js]
[browser_dbg-sourcemaps3.js]
[browser_dbg-sourcemaps-bogus.js]
[browser_dbg-sources.js]
[browser_dbg-tabs.js]
Expand Down
86 changes: 86 additions & 0 deletions src/test/mochitest/browser_dbg-sourcemaps3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests loading sourcemapped sources, setting breakpoints, and
// inspecting restored scopes.

function toggleNode(dbg, index) {
clickElement(dbg, "scopeNode", index);
}

function getLabel(dbg, index) {
return findElement(dbg, "scopeNode", index).innerText;
}

function hasScopeNode(dbg, index) {
return !!findElement(dbg, "scopeNode", index);
}

async function waitForScopeNode(dbg, index) {
const selector = getSelector("scopeNode", index);
return waitForElement(dbg, selector);
}

// This source map does not have source contents, so it's fetched separately
add_task(async function() {
// NOTE: the CORS call makes the test run times inconsistent
requestLongerTimeout(2);

const dbg = await initDebugger("doc-sourcemaps3.html");
const { selectors: { getBreakpoint, getBreakpoints }, getState } = dbg;

toggleScopes(dbg);

await waitForSources(dbg, "bundle.js", "sorted.js", "test.js");

ok(true, "Original sources exist");
const sortedSrc = findSource(dbg, "sorted.js");

await selectSource(dbg, sortedSrc);

// Test that breakpoint is not off by a line.
await addBreakpoint(dbg, sortedSrc, 9);
is(getBreakpoints(getState()).size, 1, "One breakpoint exists");
ok(
getBreakpoint(getState(), { sourceId: sortedSrc.id, line: 9, column: 4 }),
"Breakpoint has correct line"
);

invokeInTab("test");

await waitForPaused(dbg);
assertPausedLocation(dbg);

await waitForDispatch(dbg, "MAP_SCOPES");

is(getLabel(dbg, 1), "Block");
is(getLabel(dbg, 2), "<this>");
is(getLabel(dbg, 3), "na");
is(getLabel(dbg, 4), "nb");

is(getLabel(dbg, 5), "Block");
is(
hasScopeNode(dbg, 8) && !hasScopeNode(dbg, 9),
true,
"scope count before expand"
);
toggleNode(dbg, 5);

await waitForScopeNode(dbg, 9);

is(getLabel(dbg, 6), "ma");
is(getLabel(dbg, 7), "mb");

is(
hasScopeNode(dbg, 10) && !hasScopeNode(dbg, 11),
true,
"scope count before expand"
);
toggleNode(dbg, 8);

await waitForScopeNode(dbg, 11);

is(getLabel(dbg, 9), "a");
is(getLabel(dbg, 10), "arguments");
is(getLabel(dbg, 11), "b");
});
13 changes: 13 additions & 0 deletions src/test/mochitest/examples/doc-sourcemaps3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>

<body>

<script type="text/javascript" src="sourcemaps3/bundle.js"></script>
<button onclick="test()">Test</button>
</body>

</html>
1 change: 1 addition & 0 deletions src/test/mochitest/examples/sourcemaps3/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": [ "es2015" ] }
2 changes: 2 additions & 0 deletions src/test/mochitest/examples/sourcemaps3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
2 changes: 2 additions & 0 deletions src/test/mochitest/examples/sourcemaps3/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading