mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Bug 1900395 - [devtools] Some general fixes for tests r=devtools-reviewers,nchevobbe
- Wait for Codemirror document load to complete in certain situations - Make sure `getLocationsInViewport` handles properly when the source editor is destroyed Differential Revision: https://phabricator.services.mozilla.com/D224127
This commit is contained in:
parent
2de7a9cbde
commit
bffb082418
@ -12,12 +12,15 @@ add_task(async function () {
|
||||
|
||||
await selectSource(dbg, "long.js");
|
||||
await waitForSelectedSource(dbg, "long.js");
|
||||
|
||||
// Wait a bit for CM6 to complete any updates so the conditional panel
|
||||
// does not lose focus after the it has been opened
|
||||
await waitForDocumentLoadComplete(dbg);
|
||||
info(
|
||||
"toggle conditional panel with shortcut: no breakpoints, default cursorPosition"
|
||||
);
|
||||
pressKey(dbg, "toggleCondPanel");
|
||||
await pressKey(dbg, "toggleCondPanel");
|
||||
await waitForConditionalPanelFocus(dbg);
|
||||
|
||||
ok(
|
||||
!!(await getConditionalPanelAtLine(dbg, 1)),
|
||||
"conditional panel panel is open on line 1"
|
||||
|
@ -1618,11 +1618,7 @@ async function selectEditorLinesAndOpenContextMenu(
|
||||
elementName = "line"
|
||||
) {
|
||||
const { startLine, endLine } = lines;
|
||||
if (!endLine) {
|
||||
await clickElement(dbg, elementName, startLine);
|
||||
} else {
|
||||
setSelection(dbg, startLine, endLine);
|
||||
}
|
||||
setSelection(dbg, startLine, endLine ?? startLine);
|
||||
return openContextMenuInDebugger(dbg, elementName, startLine);
|
||||
}
|
||||
|
||||
@ -2245,6 +2241,15 @@ function waitForSearchState(dbg) {
|
||||
return waitFor(() => getCMEditor(dbg).isSearchStateReady());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for CodeMirror Document to completely load (for CM6 only)
|
||||
*/
|
||||
function waitForDocumentLoadComplete(dbg) {
|
||||
return waitFor(() =>
|
||||
isCm6Enabled ? getCMEditor(dbg).codeMirror.isDocumentLoadComplete : true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content for the editor as a string. it uses the
|
||||
* newline character to separate lines.
|
||||
@ -2591,7 +2596,9 @@ async function tryHovering(dbg, line, column, elementName) {
|
||||
async function tryHoverTokenAtLine(dbg, expression, line, column, elementName) {
|
||||
info("Scroll codeMirror to make the token visible");
|
||||
await scrollEditorIntoView(dbg, line, 0);
|
||||
|
||||
// Wait for all the updates to the document to complete to make all
|
||||
// token elements have been rendered
|
||||
await waitForDocumentLoadComplete(dbg);
|
||||
// Lookup for the token matching the passed expression
|
||||
const tokenEl = await getTokenElAtLine(dbg, expression, line, column);
|
||||
if (!tokenEl) {
|
||||
|
@ -3113,6 +3113,9 @@ Toolbox.prototype = {
|
||||
}
|
||||
|
||||
return this.loadTool("webconsole").then(() => {
|
||||
if (!this.component) {
|
||||
return;
|
||||
}
|
||||
this.component.setIsSplitConsoleActive(true);
|
||||
this.telemetry.recordEvent("activate", "split_console", null, {
|
||||
host: this._getTelemetryHostString(),
|
||||
|
@ -1732,6 +1732,9 @@ class Editor extends EventEmitter {
|
||||
* @returns {Object} - The location information for the current viewport
|
||||
*/
|
||||
getLocationsInViewport() {
|
||||
if (this.isDestroyed()) {
|
||||
return null;
|
||||
}
|
||||
const cm = editors.get(this);
|
||||
if (this.config.cm6) {
|
||||
const { from, to } = cm.viewport;
|
||||
@ -2091,18 +2094,13 @@ class Editor extends EventEmitter {
|
||||
/**
|
||||
* Gets details about the line
|
||||
*
|
||||
* @param {Number} lineOrOffset
|
||||
* @param {Number} line
|
||||
* @returns {Object} line info object
|
||||
*/
|
||||
lineInfo(lineOrOffset) {
|
||||
let line = this.toLineIfWasmOffset(lineOrOffset);
|
||||
if (line == undefined) {
|
||||
return null;
|
||||
}
|
||||
lineInfo(line) {
|
||||
const cm = editors.get(this);
|
||||
if (this.config.cm6) {
|
||||
// cm6 lines are 1-based, while cm5 are 0-based
|
||||
line = line + 1;
|
||||
const el = this.getElementAtLine(line);
|
||||
// Filter out SPAN which do not contain user-defined classes.
|
||||
// Classes currently are "debug-expression" and "debug-expression-error"
|
||||
@ -2111,7 +2109,7 @@ class Editor extends EventEmitter {
|
||||
);
|
||||
|
||||
return {
|
||||
text: cm.state.doc.lineAt(line)?.text,
|
||||
text: el.innerText,
|
||||
// TODO: Expose those, or see usage for those and do things differently
|
||||
line: null,
|
||||
handle: {
|
||||
|
Loading…
Reference in New Issue
Block a user