test_highlighter_paused_debugger.html (2982B)
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"; 16 17 window.onload = async function() { 18 SimpleTest.waitForExplicitFinish(); 19 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"); 24 25 const env = new HighlighterEnvironment(); 26 env.initFromWindow(window); 27 28 const highlighter = new PausedDebuggerOverlay(env); 29 await highlighter.isReady; 30 const anonymousContent = highlighter.markup.content; 31 32 function isHidden(elementID) { 33 const attr = anonymousContent.root.getElementById(elementID).getAttribute("hidden"); 34 return typeof attr === "string" && attr == "true"; 35 } 36 37 function getReason() { 38 return anonymousContent.root.getElementById("paused-dbg-reason").textContent; 39 } 40 41 function isOverlayShown() { 42 const attr = anonymousContent.root.getElementById("paused-dbg-root").getAttribute("overlay"); 43 return typeof attr === "string" && attr == "true"; 44 } 45 46 info("Test that the various elements with IDs exist"); 47 ok(highlighter.getElement("paused-dbg-root"), "The root wrapper element exists"); 48 ok(highlighter.getElement("paused-dbg-toolbar"), "The toolbar element exists"); 49 ok(highlighter.getElement("paused-dbg-reason"), "The reason label element exists"); 50 51 info("Test that the highlighter is hidden by default"); 52 ok(isHidden("paused-dbg-root"), "The highlighter is hidden"); 53 54 info("Show the highlighter with overlay and toolbar"); 55 let didShow = highlighter.show("breakpoint"); 56 ok(didShow, "Calling show returned true"); 57 ok(!isHidden("paused-dbg-root"), "The highlighter is shown"); 58 ok(isOverlayShown(), "The overlay is shown"); 59 is( 60 getReason(), 61 "Debugger paused", 62 "The reason displayed in the toolbar is correct" 63 ); 64 65 info("Call show again with another reason"); 66 didShow = highlighter.show("debuggerStatement"); 67 ok(didShow, "Calling show returned true too"); 68 ok(!isHidden("paused-dbg-root"), "The highlighter is still shown"); 69 is(getReason(), "Debugger paused", 70 "The reason displayed in the toolbar is correct again"); 71 ok(isOverlayShown(), "The overlay is still shown too"); 72 73 info("Call show again but with no reason"); 74 highlighter.show(); 75 ok(isOverlayShown(), "The overlay is shown however"); 76 77 info("Hide the highlighter"); 78 highlighter.hide(); 79 ok(isHidden("paused-dbg-root"), "The highlighter is now hidden"); 80 81 SimpleTest.finish(); 82 }; 83 </script> 84 </pre> 85 </body> 86 </html>