summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_simple-request-data.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_simple-request-data.js')
-rw-r--r--devtools/client/netmonitor/test/browser_net_simple-request-data.js684
1 files changed, 335 insertions, 349 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_simple-request-data.js b/devtools/client/netmonitor/test/browser_net_simple-request-data.js
index 7b112ef7d8..450313a4c9 100644
--- a/devtools/client/netmonitor/test/browser_net_simple-request-data.js
+++ b/devtools/client/netmonitor/test/browser_net_simple-request-data.js
@@ -17,72 +17,67 @@ function test() {
L10N,
} = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
- initNetMonitor(SIMPLE_SJS, { requestCount: 1 }).then(
- async ({ tab, monitor }) => {
- info("Starting test... ");
-
- const { document, store, windowRequire, connector } = monitor.panelWin;
- const { EVENTS, TEST_EVENTS } = windowRequire(
- "devtools/client/netmonitor/src/constants"
- );
- const { getDisplayedRequests, getSelectedRequest, getSortedRequests } =
- windowRequire("devtools/client/netmonitor/src/selectors/index");
-
- const promiseList = [];
- promiseList.push(waitForNetworkEvents(monitor, 1));
-
- function expectEvent(evt, cb) {
- promiseList.push(
- new Promise((resolve, reject) => {
- monitor.panelWin.api.once(evt, _ => {
- cb().then(resolve, reject);
- });
- })
- );
- }
+ initNetMonitor(SIMPLE_SJS, { requestCount: 1 }).then(async ({ monitor }) => {
+ info("Starting test... ");
+
+ const { document, store, windowRequire, connector } = monitor.panelWin;
+ const { EVENTS, TEST_EVENTS } = windowRequire(
+ "devtools/client/netmonitor/src/constants"
+ );
+ const { getDisplayedRequests, getSelectedRequest, getSortedRequests } =
+ windowRequire("devtools/client/netmonitor/src/selectors/index");
+
+ const promiseList = [];
+ promiseList.push(waitForNetworkEvents(monitor, 1));
+
+ function expectEvent(evt, cb) {
+ promiseList.push(
+ new Promise((resolve, reject) => {
+ monitor.panelWin.api.once(evt, _ => {
+ cb().then(resolve, reject);
+ });
+ })
+ );
+ }
- expectEvent(TEST_EVENTS.NETWORK_EVENT, async () => {
- is(
- getSelectedRequest(store.getState()),
- undefined,
- "There shouldn't be any selected item in the requests menu."
- );
- is(
- store.getState().requests.requests.length,
- 1,
- "The requests menu should not be empty after the first request."
- );
- is(
- !!document.querySelector(".network-details-bar"),
- false,
- "The network details panel should still be hidden after first request."
- );
+ expectEvent(TEST_EVENTS.NETWORK_EVENT, async () => {
+ is(
+ getSelectedRequest(store.getState()),
+ undefined,
+ "There shouldn't be any selected item in the requests menu."
+ );
+ is(
+ store.getState().requests.requests.length,
+ 1,
+ "The requests menu should not be empty after the first request."
+ );
+ is(
+ !!document.querySelector(".network-details-bar"),
+ false,
+ "The network details panel should still be hidden after first request."
+ );
- const requestItem = getSortedRequests(store.getState())[0];
+ const requestItem = getSortedRequests(store.getState())[0];
- is(
- typeof requestItem.id,
- "string",
- "The attached request id is incorrect."
- );
- isnot(
- requestItem.id,
- "",
- "The attached request id should not be empty."
- );
+ is(
+ typeof requestItem.id,
+ "string",
+ "The attached request id is incorrect."
+ );
+ isnot(requestItem.id, "", "The attached request id should not be empty.");
- is(
- typeof requestItem.startedMs,
- "number",
- "The attached startedMs is incorrect."
- );
- isnot(
- requestItem.startedMs,
- 0,
- "The attached startedMs should not be zero."
- );
+ is(
+ typeof requestItem.startedMs,
+ "number",
+ "The attached startedMs is incorrect."
+ );
+ isnot(
+ requestItem.startedMs,
+ 0,
+ "The attached startedMs should not be zero."
+ );
- /*
+ /*
* Bug 1666495: this is not possible to assert not yet set attributes
* because of throttling, which only updates the frontend after a few attributes
* are already retrieved via onResourceUpdates events.
@@ -162,328 +157,319 @@ function test() {
);
*/
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS
- );
- });
-
- expectEvent(TEST_EVENTS.RECEIVED_REQUEST_HEADERS, async () => {
- await waitForRequestData(store, ["requestHeaders"]);
-
- const requestItem = getSortedRequests(store.getState())[0];
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS
+ );
+ });
- ok(
- requestItem.requestHeaders,
- "There should be a requestHeaders data available."
- );
- is(
- requestItem.requestHeaders.headers.length,
- 10,
- "The requestHeaders data has an incorrect |headers| property."
- );
- isnot(
- requestItem.requestHeaders.headersSize,
- 0,
- "The requestHeaders data has an incorrect |headersSize| property."
- );
- // Can't test for the exact request headers size because the value may
- // vary across platforms ("User-Agent" header differs).
-
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS
- );
- });
+ expectEvent(TEST_EVENTS.RECEIVED_REQUEST_HEADERS, async () => {
+ await waitForRequestData(store, ["requestHeaders"]);
- expectEvent(TEST_EVENTS.RECEIVED_REQUEST_COOKIES, async () => {
- await waitForRequestData(store, ["requestCookies"]);
+ const requestItem = getSortedRequests(store.getState())[0];
- const requestItem = getSortedRequests(store.getState())[0];
+ ok(
+ requestItem.requestHeaders,
+ "There should be a requestHeaders data available."
+ );
+ is(
+ requestItem.requestHeaders.headers.length,
+ 10,
+ "The requestHeaders data has an incorrect |headers| property."
+ );
+ isnot(
+ requestItem.requestHeaders.headersSize,
+ 0,
+ "The requestHeaders data has an incorrect |headersSize| property."
+ );
+ // Can't test for the exact request headers size because the value may
+ // vary across platforms ("User-Agent" header differs).
+
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS
+ );
+ });
- ok(
- requestItem.requestCookies,
- "There should be a requestCookies data available."
- );
- is(
- requestItem.requestCookies.length,
- 2,
- "The requestCookies data has an incorrect |cookies| property."
- );
+ expectEvent(TEST_EVENTS.RECEIVED_REQUEST_COOKIES, async () => {
+ await waitForRequestData(store, ["requestCookies"]);
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS
- );
- });
+ const requestItem = getSortedRequests(store.getState())[0];
- monitor.panelWin.api.once(TEST_EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
- ok(false, "Trap listener: this request doesn't have any post data.");
- });
+ ok(
+ requestItem.requestCookies,
+ "There should be a requestCookies data available."
+ );
+ is(
+ requestItem.requestCookies.length,
+ 2,
+ "The requestCookies data has an incorrect |cookies| property."
+ );
- expectEvent(TEST_EVENTS.RECEIVED_RESPONSE_HEADERS, async () => {
- await waitForRequestData(store, ["responseHeaders"]);
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS
+ );
+ });
- const requestItem = getSortedRequests(store.getState())[0];
+ monitor.panelWin.api.once(TEST_EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
+ ok(false, "Trap listener: this request doesn't have any post data.");
+ });
- ok(
- requestItem.responseHeaders,
- "There should be a responseHeaders data available."
- );
- is(
- requestItem.responseHeaders.headers.length,
- 13,
- "The responseHeaders data has an incorrect |headers| property."
- );
- is(
- requestItem.responseHeaders.headersSize,
- 335,
- "The responseHeaders data has an incorrect |headersSize| property."
- );
+ expectEvent(TEST_EVENTS.RECEIVED_RESPONSE_HEADERS, async () => {
+ await waitForRequestData(store, ["responseHeaders"]);
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS
- );
- });
+ const requestItem = getSortedRequests(store.getState())[0];
- expectEvent(TEST_EVENTS.RECEIVED_RESPONSE_COOKIES, async () => {
- await waitForRequestData(store, ["responseCookies"]);
+ ok(
+ requestItem.responseHeaders,
+ "There should be a responseHeaders data available."
+ );
+ is(
+ requestItem.responseHeaders.headers.length,
+ 13,
+ "The responseHeaders data has an incorrect |headers| property."
+ );
+ is(
+ requestItem.responseHeaders.headersSize,
+ 335,
+ "The responseHeaders data has an incorrect |headersSize| property."
+ );
- const requestItem = getSortedRequests(store.getState())[0];
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS
+ );
+ });
- ok(
- requestItem.responseCookies,
- "There should be a responseCookies data available."
- );
- is(
- requestItem.responseCookies.length,
- 2,
- "The responseCookies data has an incorrect |cookies| property."
- );
+ expectEvent(TEST_EVENTS.RECEIVED_RESPONSE_COOKIES, async () => {
+ await waitForRequestData(store, ["responseCookies"]);
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS
- );
- });
+ const requestItem = getSortedRequests(store.getState())[0];
- expectEvent(TEST_EVENTS.STARTED_RECEIVING_RESPONSE, async () => {
- await waitForRequestData(store, [
- "httpVersion",
- "status",
- "statusText",
- "headersSize",
- ]);
+ ok(
+ requestItem.responseCookies,
+ "There should be a responseCookies data available."
+ );
+ is(
+ requestItem.responseCookies.length,
+ 2,
+ "The responseCookies data has an incorrect |cookies| property."
+ );
- const requestItem = getSortedRequests(store.getState())[0];
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS
+ );
+ });
- is(
- requestItem.httpVersion,
- "HTTP/1.1",
- "The httpVersion data has an incorrect value."
- );
- is(
- requestItem.status,
- "200",
- "The status data has an incorrect value."
- );
- is(
- requestItem.statusText,
- "Och Aye",
- "The statusText data has an incorrect value."
- );
- is(
- requestItem.headersSize,
- 335,
- "The headersSize data has an incorrect value."
- );
+ expectEvent(TEST_EVENTS.STARTED_RECEIVING_RESPONSE, async () => {
+ await waitForRequestData(store, [
+ "httpVersion",
+ "status",
+ "statusText",
+ "headersSize",
+ ]);
- const requestListItem = document.querySelector(".request-list-item");
- requestListItem.scrollIntoView();
- const requestsListStatus =
- requestListItem.querySelector(".status-code");
- EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus);
- await waitUntil(() => requestsListStatus.title);
- await waitForDOMIfNeeded(
- requestListItem,
- ".requests-list-timings-total"
- );
+ const requestItem = getSortedRequests(store.getState())[0];
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS,
- {
- status: "200",
- statusText: "Och Aye",
- }
- );
- });
+ is(
+ requestItem.httpVersion,
+ "HTTP/1.1",
+ "The httpVersion data has an incorrect value."
+ );
+ is(requestItem.status, "200", "The status data has an incorrect value.");
+ is(
+ requestItem.statusText,
+ "Och Aye",
+ "The statusText data has an incorrect value."
+ );
+ is(
+ requestItem.headersSize,
+ 335,
+ "The headersSize data has an incorrect value."
+ );
- expectEvent(EVENTS.PAYLOAD_READY, async () => {
- await waitForRequestData(store, [
- "transferredSize",
- "contentSize",
- "mimeType",
- ]);
+ const requestListItem = document.querySelector(".request-list-item");
+ requestListItem.scrollIntoView();
+ const requestsListStatus = requestListItem.querySelector(".status-code");
+ EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus);
+ await waitUntil(() => requestsListStatus.title);
+ await waitForDOMIfNeeded(requestListItem, ".requests-list-timings-total");
+
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS,
+ {
+ status: "200",
+ statusText: "Och Aye",
+ }
+ );
+ });
- const requestItem = getSortedRequests(store.getState())[0];
+ expectEvent(EVENTS.PAYLOAD_READY, async () => {
+ await waitForRequestData(store, [
+ "transferredSize",
+ "contentSize",
+ "mimeType",
+ ]);
- is(
- requestItem.transferredSize,
- 347,
- "The transferredSize data has an incorrect value."
- );
- is(
- requestItem.contentSize,
- 12,
- "The contentSize data has an incorrect value."
- );
- is(
- requestItem.mimeType,
- "text/plain; charset=utf-8",
- "The mimeType data has an incorrect value."
- );
+ const requestItem = getSortedRequests(store.getState())[0];
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS,
- {
- type: "plain",
- fullMimeType: "text/plain; charset=utf-8",
- transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 347),
- size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
- }
- );
- });
+ is(
+ requestItem.transferredSize,
+ 347,
+ "The transferredSize data has an incorrect value."
+ );
+ is(
+ requestItem.contentSize,
+ 12,
+ "The contentSize data has an incorrect value."
+ );
+ is(
+ requestItem.mimeType,
+ "text/plain; charset=utf-8",
+ "The mimeType data has an incorrect value."
+ );
- expectEvent(EVENTS.UPDATING_EVENT_TIMINGS, async () => {
- await waitForRequestData(store, ["eventTimings"]);
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS,
+ {
+ type: "plain",
+ fullMimeType: "text/plain; charset=utf-8",
+ transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 347),
+ size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
+ }
+ );
+ });
- const requestItem = getSortedRequests(store.getState())[0];
+ expectEvent(EVENTS.UPDATING_EVENT_TIMINGS, async () => {
+ await waitForRequestData(store, ["eventTimings"]);
- is(
- typeof requestItem.totalTime,
- "number",
- "The attached totalTime is incorrect."
- );
- Assert.greaterOrEqual(
- requestItem.totalTime,
- 0,
- "The attached totalTime should be positive."
- );
+ const requestItem = getSortedRequests(store.getState())[0];
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS,
- {
- time: true,
- }
- );
- });
+ is(
+ typeof requestItem.totalTime,
+ "number",
+ "The attached totalTime is incorrect."
+ );
+ Assert.greaterOrEqual(
+ requestItem.totalTime,
+ 0,
+ "The attached totalTime should be positive."
+ );
- expectEvent(EVENTS.RECEIVED_EVENT_TIMINGS, async () => {
- await waitForRequestData(store, ["eventTimings"]);
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS,
+ {
+ time: true,
+ }
+ );
+ });
- const requestItem = getSortedRequests(store.getState())[0];
+ expectEvent(EVENTS.RECEIVED_EVENT_TIMINGS, async () => {
+ await waitForRequestData(store, ["eventTimings"]);
- ok(
- requestItem.eventTimings,
- "There should be a eventTimings data available."
- );
- is(
- typeof requestItem.eventTimings.timings.blocked,
- "number",
- "The eventTimings data has an incorrect |timings.blocked| property."
- );
- is(
- typeof requestItem.eventTimings.timings.dns,
- "number",
- "The eventTimings data has an incorrect |timings.dns| property."
- );
- is(
- typeof requestItem.eventTimings.timings.ssl,
- "number",
- "The eventTimings data has an incorrect |timings.ssl| property."
- );
- is(
- typeof requestItem.eventTimings.timings.connect,
- "number",
- "The eventTimings data has an incorrect |timings.connect| property."
- );
- is(
- typeof requestItem.eventTimings.timings.send,
- "number",
- "The eventTimings data has an incorrect |timings.send| property."
- );
- is(
- typeof requestItem.eventTimings.timings.wait,
- "number",
- "The eventTimings data has an incorrect |timings.wait| property."
- );
- is(
- typeof requestItem.eventTimings.timings.receive,
- "number",
- "The eventTimings data has an incorrect |timings.receive| property."
- );
- is(
- typeof requestItem.eventTimings.totalTime,
- "number",
- "The eventTimings data has an incorrect |totalTime| property."
- );
+ const requestItem = getSortedRequests(store.getState())[0];
- verifyRequestItemTarget(
- document,
- getDisplayedRequests(store.getState()),
- requestItem,
- "GET",
- SIMPLE_SJS,
- {
- time: true,
- }
- );
- });
+ ok(
+ requestItem.eventTimings,
+ "There should be a eventTimings data available."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.blocked,
+ "number",
+ "The eventTimings data has an incorrect |timings.blocked| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.dns,
+ "number",
+ "The eventTimings data has an incorrect |timings.dns| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.ssl,
+ "number",
+ "The eventTimings data has an incorrect |timings.ssl| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.connect,
+ "number",
+ "The eventTimings data has an incorrect |timings.connect| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.send,
+ "number",
+ "The eventTimings data has an incorrect |timings.send| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.wait,
+ "number",
+ "The eventTimings data has an incorrect |timings.wait| property."
+ );
+ is(
+ typeof requestItem.eventTimings.timings.receive,
+ "number",
+ "The eventTimings data has an incorrect |timings.receive| property."
+ );
+ is(
+ typeof requestItem.eventTimings.totalTime,
+ "number",
+ "The eventTimings data has an incorrect |totalTime| property."
+ );
- const wait = waitForNetworkEvents(monitor, 1);
- await reloadBrowser();
- await wait;
+ verifyRequestItemTarget(
+ document,
+ getDisplayedRequests(store.getState()),
+ requestItem,
+ "GET",
+ SIMPLE_SJS,
+ {
+ time: true,
+ }
+ );
+ });
- const requestItem = getSortedRequests(store.getState())[0];
+ const wait = waitForNetworkEvents(monitor, 1);
+ await reloadBrowser();
+ await wait;
- if (!requestItem.requestHeaders) {
- connector.requestData(requestItem.id, "requestHeaders");
- }
- if (!requestItem.responseHeaders) {
- connector.requestData(requestItem.id, "responseHeaders");
- }
+ const requestItem = getSortedRequests(store.getState())[0];
- await Promise.all(promiseList);
- await teardown(monitor);
- finish();
+ if (!requestItem.requestHeaders) {
+ connector.requestData(requestItem.id, "requestHeaders");
}
- );
+ if (!requestItem.responseHeaders) {
+ connector.requestData(requestItem.id, "responseHeaders");
+ }
+
+ await Promise.all(promiseList);
+ await teardown(monitor);
+ finish();
+ });
}