browser_dbg-preview-frame.js (1868B)
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 // Test hovering in a selected frame 6 7 "use strict"; 8 9 add_task(async function () { 10 const dbg = await initDebugger("doc-script-switching.html"); 11 12 const found = findElement(dbg, "callStackBody"); 13 is(found, null, "Call stack is hidden"); 14 15 invokeInTab("firstCall"); 16 await waitForPaused(dbg); 17 18 info("Preview a variable in the second frame"); 19 clickElement(dbg, "frame", 2); 20 await waitForSelectedFrame(dbg, "firstCall"); 21 await assertPreviews(dbg, [ 22 { 23 line: 8, 24 column: 4, 25 header: `function secondCall()`, 26 fields: [["name", `"secondCall"`]], 27 expression: "secondCall", 28 }, 29 ]); 30 31 info("Preview should still work after selecting different locations"); 32 const frame = dbg.selectors.getVisibleSelectedFrame(); 33 const inScopeLines = dbg.selectors.getInScopeLines(frame.location); 34 await selectSource(dbg, "script-switching-01.js"); 35 await assertPreviews(dbg, [ 36 { 37 line: 6, 38 column: 12, 39 header: `function firstCall()`, 40 fields: [["name", `"firstCall"`]], 41 expression: "firstCall", 42 }, 43 ]); 44 await assertPreviews(dbg, [ 45 { 46 line: 8, 47 column: 4, 48 header: `function secondCall()`, 49 fields: [["name", `"secondCall"`]], 50 expression: "secondCall", 51 }, 52 ]); 53 54 is( 55 dbg.selectors.getInScopeLines(frame.location), 56 inScopeLines, 57 "In scope lines" 58 ); 59 }); 60 61 function waitForSelectedFrame(dbg, displayName) { 62 const { getInScopeLines, getVisibleSelectedFrame } = dbg.selectors; 63 return waitForState(dbg, () => { 64 const frame = getVisibleSelectedFrame(); 65 66 return frame?.displayName == displayName && getInScopeLines(frame.location); 67 }); 68 }