blob: e64dcc53f1c86614ac8f2b7722ceeac0a5282aa0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test that WS connection created while the page is still loading
* is properly tracked and there are WS frames displayed in the
* Messages side panel.
*/
add_task(async function () {
const { monitor } = await initNetMonitor(SIMPLE_URL, { requestCount: 1 });
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
// Make the WS Messages side panel the default so, we avoid
// request headers from the backend by selecting the Headers
// panel
store.dispatch(Actions.selectDetailsPanelTab("response"));
// Load page that opens WS connection during the load time.
const waitForEvents = waitForNetworkEvents(monitor, 3);
await navigateTo(WS_PAGE_EARLY_CONNECTION_URL);
await waitForEvents;
const requests = document.querySelectorAll(
".request-list-item .requests-list-file"
);
is(requests.length, 3, "There should be three requests");
// Get index of the WS connection request.
const index = Array.from(requests).findIndex(element => {
return element.textContent === "file_ws_backend";
});
ok(index !== -1, "There must be one WS connection request");
// Select the connection request to see WS frames in the side panel.
EventUtils.sendMouseEvent({ type: "mousedown" }, requests[index]);
info("Waiting for WS frames...");
// Wait for two frames to be displayed in the panel
await waitForDOMIfNeeded(
document,
"#messages-view .message-list-table .message-list-item",
2
);
// Check the payload of the first frame.
const firstFramePayload = document.querySelector(
"#messages-view .message-list-table .message-list-item .message-list-payload"
);
is(firstFramePayload.textContent.trim(), "readyState:loading");
await teardown(monitor);
});
|