Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / devtools / server / tests / chrome / test_highlighter_paused_debugger.html
blob129772c1650d2a3b09022d68fb8d70ff2618e367
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Test the PausedDebuggerOverlay highlighter.
5 -->
6 <head>
7 <meta charset="utf-8">
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">
11 </head>
12 <body>
13 <pre id="test">
14 <script>
15 "use strict";
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");
61 is(
62 getReason(),
63 "Debugger paused",
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");
76 highlighter.show();
77 ok(isOverlayShown(), "The overlay is shown however");
79 info("Hide the highlighter");
80 highlighter.hide();
81 ok(isHidden("root"), "The highlighter is now hidden");
83 SimpleTest.finish();
85 </script>
86 </pre>
87 </body>
88 </html>