summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/browser-toolbox
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/framework/browser-toolbox')
-rw-r--r--devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_netmonitor.js52
-rw-r--r--devtools/client/framework/browser-toolbox/test/browser_browser_toolbox_unavailable_children.js192
-rw-r--r--devtools/client/framework/browser-toolbox/window.js2
3 files changed, 126 insertions, 120 deletions
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();
});
diff --git a/devtools/client/framework/browser-toolbox/window.js b/devtools/client/framework/browser-toolbox/window.js
index e84ef02829..e1b4c8031b 100644
--- a/devtools/client/framework/browser-toolbox/window.js
+++ b/devtools/client/framework/browser-toolbox/window.js
@@ -185,7 +185,7 @@ window.addEventListener(
{ once: true }
);
-function onCloseCommand(event) {
+function onCloseCommand() {
window.close();
}