browser/devtools/netmonitor/test/browser_net_post-data-02.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a6953e91c5eb
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if the POST requests display the correct information in the UI,
6 * for raw payloads with attached content-type headers.
7 */
8
9 function test() {
10 initNetMonitor(POST_RAW_URL).then(([aTab, aDebuggee, aMonitor]) => {
11 info("Starting test... ");
12
13 let { document, L10N, NetMonitorView } = aMonitor.panelWin;
14 let { RequestsMenu, NetworkDetails } = NetMonitorView;
15
16 RequestsMenu.lazyUpdate = false;
17 NetworkDetails._params.lazyEmpty = false;
18
19 waitForNetworkEvents(aMonitor, 0, 1).then(() => {
20 NetMonitorView.toggleDetailsPane({ visible: true }, 2)
21 RequestsMenu.selectedIndex = 0;
22
23 let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
24 waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
25 let tab = document.querySelectorAll("#event-details-pane tab")[2];
26 let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2];
27
28 is(tab.getAttribute("selected"), "true",
29 "The params tab in the network details pane should be selected.");
30
31 is(tabpanel.querySelector("#request-params-box")
32 .hasAttribute("hidden"), false,
33 "The request params box doesn't have the indended visibility.");
34 is(tabpanel.querySelector("#request-post-data-textarea-box")
35 .hasAttribute("hidden"), true,
36 "The request post data textarea box doesn't have the indended visibility.");
37
38 is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
39 "There should be 1 param scopes displayed in this tabpanel.");
40 is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
41 "The empty notice should not be displayed in this tabpanel.");
42
43 let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
44 is(postScope.querySelector(".name").getAttribute("value"),
45 L10N.getStr("paramsFormData"),
46 "The post scope doesn't have the correct title.");
47
48 is(postScope.querySelectorAll(".variables-view-variable").length, 2,
49 "There should be 2 param values displayed in the post scope.");
50 is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
51 "foo", "The first query param name was incorrect.");
52 is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
53 "\"bar\"", "The first query param value was incorrect.");
54 is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
55 "baz", "The second query param name was incorrect.");
56 is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
57 "\"123\"", "The second query param value was incorrect.");
58
59 teardown(aMonitor).then(finish);
60 });
61 });
62
63 aDebuggee.performRequests();
64 });
65 }

mercurial