browser_webconsole_split_close_button.js (2014B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_URI = 7 "data:text/html;charset=utf-8,<!DOCTYPE html><p>Web Console test for close button of " + 8 "split console"; 9 10 add_task(async function () { 11 const toolbox = await openNewTabAndToolbox(TEST_URI, "inspector"); 12 13 info("Check the split console toolbar has a close button."); 14 15 const onSplitConsoleReady = toolbox.once("webconsole-ready"); 16 toolbox.toggleSplitConsole(); 17 await onSplitConsoleReady; 18 19 let closeButton = getCloseButton(toolbox); 20 ok(closeButton, "The split console has close button."); 21 22 info( 23 "Check we can reopen split console after closing split console by using " + 24 "the close button" 25 ); 26 27 let onSplitConsoleChange = toolbox.once("split-console"); 28 closeButton.click(); 29 await onSplitConsoleChange; 30 ok(!toolbox.splitConsole, "The split console has been closed."); 31 32 onSplitConsoleChange = toolbox.once("split-console"); 33 toolbox.toggleSplitConsole(); 34 await onSplitConsoleChange; 35 36 ok(toolbox.splitConsole, "The split console has been displayed."); 37 closeButton = getCloseButton(toolbox); 38 ok(closeButton, "The split console has the close button after reopening."); 39 40 info("Check the close button is not displayed on console panel."); 41 42 await toolbox.selectTool("webconsole"); 43 closeButton = getCloseButton(toolbox); 44 ok(!closeButton, "The console panel should not have the close button."); 45 46 info("The split console has the close button if back to the inspector."); 47 48 await toolbox.selectTool("inspector"); 49 ok( 50 toolbox.splitConsole, 51 "The split console has been displayed with inspector." 52 ); 53 closeButton = getCloseButton(toolbox); 54 ok(closeButton, "The split console on the inspector has the close button."); 55 }); 56 57 function getCloseButton(toolbox) { 58 const hud = toolbox.getPanel("webconsole").hud; 59 const doc = hud.ui.outputNode.ownerDocument; 60 return doc.getElementById("split-console-close-button"); 61 }