|
4 | 4 | createStore, |
5 | 5 | waitForState, |
6 | 6 | makeSource, |
| 7 | + makeOriginalSource, |
7 | 8 | makeFrame |
8 | 9 | } from "../../utils/test-head"; |
9 | 10 |
|
@@ -42,6 +43,11 @@ const mockThreadClient = { |
42 | 43 | source: "function foo() {\n return -5;\n}", |
43 | 44 | contentType: "text/javascript" |
44 | 45 | }); |
| 46 | + case "foo-original": |
| 47 | + return resolve({ |
| 48 | + source: "\n\nfunction fooOriginal() {\n return -5;\n}", |
| 49 | + contentType: "text/javascript" |
| 50 | + }); |
45 | 51 | } |
46 | 52 | }); |
47 | 53 | } |
@@ -145,6 +151,44 @@ describe("pause", () => { |
145 | 151 | expect(getNextStepSpy).toBeCalled(); |
146 | 152 | getNextStepSpy.mockRestore(); |
147 | 153 | }); |
| 154 | + |
| 155 | + describe("pausing in a generated location", () => { |
| 156 | + it("maps frame locations and names to original source", async () => { |
| 157 | + const generatedLocation = { |
| 158 | + sourceId: "foo", |
| 159 | + line: 1, |
| 160 | + column: 0 |
| 161 | + }; |
| 162 | + const originalLocation = { |
| 163 | + sourceId: "foo-original", |
| 164 | + line: 3, |
| 165 | + column: 0 |
| 166 | + }; |
| 167 | + const sourceMapsMock = { |
| 168 | + getOriginalLocation: () => Promise.resolve(originalLocation) |
| 169 | + }; |
| 170 | + const store = createStore(mockThreadClient, {}, sourceMapsMock); |
| 171 | + const { dispatch, getState } = store; |
| 172 | + const mockPauseInfo = createPauseInfo(generatedLocation); |
| 173 | + |
| 174 | + await dispatch(actions.newSource(makeSource("foo"))); |
| 175 | + await dispatch(actions.newSource(makeOriginalSource("foo"))); |
| 176 | + await dispatch(actions.loadSourceText(I.Map({ id: "foo" }))); |
| 177 | + await dispatch(actions.loadSourceText(I.Map({ id: "foo-original" }))); |
| 178 | + await dispatch(actions.setSymbols("foo-original")); |
| 179 | + |
| 180 | + await dispatch(actions.paused(mockPauseInfo)); |
| 181 | + expect(selectors.getFrames(getState())).toEqual([ |
| 182 | + { |
| 183 | + id: 1, |
| 184 | + scope: [], |
| 185 | + location: originalLocation, |
| 186 | + generatedLocation, |
| 187 | + originalDisplayName: "fooOriginal" |
| 188 | + } |
| 189 | + ]); |
| 190 | + }); |
| 191 | + }); |
148 | 192 | }); |
149 | 193 |
|
150 | 194 | describe("resumed", () => { |
|
0 commit comments