Skip to content

Commit e97e07b

Browse files
authored
[breakpoints] switch Breakpoint to a PureComponent (firefox-devtools#6398)
1 parent 7f6157a commit e97e07b

21 files changed

Lines changed: 730 additions & 602 deletions

File tree

src/actions/tests/__snapshots__/breakpoints.spec.js.snap renamed to src/actions/breakpoints/tests/__snapshots__/breakpoints.spec.js.snap

File renamed without changes.

src/actions/tests/breakpoints.spec.js renamed to src/actions/breakpoints/tests/breakpoints.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
actions,
99
makeSource,
1010
makeSourceRecord
11-
} from "../../utils/test-head";
11+
} from "../../../utils/test-head";
1212

1313
import {
1414
simulateCorrectThreadClient,
1515
simpleMockThreadClient
16-
} from "./helpers/threadClient.js";
16+
} from "../../tests/helpers/threadClient.js";
1717

1818
describe("breakpoints", () => {
1919
it("should add a breakpoint", async () => {

src/actions/navigation.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// @flow
66

7-
import { clearDocuments, removeEditor } from "../utils/editor";
7+
import { clearDocuments } from "../utils/editor";
88
import sourceQueue from "../utils/source-queue";
99
import { getSources } from "../reducers/sources";
1010
import { waitForMs } from "../utils/utils";
@@ -37,7 +37,6 @@ export function willNavigate(event: Object) {
3737
await sourceMaps.clearSourceMaps();
3838
clearWasmStates();
3939
clearDocuments();
40-
removeEditor();
4140
clearSymbols();
4241
clearASTs();
4342
clearScopes();

src/actions/sources/loadSourceText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const loadSourceHistogram = Services.telemetry.getHistogramById(
2323
async function loadSource(source: SourceRecord, { sourceMaps, client }) {
2424
const id = source.get("id");
2525
if (isOriginalId(id)) {
26-
return await sourceMaps.getOriginalSourceText(source.toJS());
26+
return sourceMaps.getOriginalSourceText(source.toJS());
2727
}
2828

2929
const response = await client.sourceContents(id);

src/actions/tests/ast.spec.js

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515

1616
import readFixture from "./helpers/readFixture";
1717
const {
18+
getSource,
1819
getSymbols,
1920
getEmptyLines,
2021
getOutOfScopeLocations,
@@ -27,38 +28,31 @@ import I from "immutable";
2728
import { prefs } from "../../utils/prefs";
2829

2930
const threadClient = {
30-
sourceContents: function(sourceId) {
31-
return new Promise((resolve, reject) =>
32-
resolve({
33-
source: sourceTexts[sourceId],
34-
contentType: "text/javascript"
35-
})
36-
);
37-
},
31+
sourceContents: async sourceId => ({
32+
source: sourceTexts[sourceId],
33+
contentType: "text/javascript"
34+
}),
3835
setPausePoints: async () => {},
3936
getFrameScopes: async () => {},
40-
evaluate: function(expression) {
41-
return new Promise((resolve, reject) =>
42-
resolve({ result: evaluationResult[expression] })
43-
);
44-
},
45-
evaluateExpressions: function(expressions) {
46-
return new Promise((resolve, reject) =>
47-
resolve(
48-
expressions.map(expression => ({
49-
result: evaluationResult[expression]
50-
}))
51-
)
52-
);
53-
}
37+
evaluate: async expression => ({ result: evaluationResult[expression] }),
38+
evaluateExpressions: async expressions =>
39+
expressions.map(expression => ({ result: evaluationResult[expression] }))
40+
};
41+
42+
const sourceMaps = {
43+
getOriginalSourceText: async ({ id }) => ({
44+
id,
45+
text: sourceTexts[id],
46+
contentType: "text/javascript"
47+
})
5448
};
5549

5650
const sourceTexts = {
5751
"base.js": "function base(boo) {}",
5852
"foo.js": "function base(boo) { return this.bazz; } outOfScope",
5953
"scopes.js": readFixture("scopes.js"),
60-
"reactComponent.js-original": readFixture("reactComponent.js"),
61-
"reactFuncComponent.js-original": readFixture("reactFuncComponent.js")
54+
"reactComponent.js/originalSource": readFixture("reactComponent.js"),
55+
"reactFuncComponent.js/originalSource": readFixture("reactFuncComponent.js")
6256
};
6357

6458
const evaluationResult = {
@@ -87,13 +81,15 @@ describe("ast", () => {
8781

8882
describe("setSourceMetaData", () => {
8983
it("should detect react components", async () => {
90-
const store = createStore(threadClient);
84+
const store = createStore(threadClient, {}, sourceMaps);
9185
const { dispatch, getState } = store;
9286
const source = makeOriginalSource("reactComponent.js");
9387

88+
await dispatch(actions.newSource(makeSource("reactComponent.js")));
89+
9490
await dispatch(actions.newSource(source));
9591

96-
await dispatch(actions.loadSourceText(I.Map({ id: source.id })));
92+
await dispatch(actions.loadSourceText(getSource(getState(), source.id)));
9793
await dispatch(actions.setSourceMetaData(source.id));
9894

9995
await waitForState(store, state => {
@@ -116,25 +112,6 @@ describe("ast", () => {
116112
const sourceMetaData = getSourceMetaData(getState(), base.id);
117113
expect(sourceMetaData.framework).toBe(undefined);
118114
});
119-
120-
it("should detect react func components", async () => {
121-
const store = createStore(threadClient);
122-
const { dispatch, getState } = store;
123-
const source = makeOriginalSource("reactFuncComponent.js");
124-
125-
await dispatch(actions.newSource(source));
126-
127-
await dispatch(actions.loadSourceText(I.Map({ id: source.id })));
128-
await dispatch(actions.setSourceMetaData(source.id));
129-
130-
await waitForState(store, state => {
131-
const metaData = getSourceMetaData(state, source.id);
132-
return metaData && metaData.framework;
133-
});
134-
135-
const sourceMetaData = getSourceMetaData(getState(), source.id);
136-
expect(sourceMetaData.framework).toBe("React");
137-
});
138115
});
139116

140117
describe("setSymbols", () => {

src/components/SecondaryPanes/Breakpoint.js

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)