зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1815500 - [devtools] Ensure using createLocation in all places where we create a location. r=bomsy,perftest-reviewers,devtools-reviewers,AlexandruIonescu
We were missing a few places around SourceMapLoader which creates location objects without using debugger's createLocation helper. This doesn't help ensure all location are the same. This will later be useful to assert that all location have source/sourceActor attributes. Differential Revision: https://phabricator.services.mozilla.com/D170668
This commit is contained in:
Родитель
13a1dc1ac4
Коммит
af72caf60d
|
@ -13,6 +13,7 @@ import {
|
|||
makeSource,
|
||||
waitForState,
|
||||
} from "../../../utils/test-head";
|
||||
import { createLocation } from "../../../utils/location";
|
||||
|
||||
const { getInScopeLines } = selectors;
|
||||
|
||||
|
@ -44,10 +45,13 @@ describe("getInScopeLine", () => {
|
|||
await dispatch(actions.newGeneratedSource(makeSource("scopes.js")));
|
||||
|
||||
await dispatch(
|
||||
actions.selectLocation(selectors.getContext(getState()), {
|
||||
sourceId: "scopes.js",
|
||||
line: 5,
|
||||
})
|
||||
actions.selectLocation(
|
||||
selectors.getContext(getState()),
|
||||
createLocation({
|
||||
sourceId: "scopes.js",
|
||||
line: 5,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
await dispatch(
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
import { makeBreakpointId } from "../../utils/breakpoint";
|
||||
import { memoizeableAction } from "../../utils/memoizableAction";
|
||||
import { fulfilled } from "../../utils/async-value";
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
async function mapLocations(generatedLocations, { sourceMapLoader }) {
|
||||
if (!generatedLocations.length) {
|
||||
|
@ -29,7 +30,7 @@ async function mapLocations(generatedLocations, { sourceMapLoader }) {
|
|||
);
|
||||
|
||||
return originalLocations.map((location, index) => ({
|
||||
location,
|
||||
location: createLocation(location),
|
||||
generatedLocation: generatedLocations[index],
|
||||
}));
|
||||
}
|
||||
|
@ -68,12 +69,14 @@ function convertToList(results, source) {
|
|||
|
||||
for (const line in results) {
|
||||
for (const column of results[line]) {
|
||||
positions.push({
|
||||
line: Number(line),
|
||||
column,
|
||||
sourceId: id,
|
||||
sourceUrl: url,
|
||||
});
|
||||
positions.push(
|
||||
createLocation({
|
||||
line: Number(line),
|
||||
column,
|
||||
sourceId: id,
|
||||
sourceUrl: url,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import { PROMISE } from "../utils/middleware/promise";
|
||||
import { asyncStore } from "../../utils/prefs";
|
||||
import { createLocation } from "../../utils/location";
|
||||
import {
|
||||
getBreakpointsList,
|
||||
getXHRBreakpoints,
|
||||
|
@ -226,11 +227,14 @@ export function toggleBreakpointAtLine(cx, line) {
|
|||
return dispatch(removeBreakpoint(cx, bp));
|
||||
}
|
||||
return dispatch(
|
||||
addBreakpoint(cx, {
|
||||
sourceId: selectedSource.id,
|
||||
sourceUrl: selectedSource.url,
|
||||
line,
|
||||
})
|
||||
addBreakpoint(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: selectedSource.id,
|
||||
sourceUrl: selectedSource.url,
|
||||
line,
|
||||
})
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -248,12 +252,12 @@ export function addBreakpointAtLine(
|
|||
if (!source) {
|
||||
return null;
|
||||
}
|
||||
const breakpointLocation = {
|
||||
const breakpointLocation = createLocation({
|
||||
sourceId: source.id,
|
||||
sourceUrl: source.url,
|
||||
column: undefined,
|
||||
line,
|
||||
};
|
||||
});
|
||||
|
||||
const options = {};
|
||||
if (shouldLog) {
|
||||
|
|
|
@ -9,6 +9,7 @@ Array [
|
|||
"generatedLocation": Object {
|
||||
"column": 1,
|
||||
"line": 2,
|
||||
"sourceActorId": null,
|
||||
"sourceId": "a",
|
||||
"sourceUrl": "http://localhost:8000/examples/a",
|
||||
},
|
||||
|
@ -16,6 +17,7 @@ Array [
|
|||
"location": Object {
|
||||
"column": 1,
|
||||
"line": 2,
|
||||
"sourceActorId": null,
|
||||
"sourceId": "a",
|
||||
"sourceUrl": "http://localhost:8000/examples/a",
|
||||
},
|
||||
|
@ -58,6 +60,7 @@ Array [
|
|||
"generatedLocation": Object {
|
||||
"column": 1,
|
||||
"line": 5,
|
||||
"sourceActorId": null,
|
||||
"sourceId": "a",
|
||||
"sourceUrl": "http://localhost:8000/examples/a",
|
||||
},
|
||||
|
@ -65,6 +68,7 @@ Array [
|
|||
"location": Object {
|
||||
"column": 1,
|
||||
"line": 5,
|
||||
"sourceActorId": null,
|
||||
"sourceId": "a",
|
||||
"sourceUrl": "http://localhost:8000/examples/a",
|
||||
},
|
||||
|
|
|
@ -44,6 +44,7 @@ describe("breakpoints", () => {
|
|||
const { dispatch, getState, cx } = createStore(mockClient({ "2": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
sourceActorId: null,
|
||||
line: 2,
|
||||
column: 1,
|
||||
sourceUrl: "http://localhost:8000/examples/a",
|
||||
|
@ -73,6 +74,7 @@ describe("breakpoints", () => {
|
|||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
sourceActorId: null,
|
||||
line: 5,
|
||||
column: 1,
|
||||
sourceUrl: "http://localhost:8000/examples/a",
|
||||
|
@ -98,6 +100,7 @@ describe("breakpoints", () => {
|
|||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
sourceActorId: null,
|
||||
line: 5,
|
||||
column: 1,
|
||||
sourceUrl: "http://localhost:8000/examples/a",
|
||||
|
@ -129,6 +132,7 @@ describe("breakpoints", () => {
|
|||
const { dispatch, getState, cx } = createStore(mockClient({ "5": [1] }));
|
||||
const loc1 = {
|
||||
sourceId: "a",
|
||||
sourceActorId: null,
|
||||
line: 5,
|
||||
column: 1,
|
||||
sourceUrl: "http://localhost:8000/examples/a",
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
getClosestBreakpointPosition,
|
||||
getBreakpoint,
|
||||
} from "../../selectors";
|
||||
import { createLocation } from "../../utils/location";
|
||||
import { addHiddenBreakpoint } from "../breakpoints";
|
||||
import { setBreakpointPositions } from "../breakpoints/breakpointPositions";
|
||||
|
||||
|
@ -45,11 +46,14 @@ export function continueToHere(cx, location) {
|
|||
// at the closest position
|
||||
if (!getBreakpoint(getState(), pauseLocation)) {
|
||||
await dispatch(
|
||||
addHiddenBreakpoint(cx, {
|
||||
sourceId: selectedSource.id,
|
||||
line: pauseLocation.line,
|
||||
column: pauseLocation.column,
|
||||
})
|
||||
addHiddenBreakpoint(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: selectedSource.id,
|
||||
line: pauseLocation.line,
|
||||
column: pauseLocation.column,
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import { isFrameBlackBoxed } from "../../utils/source";
|
|||
|
||||
import assert from "../../utils/assert";
|
||||
import { getOriginalLocation } from "../../utils/source-maps";
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
import { isGeneratedId } from "devtools/client/shared/source-map-loader/index";
|
||||
|
||||
|
@ -106,7 +107,7 @@ async function expandFrames(frames, sourceMapLoader, getState) {
|
|||
result.push({
|
||||
id,
|
||||
displayName: originalFrame.displayName,
|
||||
location: originalFrame.location,
|
||||
location: createLocation(originalFrame.location),
|
||||
index: frame.index,
|
||||
source: null,
|
||||
thread: frame.thread,
|
||||
|
|
|
@ -170,7 +170,6 @@ describe("pause", () => {
|
|||
column: 0,
|
||||
line: 1,
|
||||
sourceId: "foo",
|
||||
sourceActorId: "foo-1-actor",
|
||||
},
|
||||
id: mockFrameId,
|
||||
location: {
|
||||
|
@ -178,6 +177,7 @@ describe("pause", () => {
|
|||
line: 1,
|
||||
sourceId: "foo",
|
||||
sourceActorId: "foo-1-actor",
|
||||
sourceUrl: "",
|
||||
},
|
||||
originalDisplayName: "foo",
|
||||
scope: {
|
||||
|
@ -255,6 +255,7 @@ describe("pause", () => {
|
|||
line: 3,
|
||||
sourceActorId: "foo-original-1-actor",
|
||||
sourceId: "foo-original",
|
||||
sourceUrl: "",
|
||||
},
|
||||
originalDisplayName: "fooOriginal",
|
||||
scope: { bindings: { arguments: [], variables: {} } },
|
||||
|
@ -333,6 +334,7 @@ describe("pause", () => {
|
|||
line: 1,
|
||||
sourceActorId: "foo-wasm-1-actor",
|
||||
sourceId: "foo-wasm/originalSource",
|
||||
sourceUrl: "",
|
||||
},
|
||||
originalDisplayName: "fooBar",
|
||||
originalVariables: undefined,
|
||||
|
@ -352,7 +354,9 @@ describe("pause", () => {
|
|||
location: {
|
||||
column: 14,
|
||||
line: 2,
|
||||
sourceActorId: null,
|
||||
sourceId: "foo-wasm/originalSource",
|
||||
sourceUrl: "",
|
||||
},
|
||||
originalDisplayName: "barZoo",
|
||||
originalVariables: undefined,
|
||||
|
|
|
@ -139,12 +139,17 @@ function checkSelectedSource(cx, sourceId) {
|
|||
}
|
||||
|
||||
await dispatch(
|
||||
selectLocation(cx, {
|
||||
sourceId: source.id,
|
||||
line:
|
||||
typeof pendingLocation.line === "number" ? pendingLocation.line : 0,
|
||||
column: pendingLocation.column,
|
||||
})
|
||||
selectLocation(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: source.id,
|
||||
line:
|
||||
typeof pendingLocation.line === "number"
|
||||
? pendingLocation.line
|
||||
: 0,
|
||||
column: pendingLocation.column,
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
import assert from "../../utils/assert";
|
||||
import { recordEvent } from "../../utils/telemetry";
|
||||
import { updateBreakpointsForNewPrettyPrintedSource } from "../breakpoints";
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
import {
|
||||
getPrettySourceURL,
|
||||
|
@ -112,7 +113,10 @@ function selectPrettyLocation(cx, prettySource) {
|
|||
location = await getOriginalLocation(location, thunkArgs);
|
||||
|
||||
return dispatch(
|
||||
selectSpecificLocation(cx, { ...location, sourceId: prettySource.id })
|
||||
selectSpecificLocation(
|
||||
cx,
|
||||
createLocation({ ...location, sourceId: prettySource.id })
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
getSelectedLocation,
|
||||
getSymbols,
|
||||
} from "../../../selectors/";
|
||||
import { createLocation } from "../../../utils/location";
|
||||
|
||||
import { mockCommandClient } from "../../tests/helpers/mockCommandClient";
|
||||
|
||||
|
@ -50,7 +51,10 @@ describe("sources", () => {
|
|||
|
||||
const cx = selectors.getThreadContext(getState());
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "foo1", line: 1, column: 5 })
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo1", line: 1, column: 5 })
|
||||
)
|
||||
);
|
||||
|
||||
const selectedSource = getSelectedSource(getState());
|
||||
|
@ -213,7 +217,10 @@ describe("sources", () => {
|
|||
);
|
||||
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: baseSource.id, line: 1 })
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: baseSource.id, line: 1 })
|
||||
)
|
||||
);
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
|
@ -248,7 +255,10 @@ describe("sources", () => {
|
|||
actions.newGeneratedSource(makeSource("foo.js"))
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: fooSource.id, line: 1 })
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: fooSource.id, line: 1 })
|
||||
)
|
||||
);
|
||||
|
||||
const selected = getSelectedLocation(getState());
|
||||
|
@ -277,10 +287,13 @@ describe("sources", () => {
|
|||
await dispatch(actions.selectSource(cx, baseSources[0]));
|
||||
|
||||
await dispatch(
|
||||
actions.selectSpecificLocation(cx, {
|
||||
sourceId: baseSources[0].id,
|
||||
line: 1,
|
||||
})
|
||||
actions.selectSpecificLocation(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: baseSources[0].id,
|
||||
line: 1,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const selected = getSelectedLocation(getState());
|
||||
|
|
|
@ -14,11 +14,14 @@ Object {
|
|||
"generatedLocation": Object {
|
||||
"column": 2,
|
||||
"line": 5,
|
||||
"sourceActorId": null,
|
||||
"sourceId": undefined,
|
||||
"sourceUrl": "http://localhost:8000/examples/bar.js",
|
||||
},
|
||||
"location": Object {
|
||||
"column": 2,
|
||||
"line": 5,
|
||||
"sourceActorId": null,
|
||||
"sourceId": "",
|
||||
"sourceUrl": "http://localhost:8000/examples/bar.js",
|
||||
},
|
||||
|
|
|
@ -2,20 +2,22 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { createLocation } from "../../../utils/location";
|
||||
|
||||
export function mockPendingBreakpoint(overrides = {}) {
|
||||
const { sourceUrl, line, column, condition, disabled, hidden } = overrides;
|
||||
return {
|
||||
location: {
|
||||
location: createLocation({
|
||||
sourceId: "",
|
||||
sourceUrl: sourceUrl || "http://localhost:8000/examples/bar.js",
|
||||
line: line || 5,
|
||||
column: column || 1,
|
||||
},
|
||||
generatedLocation: {
|
||||
}),
|
||||
generatedLocation: createLocation({
|
||||
sourceUrl: sourceUrl || "http://localhost:8000/examples/bar.js",
|
||||
line: line || 5,
|
||||
column: column || 1,
|
||||
},
|
||||
}),
|
||||
astLocation: {
|
||||
name: undefined,
|
||||
offset: {
|
||||
|
@ -36,18 +38,18 @@ export function generateBreakpoint(filename, line = 5, column = 0) {
|
|||
id: "breakpoint",
|
||||
originalText: "",
|
||||
text: "",
|
||||
location: {
|
||||
location: createLocation({
|
||||
sourceUrl: `http://localhost:8000/examples/${filename}`,
|
||||
sourceId: `${filename}`,
|
||||
line,
|
||||
column,
|
||||
},
|
||||
generatedLocation: {
|
||||
}),
|
||||
generatedLocation: createLocation({
|
||||
sourceUrl: `http://localhost:8000/examples/${filename}`,
|
||||
sourceId: filename,
|
||||
line,
|
||||
column,
|
||||
},
|
||||
}),
|
||||
astLocation: undefined,
|
||||
options: {
|
||||
condition: "",
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
makeSource,
|
||||
} from "../../utils/test-head";
|
||||
const { getSelectedSource, getSourceTabs } = selectors;
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
import { mockCommandClient } from "./helpers/mockCommandClient";
|
||||
|
||||
|
@ -19,7 +20,12 @@ describe("closing tabs", () => {
|
|||
const fooSource = await dispatch(
|
||||
actions.newGeneratedSource(makeSource("foo.js"))
|
||||
);
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
|
@ -33,8 +39,18 @@ describe("closing tabs", () => {
|
|||
actions.newGeneratedSource(makeSource("foo.js"))
|
||||
);
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bar.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bar.js", line: 1 })
|
||||
)
|
||||
);
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
|
@ -48,7 +64,12 @@ describe("closing tabs", () => {
|
|||
const fooSource = await dispatch(
|
||||
actions.newGeneratedSource(makeSource("foo.js"))
|
||||
);
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
dispatch(actions.closeTab(cx, fooSource));
|
||||
|
||||
expect(getSelectedSource(getState())).toBe(undefined);
|
||||
|
@ -62,8 +83,18 @@ describe("closing tabs", () => {
|
|||
const barSource = await dispatch(
|
||||
actions.newGeneratedSource(makeSource("bar.js"))
|
||||
);
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bar.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(actions.closeTab(cx, barSource));
|
||||
|
||||
const selected = getSelectedSource(getState());
|
||||
|
@ -77,10 +108,23 @@ describe("closing tabs", () => {
|
|||
await dispatch(actions.newGeneratedSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bazz.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "bazz.js", line: 1 })
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bar.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bazz.js", line: 1 })
|
||||
)
|
||||
);
|
||||
|
||||
const tabs = [
|
||||
|
@ -100,10 +144,23 @@ describe("closing tabs", () => {
|
|||
await dispatch(actions.newGeneratedSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bar.js")));
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bazz.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(cx, { sourceId: "bazz.js", line: 1 })
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bar.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bazz.js", line: 1 })
|
||||
)
|
||||
);
|
||||
const tabs = [
|
||||
"http://localhost:8000/examples/bar.js",
|
||||
|
@ -121,8 +178,18 @@ describe("closing tabs", () => {
|
|||
|
||||
await dispatch(actions.newGeneratedSource(makeSource("foo.js")));
|
||||
await dispatch(actions.newGeneratedSource(makeSource("bar.js")));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "foo.js", line: 1 }));
|
||||
await dispatch(actions.selectLocation(cx, { sourceId: "bar.js", line: 1 }));
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "foo.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: "bar.js", line: 1 })
|
||||
)
|
||||
);
|
||||
await dispatch(
|
||||
actions.closeTabs(cx, [
|
||||
"http://localhost:8000/examples/foo.js",
|
||||
|
|
|
@ -8,6 +8,7 @@ import PropTypes from "prop-types";
|
|||
import { toEditorPosition, getTokenEnd, hasDocument } from "../../utils/editor";
|
||||
|
||||
import { getIndentation } from "../../utils/indentation";
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
export default class Exception extends PureComponent {
|
||||
exceptionLine;
|
||||
|
@ -58,11 +59,11 @@ export default class Exception extends PureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
const location = {
|
||||
const location = createLocation({
|
||||
column: columnNumber - 1,
|
||||
line: lineNumber,
|
||||
sourceId: selectedSourceId,
|
||||
};
|
||||
});
|
||||
|
||||
const { line, column } = toEditorPosition(location);
|
||||
const lineText = doc.getLine(line);
|
||||
|
|
|
@ -10,6 +10,7 @@ import { connect } from "../../utils/connect";
|
|||
import classnames from "classnames";
|
||||
|
||||
import { getLineText } from "./../../utils/source";
|
||||
import { createLocation } from "./../../utils/location";
|
||||
import { features } from "../../utils/prefs";
|
||||
import { getIndentation } from "../../utils/indentation";
|
||||
|
||||
|
@ -432,7 +433,7 @@ class Editor extends PureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
const location = { line, column: undefined, sourceId };
|
||||
const location = createLocation({ line, column: undefined, sourceId });
|
||||
|
||||
if (target.classList.contains("CodeMirror-linenumber")) {
|
||||
const lineText = getLineText(
|
||||
|
|
|
@ -12,6 +12,7 @@ const classnames = require("classnames");
|
|||
import { containsPosition, positionAfter } from "../../utils/ast";
|
||||
import { copyToTheClipboard } from "../../utils/clipboard";
|
||||
import { findFunctionText } from "../../utils/function";
|
||||
import { createLocation } from "../../utils/location";
|
||||
|
||||
import actions from "../../actions";
|
||||
import {
|
||||
|
@ -130,11 +131,14 @@ export class Outline extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
selectLocation(cx, {
|
||||
sourceId: selectedSource.id,
|
||||
line: selectedItem.location.start.line,
|
||||
column: selectedItem.location.start.column,
|
||||
});
|
||||
selectLocation(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: selectedSource.id,
|
||||
line: selectedItem.location.start.line,
|
||||
column: selectedItem.location.start.column,
|
||||
})
|
||||
);
|
||||
|
||||
this.setState({ focusedItem: selectedItem });
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import classnames from "classnames";
|
|||
import actions from "../actions";
|
||||
|
||||
import { getEditor } from "../utils/editor";
|
||||
import { createLocation } from "../utils/location";
|
||||
|
||||
import { statusType } from "../reducers/project-text-search";
|
||||
import { getRelativePath } from "../utils/sources-tree/utils";
|
||||
|
@ -118,11 +119,14 @@ export class ProjectSearch extends Component {
|
|||
isProjectSearchEnabled = () => this.props.activeSearch === "project";
|
||||
|
||||
selectMatchItem = matchItem => {
|
||||
this.props.selectSpecificLocation(this.props.cx, {
|
||||
sourceId: matchItem.sourceId,
|
||||
line: matchItem.line,
|
||||
column: matchItem.column,
|
||||
});
|
||||
this.props.selectSpecificLocation(
|
||||
this.props.cx,
|
||||
createLocation({
|
||||
sourceId: matchItem.sourceId,
|
||||
line: matchItem.line,
|
||||
column: matchItem.column,
|
||||
})
|
||||
);
|
||||
this.props.doSearchForHighlight(
|
||||
this.state.inputValue,
|
||||
getEditor(),
|
||||
|
|
|
@ -7,6 +7,7 @@ import PropTypes from "prop-types";
|
|||
import { connect } from "../utils/connect";
|
||||
import fuzzyAldrin from "fuzzaldrin-plus";
|
||||
import { basename } from "../utils/path";
|
||||
import { createLocation } from "../utils/location";
|
||||
|
||||
const { throttle } = require("devtools/shared/throttle");
|
||||
|
||||
|
@ -285,12 +286,11 @@ export class QuickOpenModal extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
highlightLineRange({
|
||||
...(item.location != null
|
||||
highlightLineRange(
|
||||
item.location != null
|
||||
? { start: item.location.start.line, end: item.location.end.line }
|
||||
: {}),
|
||||
sourceId: selectedSource.id,
|
||||
});
|
||||
: {}
|
||||
);
|
||||
};
|
||||
|
||||
traverseResults = e => {
|
||||
|
@ -312,12 +312,14 @@ export class QuickOpenModal extends Component {
|
|||
|
||||
if (location != null) {
|
||||
const selectedSourceId = selectedSource ? selectedSource.id : "";
|
||||
const sourceId = location.sourceId ? location.sourceId : selectedSourceId;
|
||||
selectSpecificLocation(cx, {
|
||||
sourceId,
|
||||
line: location.line,
|
||||
column: location.column,
|
||||
});
|
||||
selectSpecificLocation(
|
||||
cx,
|
||||
createLocation({
|
||||
sourceId: location.sourceId || selectedSourceId,
|
||||
line: location.line,
|
||||
column: location.column,
|
||||
})
|
||||
);
|
||||
this.closeModal();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -69,7 +69,10 @@ describe("Outline", () => {
|
|||
listItem.simulate("click");
|
||||
expect(selectLocation).toHaveBeenCalledWith(mockcx, {
|
||||
line: startLine,
|
||||
column: undefined,
|
||||
sourceId,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -203,7 +206,10 @@ describe("Outline", () => {
|
|||
|
||||
expect(props.selectLocation).toHaveBeenCalledWith(mockcx, {
|
||||
line: 24,
|
||||
column: undefined,
|
||||
sourceId,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -227,6 +227,8 @@ describe("ProjectSearch", () => {
|
|||
shortcuts.dispatch("Enter");
|
||||
expect(selectSpecificLocation).toHaveBeenCalledWith(mockcx, {
|
||||
sourceId: "some-target/source42",
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
line: 3,
|
||||
column: 30,
|
||||
});
|
||||
|
|
|
@ -339,6 +339,8 @@ describe("QuickOpenModal", () => {
|
|||
column: 12,
|
||||
line: 34,
|
||||
sourceId: "",
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -362,6 +364,8 @@ describe("QuickOpenModal", () => {
|
|||
column: 12,
|
||||
line: 34,
|
||||
sourceId,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -470,6 +474,8 @@ describe("QuickOpenModal", () => {
|
|||
column: undefined,
|
||||
sourceId: id,
|
||||
line: 0,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
expect(props.setQuickOpenQuery).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -500,6 +506,8 @@ describe("QuickOpenModal", () => {
|
|||
column: undefined,
|
||||
line: 0,
|
||||
sourceId: "",
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
expect(props.setQuickOpenQuery).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -530,6 +538,8 @@ describe("QuickOpenModal", () => {
|
|||
column: 4,
|
||||
line: 3,
|
||||
sourceId: id,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
expect(props.setQuickOpenQuery).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -632,7 +642,6 @@ describe("QuickOpenModal", () => {
|
|||
expect(wrapper.state().selectedIndex).toEqual(0);
|
||||
expect(props.highlightLineRange).toHaveBeenCalledWith({
|
||||
end: 3,
|
||||
sourceId,
|
||||
start: 1,
|
||||
});
|
||||
});
|
||||
|
@ -688,9 +697,7 @@ describe("QuickOpenModal", () => {
|
|||
wrapper.find("SearchInput").simulate("keydown", event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state().selectedIndex).toEqual(0);
|
||||
expect(props.highlightLineRange).toHaveBeenCalledWith({
|
||||
sourceId: "sourceId",
|
||||
});
|
||||
expect(props.highlightLineRange).toHaveBeenCalledWith({});
|
||||
});
|
||||
|
||||
it(
|
||||
|
|
|
@ -12,6 +12,7 @@ import { createEditor } from "./create-editor";
|
|||
import { findNext, findPrev } from "./source-search";
|
||||
|
||||
import { isWasm, lineToWasmOffset, wasmOffsetToLine } from "../wasm";
|
||||
import { createLocation } from "../location";
|
||||
|
||||
let editor;
|
||||
|
||||
|
@ -196,11 +197,11 @@ export function getSourceLocationFromMouseEvent({ codeMirror }, source, e) {
|
|||
});
|
||||
const sourceId = source.id;
|
||||
|
||||
return {
|
||||
return createLocation({
|
||||
sourceId,
|
||||
line: fromEditorLine(sourceId, line, isWasm(sourceId)),
|
||||
column: isWasm(sourceId) ? 0 : ch + 1,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function forEachLine(codeMirror, iter) {
|
||||
|
|
|
@ -166,6 +166,8 @@ describe("getSourceLocationFromMouseEvent", () => {
|
|||
sourceId: "test-123",
|
||||
line: 7,
|
||||
column: 31,
|
||||
sourceActorId: null,
|
||||
sourceUrl: "",
|
||||
});
|
||||
expect(editor.codeMirror.coordsChar).toHaveBeenCalledWith({
|
||||
left: 30,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
|
||||
import { getSource, getLocationSource } from "../selectors";
|
||||
import { createLocation } from "./location";
|
||||
|
||||
/**
|
||||
* For any location, return the matching generated location.
|
||||
|
@ -24,7 +25,7 @@ export async function getGeneratedLocation(location, thunkArgs) {
|
|||
}
|
||||
|
||||
const { sourceMapLoader, getState } = thunkArgs;
|
||||
const { line, sourceId, column } = await sourceMapLoader.getGeneratedLocation(
|
||||
const { sourceId, line, column } = await sourceMapLoader.getGeneratedLocation(
|
||||
location
|
||||
);
|
||||
|
||||
|
@ -33,12 +34,12 @@ export async function getGeneratedLocation(location, thunkArgs) {
|
|||
throw new Error(`Could not find generated source ${sourceId}`);
|
||||
}
|
||||
|
||||
return {
|
||||
line,
|
||||
return createLocation({
|
||||
sourceId,
|
||||
column: column === 0 ? undefined : column,
|
||||
sourceUrl: generatedSource.url,
|
||||
};
|
||||
line,
|
||||
column: column === 0 ? undefined : column,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getOriginalLocation(generatedLocation, thunkArgs) {
|
||||
|
@ -46,7 +47,10 @@ export async function getOriginalLocation(generatedLocation, thunkArgs) {
|
|||
return location;
|
||||
}
|
||||
const { sourceMapLoader } = thunkArgs;
|
||||
return sourceMapLoader.getOriginalLocation(generatedLocation);
|
||||
const originalLocation = await sourceMapLoader.getOriginalLocation(
|
||||
generatedLocation
|
||||
);
|
||||
return createLocation(originalLocation);
|
||||
}
|
||||
|
||||
export async function getMappedLocation(location, thunkArgs) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
import configureStore from "../actions/utils/create-store";
|
||||
import sourceQueue from "../utils/source-queue";
|
||||
import { setupCreate } from "../client/firefox/create";
|
||||
import { createLocation } from "./location";
|
||||
|
||||
// Import the internal module used by the source-map worker
|
||||
// as node doesn't have Web Worker support and require path mapping
|
||||
|
@ -85,7 +86,7 @@ function makeFrame({ id, sourceId, thread }, opts = {}) {
|
|||
return {
|
||||
id,
|
||||
scope: { bindings: { variables: {}, arguments: [] } },
|
||||
location: { sourceId, line: 4 },
|
||||
location: createLocation({ sourceId, line: 4 }),
|
||||
thread: thread || "FakeThread",
|
||||
...opts,
|
||||
};
|
||||
|
|
|
@ -489,7 +489,7 @@ add_task(async function testFailingHtmlSource() {
|
|||
const source = findSource(dbg, "200-then-connection-reset.html");
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: source.id },
|
||||
createLocation({ sourceId: source.id }),
|
||||
{ keepContext: false }
|
||||
);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ add_task(async function() {
|
|||
// as we aren't fetching any source.
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: source.id },
|
||||
createLocation({ sourceId: source.id }),
|
||||
{ keepContext: false }
|
||||
);
|
||||
is(getCM(dbg).getValue(), `Please refresh to debug this module`);
|
||||
|
@ -112,7 +112,7 @@ add_task(async function() {
|
|||
// (getSymbols(source) selector will be false)
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: binarySource.id },
|
||||
createLocation({ sourceId: binarySource.id }),
|
||||
{ keepContext: false }
|
||||
);
|
||||
|
||||
|
@ -130,7 +130,7 @@ add_task(async function() {
|
|||
info("Reselect the binary source");
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: binarySource.id },
|
||||
createLocation({ sourceId: binarySource.id }),
|
||||
{ keepContext: false }
|
||||
);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ add_task(async function() {
|
|||
|
||||
await dbg.actions.addBreakpoint(
|
||||
getContext(dbg),
|
||||
{ line: 5, sourceId: source.id },
|
||||
createLocation({ line: 5, sourceId: source.id }),
|
||||
{ logValue: "`value: ${JSON.stringify(test)}`", requiresMapping: true }
|
||||
);
|
||||
await waitForBreakpoint(dbg, "test.js", 5);
|
||||
|
|
|
@ -25,7 +25,7 @@ add_task(async function() {
|
|||
|
||||
await dbg.actions.addBreakpoint(
|
||||
getContext(dbg),
|
||||
{ line: 8, sourceId: source.id },
|
||||
createLocation({ line: 8, sourceId: source.id }),
|
||||
{ logValue: "'a', 'b', 'c'" }
|
||||
);
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ const asyncStorage = require("devtools/shared/async-storage");
|
|||
const {
|
||||
getSelectedLocation,
|
||||
} = require("devtools/client/debugger/src/utils/selected-location");
|
||||
const {
|
||||
createLocation,
|
||||
} = require("devtools/client/debugger/src/utils/location");
|
||||
|
||||
const {
|
||||
resetSchemaVersion,
|
||||
|
@ -705,10 +708,12 @@ function findSourceContent(dbg, url, opts) {
|
|||
if (!source) {
|
||||
return null;
|
||||
}
|
||||
const content = dbg.selectors.getSettledSourceTextContent({
|
||||
sourceId: source.id,
|
||||
sourceActorId: null,
|
||||
});
|
||||
const content = dbg.selectors.getSettledSourceTextContent(
|
||||
createLocation({
|
||||
sourceId: source.id,
|
||||
sourceActorId: null,
|
||||
})
|
||||
);
|
||||
|
||||
if (!content) {
|
||||
return null;
|
||||
|
@ -732,10 +737,12 @@ function waitForLoadedSource(dbg, url) {
|
|||
const source = findSource(dbg, url, { silent: true });
|
||||
return (
|
||||
source &&
|
||||
dbg.selectors.getSettledSourceTextContent({
|
||||
sourceId: source.id,
|
||||
sourceActorId: null,
|
||||
})
|
||||
dbg.selectors.getSettledSourceTextContent(
|
||||
createLocation({
|
||||
sourceId: source.id,
|
||||
sourceActorId: null,
|
||||
})
|
||||
)
|
||||
);
|
||||
},
|
||||
"loaded source"
|
||||
|
@ -766,7 +773,7 @@ async function selectSource(dbg, url, line, column) {
|
|||
|
||||
await dbg.actions.selectLocation(
|
||||
getContext(dbg),
|
||||
{ sourceId: source.id, line, column },
|
||||
createLocation({ sourceId: source.id, line, column }),
|
||||
{ keepContext: false }
|
||||
);
|
||||
return waitForSelectedSource(dbg, url);
|
||||
|
@ -966,7 +973,7 @@ async function addBreakpoint(dbg, source, line, column, options) {
|
|||
const onBreakpoint = waitForDispatch(dbg.store, "SET_BREAKPOINT");
|
||||
await dbg.actions.addBreakpoint(
|
||||
getContext(dbg),
|
||||
{ sourceId, line, column },
|
||||
createLocation({ sourceId, line, column }),
|
||||
options
|
||||
);
|
||||
await onBreakpoint;
|
||||
|
@ -991,7 +998,12 @@ async function addBreakpointViaGutter(dbg, line) {
|
|||
function disableBreakpoint(dbg, source, line, column) {
|
||||
column =
|
||||
column || getFirstBreakpointColumn(dbg, { line, sourceId: source.id });
|
||||
const location = { sourceId: source.id, sourceUrl: source.url, line, column };
|
||||
const location = createLocation({
|
||||
sourceId: source.id,
|
||||
sourceUrl: source.url,
|
||||
line,
|
||||
column,
|
||||
});
|
||||
const bp = getBreakpointForLocation(dbg, location);
|
||||
return dbg.actions.disableBreakpoint(getContext(dbg), bp);
|
||||
}
|
||||
|
@ -1029,7 +1041,7 @@ async function loadAndAddBreakpoint(dbg, filename, line, column) {
|
|||
await addBreakpoint(dbg, source, line, column);
|
||||
|
||||
is(getBreakpointCount(), 1, "One breakpoint exists");
|
||||
if (!getBreakpoint({ sourceId: source.id, line, column })) {
|
||||
if (!getBreakpoint(createLocation({ sourceId: source.id, line, column }))) {
|
||||
const breakpoints = getBreakpointsMap();
|
||||
const id = Object.keys(breakpoints).pop();
|
||||
const loc = breakpoints[id].location;
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
"use strict";
|
||||
|
||||
const { openToolboxAndLog, reloadPageAndLog } = require("../head");
|
||||
const {
|
||||
createLocation,
|
||||
} = require("devtools/client/debugger/src/utils/location");
|
||||
|
||||
/*
|
||||
* These methods are used for working with debugger state changes in order
|
||||
|
@ -180,7 +183,7 @@ function selectSource(dbg, url) {
|
|||
const line = 1;
|
||||
const source = findSource(dbg, url);
|
||||
const cx = dbg.selectors.getContext(dbg.getState());
|
||||
dbg.actions.selectLocation(cx, { sourceId: source.id, line });
|
||||
dbg.actions.selectLocation(cx, createLocation({ sourceId: source.id, line }));
|
||||
return waitForState(
|
||||
dbg,
|
||||
state => {
|
||||
|
@ -257,10 +260,10 @@ exports.reloadDebuggerAndLog = reloadDebuggerAndLog;
|
|||
async function addBreakpoint(dbg, line, url) {
|
||||
dump(`add breakpoint\n`);
|
||||
const source = findSource(dbg, url);
|
||||
const location = {
|
||||
const location = createLocation({
|
||||
sourceId: source.id,
|
||||
line,
|
||||
};
|
||||
});
|
||||
|
||||
await selectSource(dbg, url);
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ module.exports = async function() {
|
|||
await evaluateInBrowserToolbox(consoleFront, [TEST_URL], async function(
|
||||
testUrl
|
||||
) {
|
||||
const {
|
||||
createLocation,
|
||||
} = require("devtools/client/debugger/src/utils/location");
|
||||
dump("Wait for debugger to initialize\n");
|
||||
const panel = await gToolbox.selectTool("jsdebugger");
|
||||
const { dbg } = panel.panelWin;
|
||||
|
@ -94,7 +97,10 @@ module.exports = async function() {
|
|||
|
||||
dump("Select this source\n");
|
||||
const cx = dbg.selectors.getContext(dbg.store.getState());
|
||||
dbg.actions.selectLocation(cx, { sourceId: source.id, line: 1 });
|
||||
dbg.actions.selectLocation(
|
||||
cx,
|
||||
createLocation({ sourceId: source.id, line: 1 })
|
||||
);
|
||||
await waitFor(() => {
|
||||
const source = dbg.selectors.getSelectedSource(dbg.store.getState());
|
||||
if (!source) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче