browser_dbg-javascript-tracer-sidebar-toggle.js (1755B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 // Tests the Javascript Tracing feature. 6 7 "use strict"; 8 9 add_task(async function () { 10 const dbg = await initDebugger("doc-scripts.html"); 11 12 info("Force the log method to be the debugger sidebar"); 13 await toggleJsTracerMenuItem(dbg, "#jstracer-menu-item-debugger-sidebar"); 14 15 info("Enable the tracing"); 16 await toggleJsTracer(dbg.toolbox); 17 18 const topLevelThreadActorID = 19 dbg.toolbox.commands.targetCommand.targetFront.threadFront.actorID; 20 info("Wait for tracing to be enabled"); 21 await waitForState(dbg, () => { 22 return dbg.selectors.getIsThreadCurrentlyTracing(topLevelThreadActorID); 23 }); 24 25 invokeInTab("main"); 26 27 info("Wait for the call tree to appear in the tracer panel"); 28 const tracerTree = await waitForElementWithSelector( 29 dbg, 30 "#tracer-tab-panel .tree" 31 ); 32 33 info("Wait for the expected traces to appear in the call tree"); 34 await waitFor(() => { 35 const elements = tracerTree.querySelectorAll(".trace-line"); 36 if (elements.length == 3) { 37 return elements; 38 } 39 return false; 40 }); 41 42 is( 43 findAllElementsWithSelector(dbg, ".tracer-timeline").length, 44 1, 45 "The timeline was rendered before moving to another tab" 46 ); 47 await dbg.actions.setPrimaryPaneTab("sources"); 48 await dbg.actions.setPrimaryPaneTab("tracer"); 49 is( 50 findAllElementsWithSelector(dbg, ".tracer-timeline").length, 51 1, 52 "The timeline is still rendered after moving to another tab" 53 ); 54 55 info("Reset back to the default value"); 56 await toggleJsTracerMenuItem(dbg, "#jstracer-menu-item-console"); 57 });