Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 959eaa5

Browse files
tromeyjasonLaster
authored andcommitted
Have firefox onConnect wait for newSources (#2997)
This fixes a race where panel.js can report that the debugger has started, but where getSources will still return null for a source that does in fact exist. See https://bugzilla.mozilla.org/show_bug.cgi?id=1364526
1 parent 884ff3f commit 959eaa5

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/client/firefox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function onConnect(connection: any, actions: Object) {
3030
// bfcache) so explicity fire `newSource` events for all returned
3131
// sources.
3232
const sources = await clientCommands.fetchSources();
33-
actions.newSources(sources);
33+
await actions.newSources(sources);
3434

3535
// If the threadClient is already paused, make sure to show a
3636
// paused state.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { onConnect } from "../../firefox";
2+
3+
const tabTarget = {
4+
on: () => {}
5+
};
6+
7+
const threadClient = {
8+
addListener: () => {},
9+
reconfigure: () => {},
10+
getSources: () => {
11+
return {
12+
sources: [
13+
{
14+
id: "s.js",
15+
url: "file:///tmp/s.js"
16+
}
17+
]
18+
};
19+
},
20+
getLastPausePacket: () => null
21+
};
22+
23+
const debuggerClient = {};
24+
25+
const actions = {
26+
_sources: [],
27+
28+
newSources: function(sources) {
29+
return new Promise(resolve => {
30+
setTimeout(() => {
31+
this._sources = sources;
32+
resolve();
33+
}, 0);
34+
});
35+
}
36+
};
37+
38+
describe("firefox onConnect", () => {
39+
it("wait for sources at startup", async () => {
40+
await onConnect(
41+
{
42+
tabConnection: {
43+
tabTarget,
44+
threadClient,
45+
debuggerClient
46+
}
47+
},
48+
actions
49+
);
50+
expect(actions._sources.length).toEqual(1);
51+
expect(actions._sources[0].url).toEqual("file:///tmp/s.js");
52+
});
53+
});

0 commit comments

Comments
 (0)