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
60
61
62
63
64
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test InspectorUtils.getRegisteredCssHighlights</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<code>InspectorUtils.getRegisteredCssHighlights</code>
<script>
"use strict";
/** Test for InspectorUtils.getRegisteredCssHighlights **/
const { Assert } = SpecialPowers.ChromeUtils.importESModule(
"resource://testing-common/Assert.sys.mjs"
);
const InspectorUtils = SpecialPowers.InspectorUtils;
const codeEl = document.querySelector("code");
const range = new Range();
range.setStart(codeEl.firstChild, 10);
range.setEnd(codeEl.firstChild, 20);
const searchHighlight = new Highlight(range);
CSS.highlights.set("search", searchHighlight);
Assert.deepEqual(
InspectorUtils.getRegisteredCssHighlights(document),
["search"],
`Got registered "search" highlight`
);
CSS.highlights.set("filter", new Highlight());
Assert.deepEqual(
InspectorUtils.getRegisteredCssHighlights(document),
["search", "filter"],
`Got new registered "filter" highlight and previous one`
);
Assert.deepEqual(
InspectorUtils.getRegisteredCssHighlights(document, true),
["search"],
"Only got registered active highlights when passing activeOnly"
);
CSS.highlights.clear();
is(
InspectorUtils.getRegisteredCssHighlights(document).length,
0,
"Empty array returned when no highlights are registered"
);
is(
InspectorUtils.getRegisteredCssHighlights(document, true).length,
0,
"Empty array returned when passing activeOnly and no highlights are registered"
);
</script>
</pre>
</body>
</html>
|