forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert.js
More file actions
59 lines (49 loc) · 1.47 KB
/
assert.js
File metadata and controls
59 lines (49 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const {
findSource,
findElement,
isVisibleWithin,
isPaused
} = require("./shared");
function assertPausedLocation(dbg, ctx, source, line) {
const { selectors: { getSelectedSource, getPause }, getState } = dbg;
source = findSource(dbg, source);
const { is, ok } = ctx;
// Check the selected source
is(getSelectedSource(getState()).get("id"), source.id);
// Check the pause location
const location = getPause(getState()).getIn(["frame", "location"]);
is(location.get("sourceId"), source.id);
is(location.get("line"), line);
// Check the debug line
ok(
dbg.win.cm.lineInfo(line - 1).wrapClass.includes("debug-line"),
"Line is highlighted as paused"
);
}
function assertNotPaused(dbg, ctx) {
const { ok } = ctx;
ok(!isPaused(dbg), "not paused");
}
function assertHighlightLocation(dbg, ctx, source, line) {
const { selectors: { getSelectedSource, getPause }, getState } = dbg;
const { is, ok } = ctx;
source = findSource(dbg, source);
// Check the selected source
is(getSelectedSource(getState()).get("url"), source.url);
// Check the highlight line
const lineEl = findElement(dbg, "highlightLine");
ok(lineEl, "Line is highlighted");
ok(
isVisibleWithin(findElement(dbg, "codeMirror"), lineEl),
"Highlighted line is visible"
);
ok(
dbg.win.cm.lineInfo(line - 1).wrapClass.includes("highlight-line"),
"Line is highlighted"
);
}
module.exports = {
assertPausedLocation,
assertNotPaused,
assertHighlightLocation
};