4 Test the PausedDebuggerOverlay highlighter.
8 <title>PausedDebuggerOverlay test
</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css">
17 window
.onload
= async
function() {
18 SimpleTest
.waitForExplicitFinish();
20 const {require
} = ChromeUtils
.importESModule("resource://devtools/shared/loader/Loader.sys.mjs");
21 require("devtools/server/actors/inspector/inspector");
22 const {HighlighterEnvironment
} = require("devtools/server/actors/highlighters");
23 const {PausedDebuggerOverlay
} = require("devtools/server/actors/highlighters/paused-debugger");
25 const env
= new HighlighterEnvironment();
26 env
.initFromWindow(window
);
28 const highlighter
= new PausedDebuggerOverlay(env
);
29 await highlighter
.isReady
;
30 const anonymousContent
= highlighter
.markup
.content
;
32 const id
= elementID
=> `${highlighter.ID_CLASS_PREFIX}${elementID}`;
34 function isHidden(elementID
) {
35 const attr
= anonymousContent
.root
.getElementById(id(elementID
)).getAttribute("hidden");
36 return typeof attr
=== "string" && attr
== "true";
39 function getReason() {
40 return anonymousContent
.root
.getElementById(id("reason")).textContent
;
43 function isOverlayShown() {
44 const attr
= anonymousContent
.root
.getElementById(id("root")).getAttribute("overlay");
45 return typeof attr
=== "string" && attr
== "true";
48 info("Test that the various elements with IDs exist");
49 ok(highlighter
.getElement("root"), "The root wrapper element exists");
50 ok(highlighter
.getElement("toolbar"), "The toolbar element exists");
51 ok(highlighter
.getElement("reason"), "The reason label element exists");
53 info("Test that the highlighter is hidden by default");
54 ok(isHidden("root"), "The highlighter is hidden");
56 info("Show the highlighter with overlay and toolbar");
57 let didShow
= highlighter
.show("breakpoint");
58 ok(didShow
, "Calling show returned true");
59 ok(!isHidden("root"), "The highlighter is shown");
60 ok(isOverlayShown(), "The overlay is shown");
64 "The reason displayed in the toolbar is correct"
67 info("Call show again with another reason");
68 didShow
= highlighter
.show("debuggerStatement");
69 ok(didShow
, "Calling show returned true too");
70 ok(!isHidden("root"), "The highlighter is still shown");
71 is(getReason(), "Debugger paused",
72 "The reason displayed in the toolbar is correct again");
73 ok(isOverlayShown(), "The overlay is still shown too");
75 info("Call show again but with no reason");
77 ok(isOverlayShown(), "The overlay is shown however");
79 info("Hide the highlighter");
81 ok(isHidden("root"), "The highlighter is now hidden");