mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1767702 - [devtools] Split browser_dbg-features-source-tree.js and re-enable it. r=bomsy
Let move Browser Toolbox checks in a distinct file as it can get flaky. Differential Revision: https://phabricator.services.mozilla.com/D149417
This commit is contained in:
parent
5b2dd6dd56
commit
09d0d54069
@ -33,7 +33,8 @@ prefs =
|
||||
[browser_dbg-features-breakable-lines.js]
|
||||
[browser_dbg-features-breakable-positions.js]
|
||||
[browser_dbg-features-source-tree.js]
|
||||
skip-if =
|
||||
[browser_dbg-features-browser-toolbox-source-tree.js]
|
||||
skip-if =
|
||||
asan # Bug 1591064
|
||||
win10_2004 # Bug 1767702
|
||||
[browser_dbg-features-source-text-content.js]
|
||||
|
@ -0,0 +1,89 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
/**
|
||||
* This test focuses on the SourceTree component, within the browser toolbox.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
/* import-globals-from ../../../framework/browser-toolbox/test/helpers-browser-toolbox.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/devtools/client/framework/browser-toolbox/test/helpers-browser-toolbox.js",
|
||||
this
|
||||
);
|
||||
|
||||
// Test that the Web extension name is shown in source tree rather than
|
||||
// the extensions internal UUID. This checks both the web toolbox and the
|
||||
// browser toolbox.
|
||||
add_task(async function testSourceTreeNamesForWebExtensions() {
|
||||
await pushPref("devtools.chrome.enabled", true);
|
||||
await pushPref("devtools.browsertoolbox.fission", true);
|
||||
const extension = await installAndStartContentScriptExtension();
|
||||
|
||||
const dbg = await initDebugger("doc-content-script-sources.html");
|
||||
await waitForSourcesInSourceTree(dbg, [], {
|
||||
noExpand: true,
|
||||
});
|
||||
|
||||
is(
|
||||
getSourceTreeLabel(dbg, 2),
|
||||
"Test content script extension",
|
||||
"Test content script extension is labeled properly"
|
||||
);
|
||||
|
||||
await dbg.toolbox.closeToolbox();
|
||||
await extension.unload();
|
||||
|
||||
// Make sure the toolbox opens with the debugger selected.
|
||||
await pushPref("devtools.browsertoolbox.panel", "jsdebugger");
|
||||
|
||||
const ToolboxTask = await initBrowserToolboxTask();
|
||||
await ToolboxTask.importFunctions({
|
||||
createDebuggerContext,
|
||||
waitUntil,
|
||||
findSourceNodeWithText,
|
||||
findAllElements,
|
||||
getSelector,
|
||||
findAllElementsWithSelector,
|
||||
assertSourceTreeNode,
|
||||
});
|
||||
|
||||
await ToolboxTask.spawn(selectors, async _selectors => {
|
||||
this.selectors = _selectors;
|
||||
});
|
||||
|
||||
await ToolboxTask.spawn(null, async () => {
|
||||
try {
|
||||
/* global gToolbox */
|
||||
// Wait for the debugger to finish loading.
|
||||
await gToolbox.getPanelWhenReady("jsdebugger");
|
||||
const dbgx = createDebuggerContext(gToolbox);
|
||||
let rootNodeForExtensions = null;
|
||||
await waitUntil(() => {
|
||||
rootNodeForExtensions = findSourceNodeWithText(dbgx, "extension");
|
||||
return !!rootNodeForExtensions;
|
||||
});
|
||||
// Find the root node for extensions and expand it if needed
|
||||
if (
|
||||
!!rootNodeForExtensions &&
|
||||
!rootNodeForExtensions.querySelector(".arrow.expanded")
|
||||
) {
|
||||
rootNodeForExtensions.querySelector(".arrow").click();
|
||||
}
|
||||
|
||||
// Assert that extensions are displayed in the source tree
|
||||
// with their extension name.
|
||||
await assertSourceTreeNode(dbgx, "Picture-In-Picture");
|
||||
await assertSourceTreeNode(dbgx, "Form Autofill");
|
||||
} catch (e) {
|
||||
console.log("Caught exception in spawn", e);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
await ToolboxTask.destroy();
|
||||
});
|
@ -14,14 +14,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
requestLongerTimeout(5);
|
||||
|
||||
/* import-globals-from ../../../framework/browser-toolbox/test/helpers-browser-toolbox.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/devtools/client/framework/browser-toolbox/test/helpers-browser-toolbox.js",
|
||||
this
|
||||
);
|
||||
|
||||
const testServer = createVersionizedHttpTestServer(
|
||||
"examples/sourcemaps-reload-uncompressed"
|
||||
);
|
||||
@ -41,7 +33,11 @@ add_task(async function testSimpleSourcesWithManualClickExpand() {
|
||||
);
|
||||
|
||||
// Expand nodes and make sure more sources appear.
|
||||
is(getLabel(dbg, 1), "Main Thread", "Main thread is labeled properly");
|
||||
is(
|
||||
getSourceTreeLabel(dbg, 1),
|
||||
"Main Thread",
|
||||
"Main thread is labeled properly"
|
||||
);
|
||||
info("Before interacting with the source tree, no source are displayed");
|
||||
await waitForSourcesInSourceTree(dbg, [], { noExpand: true });
|
||||
await clickElement(dbg, "sourceDirectoryLabel", 3);
|
||||
@ -394,110 +390,6 @@ add_task(async function testSourceTreeWithWebExtensionContentScript() {
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
// Test that the Web extension name is shown in source tree rather than
|
||||
// the extensions internal UUID. This checks both the web toolbox and the
|
||||
// browser toolbox.
|
||||
add_task(async function testSourceTreeNamesForWebExtensions() {
|
||||
await pushPref("devtools.chrome.enabled", true);
|
||||
await pushPref("devtools.browsertoolbox.fission", true);
|
||||
const extension = await installAndStartContentScriptExtension();
|
||||
|
||||
const dbg = await initDebugger("doc-content-script-sources.html");
|
||||
await waitForSourcesInSourceTree(dbg, [], {
|
||||
noExpand: true,
|
||||
});
|
||||
|
||||
is(
|
||||
getLabel(dbg, 2),
|
||||
"Test content script extension",
|
||||
"Test content script extension is labeled properly"
|
||||
);
|
||||
|
||||
await dbg.toolbox.closeToolbox();
|
||||
await extension.unload();
|
||||
|
||||
// Make sure the toolbox opens with the debugger selected.
|
||||
await pushPref("devtools.browsertoolbox.panel", "jsdebugger");
|
||||
|
||||
const ToolboxTask = await initBrowserToolboxTask();
|
||||
await ToolboxTask.importFunctions({
|
||||
createDebuggerContext,
|
||||
waitUntil,
|
||||
findSourceNodeWithText,
|
||||
findAllElements,
|
||||
getSelector,
|
||||
findAllElementsWithSelector,
|
||||
assertSourceTreeNode,
|
||||
});
|
||||
|
||||
await ToolboxTask.spawn(selectors, async _selectors => {
|
||||
this.selectors = _selectors;
|
||||
});
|
||||
|
||||
await ToolboxTask.spawn(null, async () => {
|
||||
try {
|
||||
/* global gToolbox */
|
||||
// Wait for the debugger to finish loading.
|
||||
await gToolbox.getPanelWhenReady("jsdebugger");
|
||||
const dbgx = createDebuggerContext(gToolbox);
|
||||
let rootNodeForExtensions = null;
|
||||
await waitUntil(() => {
|
||||
rootNodeForExtensions = findSourceNodeWithText(dbgx, "extension");
|
||||
return !!rootNodeForExtensions;
|
||||
});
|
||||
// Find the root node for extensions and expand it if needed
|
||||
if (
|
||||
!!rootNodeForExtensions &&
|
||||
!rootNodeForExtensions.querySelector(".arrow.expanded")
|
||||
) {
|
||||
rootNodeForExtensions.querySelector(".arrow").click();
|
||||
}
|
||||
|
||||
// Assert that extensions are displayed in the source tree
|
||||
// with their extension name.
|
||||
await assertSourceTreeNode(dbgx, "Picture-In-Picture");
|
||||
await assertSourceTreeNode(dbgx, "Form Autofill");
|
||||
} catch (e) {
|
||||
console.log("Caught exception in spawn", e);
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
await ToolboxTask.destroy();
|
||||
});
|
||||
|
||||
/**
|
||||
* Return the text content for a given line in the Source Tree.
|
||||
*
|
||||
* @param {Object} dbg
|
||||
* @param {Number} index
|
||||
* Line number in the source tree
|
||||
*/
|
||||
function getLabel(dbg, index) {
|
||||
return (
|
||||
findElement(dbg, "sourceNode", index)
|
||||
.textContent.trim()
|
||||
// There is some special whitespace character which aren't removed by trim()
|
||||
.replace(/^[\s\u200b]*/g, "")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find and assert the source tree node with the specified text
|
||||
* exists on the source tree.
|
||||
*
|
||||
* @param {Object} dbg
|
||||
* @param {String} text The node text displayed
|
||||
*/
|
||||
async function assertSourceTreeNode(dbg, text) {
|
||||
let node = null;
|
||||
await waitUntil(() => {
|
||||
node = findSourceNodeWithText(dbg, text);
|
||||
return !!node;
|
||||
});
|
||||
ok(!!node, `Source tree node with text "${text}" exists`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the location displayed in the breakpoint list, in the right sidebar.
|
||||
*
|
||||
|
@ -169,3 +169,35 @@ async function installAndStartContentScriptExtension() {
|
||||
|
||||
return extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the text content for a given line in the Source Tree.
|
||||
*
|
||||
* @param {Object} dbg
|
||||
* @param {Number} index
|
||||
* Line number in the source tree
|
||||
*/
|
||||
function getSourceTreeLabel(dbg, index) {
|
||||
return (
|
||||
findElement(dbg, "sourceNode", index)
|
||||
.textContent.trim()
|
||||
// There is some special whitespace character which aren't removed by trim()
|
||||
.replace(/^[\s\u200b]*/g, "")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find and assert the source tree node with the specified text
|
||||
* exists on the source tree.
|
||||
*
|
||||
* @param {Object} dbg
|
||||
* @param {String} text The node text displayed
|
||||
*/
|
||||
async function assertSourceTreeNode(dbg, text) {
|
||||
let node = null;
|
||||
await waitUntil(() => {
|
||||
node = findSourceNodeWithText(dbg, text);
|
||||
return !!node;
|
||||
});
|
||||
ok(!!node, `Source tree node with text "${text}" exists`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user