browser_dbg-editor-select.js (3146B)
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 that the editor highlights the correct location when the 6 // debugger pauses 7 8 "use strict"; 9 10 requestLongerTimeout(2); 11 12 add_task(async function () { 13 // This test runs too slowly on linux debug. I'd like to figure out 14 // which is the slowest part of this and make it run faster, but to 15 // fix a frequent failure allow a longer timeout. 16 const dbg = await initDebugger("doc-scripts.html"); 17 18 info("Set the initial breakpoint."); 19 await selectSource(dbg, "simple1.js"); 20 ok( 21 !findElementWithSelector(dbg, ".cursor-position"), 22 "no position is displayed when selecting a location without an explicit line number" 23 ); 24 await selectSource(dbg, "simple1.js", 1, 1); 25 assertCursorPosition( 26 dbg, 27 1, 28 2, 29 "when passing an explicit line number, the position is displayed" 30 ); 31 assertHighlightLocation(dbg, "simple1.js", 1); 32 33 await setEditorCursorAt(dbg, 1, 0); 34 assertCursorPosition( 35 dbg, 36 1, 37 1, 38 "when moving the cursor, the position footer updates" 39 ); 40 ok( 41 !findElement(dbg, "highlightLine"), 42 "Moving the cursor resets the highlighted line" 43 ); 44 45 await setEditorCursorAt(dbg, 2, 0); 46 assertCursorPosition( 47 dbg, 48 2, 49 1, 50 "when moving the cursor a second time, the position footer still updates" 51 ); 52 53 await addBreakpoint(dbg, "simple1.js", 4); 54 const breakpointItems = findAllElements(dbg, "breakpointItems"); 55 breakpointItems[0].click(); 56 await waitForCursorPosition(dbg, 4); 57 assertCursorPosition( 58 dbg, 59 4, 60 16, 61 "when moving the cursor a second time, the position footer still updates" 62 ); 63 assertHighlightLocation(dbg, "simple1.js", 4); 64 65 info("Call the function that we set a breakpoint in."); 66 invokeInTab("main"); 67 await waitForPaused(dbg); 68 await waitForSelectedSource(dbg, "simple1.js"); 69 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple1.js").id, 4); 70 assertCursorPosition(dbg, 4, 16, "on pause, the cursor updates"); 71 72 info("Step into another file."); 73 await stepOver(dbg); 74 await stepIn(dbg); 75 await waitForSelectedSource(dbg, "simple2.js"); 76 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 3); 77 assertCursorPosition(dbg, 3, 5, "on step-in, the cursor updates"); 78 79 info("Step out to the initial file."); 80 await stepOut(dbg); 81 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple1.js").id, 6); 82 assertCursorPosition(dbg, 6, 3, "on step-out, the cursor updates"); 83 await resume(dbg); 84 85 info("Make sure that the editor scrolls to the paused location."); 86 const longSrc = findSource(dbg, "long.js"); 87 await selectSource(dbg, "long.js"); 88 await addBreakpoint(dbg, longSrc, 66); 89 90 invokeInTab("testModel"); 91 await waitForPaused(dbg); 92 await waitForSelectedSource(dbg, "long.js"); 93 94 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "long.js").id, 66); 95 ok( 96 isVisibleInEditor(dbg, findElement(dbg, "breakpoint")), 97 "Breakpoint is visible" 98 ); 99 });