blob: 9dc641422203ed89ff6fd1bb321ddc7ab5845b19 (
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
63
64
65
66
67
68
69
70
71
72
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_FILE = "test-network-request.html";
const TEST_PATH =
"https://example.com/browser/devtools/client/webconsole/" + "test/browser/";
const TEST_URI = TEST_PATH + TEST_FILE;
registerCleanupFunction(async function () {
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, () =>
resolve()
);
});
});
add_task(async function task() {
await pushPref("devtools.webconsole.filter.net", false);
await pushPref("devtools.webconsole.filter.netxhr", true);
await openNewTabAndToolbox(TEST_URI, "netmonitor");
const currentTab = gBrowser.selectedTab;
const toolbox = gDevTools.getToolboxForTab(currentTab);
const panel = toolbox.getCurrentPanel().panelWin;
const netReady = panel.api.once("NetMonitor:PayloadReady");
// Fire an XHR POST request.
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
content.wrappedJSObject.testXhrGet();
});
info("XHR executed");
await netReady;
info("NetMonitor:PayloadReady received");
const { hud } = await toolbox.selectTool("webconsole");
const xhrUrl = TEST_PATH + "test-data.json";
const messageNode = await waitFor(() =>
findMessageByType(hud, xhrUrl, ".network")
);
const urlNode = messageNode.querySelector(".url");
info("Network message found.");
const onReady = hud.ui.once("network-request-payload-ready");
// Expand network log
urlNode.click();
await onReady;
info("network-request-payload-ready received");
await testNetworkMessage(messageNode);
await waitForLazyRequests(toolbox);
});
async function testNetworkMessage(messageNode) {
const headersTab = messageNode.querySelector("#headers-tab");
ok(headersTab, "Headers tab is available");
// Headers tab should be selected by default, so just check its content.
await waitUntil(() =>
messageNode.querySelector("#headers-panel .headers-overview")
);
}
|