From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../test/browser_browser_toolbox_netmonitor.js | 52 ++++-- ...browser_browser_toolbox_unavailable_children.js | 192 ++++++++++----------- 2 files changed, 125 insertions(+), 119 deletions(-) (limited to 'devtools/client/framework/browser-toolbox/test') diff --git a/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_netmonitor.js b/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_netmonitor.js index 56e38998ce..cfa5783f12 100644 --- a/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_netmonitor.js +++ b/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_netmonitor.js @@ -29,6 +29,7 @@ add_task(async function () { await ToolboxTask.importFunctions({ waitUntil, + waitForDOM, }); await ToolboxTask.spawn(null, async () => { @@ -94,7 +95,10 @@ add_task(async function () { await ToolboxTask.spawn(null, async () => { const monitor = gToolbox.getCurrentPanel(); - const { document, store } = monitor.panelWin; + const { document, store, windowRequire } = monitor.panelWin; + const Actions = windowRequire( + "devtools/client/netmonitor/src/actions/index" + ); await waitUntil( () => !document.querySelector(".request-list-empty-notice") @@ -110,10 +114,19 @@ add_task(async function () { document.querySelectorAll("tbody .requests-list-column.requests-list-url") ); is(requests.length, 1, "One request displayed"); + const requestUrl = + "https://example.org/document-builder.sjs?html=fromParent"; + is(requests[0].textContent, requestUrl, "Expected request is displayed"); + + const waitForHeaders = waitForDOM(document, ".headers-overview"); + store.dispatch(Actions.toggleNetworkDetails()); + await waitForHeaders; + + const tabpanel = document.querySelector("#headers-panel"); is( - requests[0].textContent, - "https://example.org/document-builder.sjs?html=fromParent", - "Expected request is displayed" + tabpanel.querySelector(".url-preview .url").innerText, + requestUrl, + "The url summary value is incorrect." ); }); @@ -129,23 +142,24 @@ add_task(async function () { const monitor = gToolbox.getCurrentPanel(); const { document, store } = monitor.panelWin; + // Note that we may have lots of other requests relates to browser activity, + // like file:// requests for many internal UI ressources. await waitUntil(() => store.getState().requests.requests.length >= 3); ok(true, "Expected content requests are displayed"); - const requests = Array.from( - document.querySelectorAll("tbody .requests-list-column.requests-list-url") - ); - is(requests.length, 3, "Three requests displayed"); - ok( - requests[1].textContent.includes( - `https://example.com/document-builder.sjs` - ), - "Request for the tab is displayed" - ); - is( - requests[2].textContent, - innerUrlImg, - "Request for image image in tab is displayed" - ); + async function waitForRequest(url, requestName) { + info(`Wait for ${requestName} request`); + await waitUntil(() => { + const requests = Array.from( + document.querySelectorAll( + "tbody .requests-list-column.requests-list-url" + ) + ); + return requests.some(r => r.textContent.includes(url)); + }); + info(`Got ${requestName} request`); + } + await waitForRequest("https://example.com/document-builder.sjs", "tab"); + await waitForRequest(innerUrlImg, "image in tab"); }); }); diff --git a/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_unavailable_children.js b/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_unavailable_children.js index 5029c62306..d06274591e 100644 --- a/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_unavailable_children.js +++ b/devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_unavailable_children.js @@ -38,107 +38,99 @@ add_task(async function () { selectNode, }); - const tabProcessID = - tab.linkedBrowser.browsingContext.currentWindowGlobal.osPid; - - const decodedTabURI = decodeURI(tab.linkedBrowser.currentURI.spec); - - await ToolboxTask.spawn( - [tabProcessID, isFissionEnabled(), decodedTabURI], - async (processID, _isFissionEnabled, tabURI) => { - /* global gToolbox */ - const inspector = gToolbox.getPanel("inspector"); - - info("Select the test browser element."); - await selectNode('browser[remote="true"][test-tab]', inspector); - - info("Retrieve the node front for selected node."); - const browserNodeFront = inspector.selection.nodeFront; - ok(!!browserNodeFront, "Retrieved a node front for the browser"); - is(browserNodeFront.displayName, "browser"); - - // Small helper to expand containers and return the child container - // matching the provided display name. - async function expandContainer(container, expectedChildName) { - info(`Expand the node expected to contain a ${expectedChildName}`); - await inspector.markup.expandNode(container.node); - await waitUntil(() => !!container.getChildContainers().length); - - const children = container - .getChildContainers() - .filter(child => child.node.displayName === expectedChildName); - is(children.length, 1); - return children[0]; - } - - info("Check that the corresponding markup view container has children"); - const browserContainer = inspector.markup.getContainer(browserNodeFront); - ok(browserContainer.hasChildren); - ok( - !browserContainer.node.childrenUnavailable, - "childrenUnavailable un-set" - ); - ok( - !browserContainer.elt.querySelector(".unavailable-children"), - "The unavailable badge is not displayed" - ); - - // Store the asserts as a helper to reuse it later in the test. - async function assertMarkupView() { - info("Check that the children are #document > html > body > div"); - let container = await expandContainer(browserContainer, "#document"); - container = await expandContainer(container, "html"); - container = await expandContainer(container, "body"); - container = await expandContainer(container, "div"); - - info("Select the #pick-me div"); - await selectNode(container.node, inspector); - is(inspector.selection.nodeFront.id, "pick-me"); - } - await assertMarkupView(); - - const parentProcessScope = gToolbox.doc.querySelector( - 'input[name="chrome-debug-mode"][value="parent-process"]' - ); - - info("Switch to parent process only scope"); - const onInspectorUpdated = inspector.once("inspector-updated"); - parentProcessScope.click(); - await onInspectorUpdated; - - // Note: `getChildContainers` returns null when the container has no - // children, instead of an empty array. - await waitUntil(() => browserContainer.getChildContainers() === null); - - ok(!browserContainer.hasChildren, "browser container has no children"); - ok(browserContainer.node.childrenUnavailable, "childrenUnavailable set"); - ok( - !!browserContainer.elt.querySelector(".unavailable-children"), - "The unavailable badge is displayed" - ); - - const everythingScope = gToolbox.doc.querySelector( - 'input[name="chrome-debug-mode"][value="everything"]' - ); - - info("Switch to multi process scope"); - everythingScope.click(); - - info("Wait until browserContainer has children"); - await waitUntil(() => browserContainer.hasChildren); - ok(browserContainer.hasChildren, "browser container has children"); - ok( - !browserContainer.node.childrenUnavailable, - "childrenUnavailable un-set" - ); - ok( - !browserContainer.elt.querySelector(".unavailable-children"), - "The unavailable badge is no longer displayed" - ); - - await assertMarkupView(); + await ToolboxTask.spawn([], async () => { + /* global gToolbox */ + const inspector = gToolbox.getPanel("inspector"); + + info("Select the test browser element."); + await selectNode('browser[remote="true"][test-tab]', inspector); + + info("Retrieve the node front for selected node."); + const browserNodeFront = inspector.selection.nodeFront; + ok(!!browserNodeFront, "Retrieved a node front for the browser"); + is(browserNodeFront.displayName, "browser"); + + // Small helper to expand containers and return the child container + // matching the provided display name. + async function expandContainer(container, expectedChildName) { + info(`Expand the node expected to contain a ${expectedChildName}`); + await inspector.markup.expandNode(container.node); + await waitUntil(() => !!container.getChildContainers().length); + + const children = container + .getChildContainers() + .filter(child => child.node.displayName === expectedChildName); + is(children.length, 1); + return children[0]; } - ); + + info("Check that the corresponding markup view container has children"); + const browserContainer = inspector.markup.getContainer(browserNodeFront); + ok(browserContainer.hasChildren); + ok( + !browserContainer.node.childrenUnavailable, + "childrenUnavailable un-set" + ); + ok( + !browserContainer.elt.querySelector(".unavailable-children"), + "The unavailable badge is not displayed" + ); + + // Store the asserts as a helper to reuse it later in the test. + async function assertMarkupView() { + info("Check that the children are #document > html > body > div"); + let container = await expandContainer(browserContainer, "#document"); + container = await expandContainer(container, "html"); + container = await expandContainer(container, "body"); + container = await expandContainer(container, "div"); + + info("Select the #pick-me div"); + await selectNode(container.node, inspector); + is(inspector.selection.nodeFront.id, "pick-me"); + } + await assertMarkupView(); + + const parentProcessScope = gToolbox.doc.querySelector( + 'input[name="chrome-debug-mode"][value="parent-process"]' + ); + + info("Switch to parent process only scope"); + const onInspectorUpdated = inspector.once("inspector-updated"); + parentProcessScope.click(); + await onInspectorUpdated; + + // Note: `getChildContainers` returns null when the container has no + // children, instead of an empty array. + await waitUntil(() => browserContainer.getChildContainers() === null); + + ok(!browserContainer.hasChildren, "browser container has no children"); + ok(browserContainer.node.childrenUnavailable, "childrenUnavailable set"); + ok( + !!browserContainer.elt.querySelector(".unavailable-children"), + "The unavailable badge is displayed" + ); + + const everythingScope = gToolbox.doc.querySelector( + 'input[name="chrome-debug-mode"][value="everything"]' + ); + + info("Switch to multi process scope"); + everythingScope.click(); + + info("Wait until browserContainer has children"); + await waitUntil(() => browserContainer.hasChildren); + ok(browserContainer.hasChildren, "browser container has children"); + ok( + !browserContainer.node.childrenUnavailable, + "childrenUnavailable un-set" + ); + ok( + !browserContainer.elt.querySelector(".unavailable-children"), + "The unavailable badge is no longer displayed" + ); + + await assertMarkupView(); + }); await ToolboxTask.destroy(); }); -- cgit v1.2.3