browser_dbg-editor-highlight.js (1861B)
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 will always highight the right line, no 6 // matter if the source text doesn't exist yet or even if the source 7 // doesn't exist. 8 9 "use strict"; 10 11 add_task(async function () { 12 const dbg = await initDebugger("doc-scripts.html", "long.js"); 13 const { 14 selectors: { getSettledSourceTextContent }, 15 } = dbg; 16 17 // The source itself doesn't even exist yet, and using 18 // `selectSourceURL` will set a pending request to load this source 19 // and highlight a specific line. 20 21 await selectSource(dbg, "long.js", 66); 22 23 // TODO: revisit highlighting lines when the debugger opens 24 // assertHighlightLocation(dbg, "long.js", 66); 25 26 info("Select line 16 and make sure the editor scrolled."); 27 await selectSource(dbg, "long.js", 16); 28 await waitForElement(dbg, "highlightLine"); 29 assertHighlightLocation(dbg, "long.js", 16); 30 31 info("Select several locations and check that we have one highlight"); 32 await selectSource(dbg, "long.js", 17); 33 await selectSource(dbg, "long.js", 18); 34 assertHighlightLocation(dbg, "long.js", 18); 35 36 // Test jumping to a line in a source that exists but hasn't been 37 // loaded yet. 38 info("Select an unloaded source"); 39 const onSourceSelected = selectSource(dbg, "simple1.js", 6); 40 41 // Make sure the source is in the loading state, wait for it to be 42 // fully loaded, and check the highlighted line. 43 const simple1 = findSource(dbg, "simple1.js"); 44 const location = createLocation({ source: simple1 }); 45 is(getSettledSourceTextContent(location), null); 46 47 await onSourceSelected; 48 ok(getSettledSourceTextContent(location).value.value); 49 assertHighlightLocation(dbg, "simple1.js", 6); 50 });