summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_post-data-03.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/netmonitor/test/browser_net_post-data-03.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_post-data-03.js')
-rw-r--r--devtools/client/netmonitor/test/browser_net_post-data-03.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_post-data-03.js b/devtools/client/netmonitor/test/browser_net_post-data-03.js
new file mode 100644
index 000000000..3433f89ce
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_post-data-03.js
@@ -0,0 +1,98 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Tests if the POST requests display the correct information in the UI,
+ * for raw payloads with content-type headers attached to the upload stream.
+ */
+
+add_task(function* () {
+ let { L10N } = require("devtools/client/netmonitor/l10n");
+
+ let { tab, monitor } = yield initNetMonitor(POST_RAW_WITH_HEADERS_URL);
+ info("Starting test... ");
+
+ let { document, EVENTS, NetMonitorView } = monitor.panelWin;
+ let { RequestsMenu } = NetMonitorView;
+
+ RequestsMenu.lazyUpdate = false;
+
+ let wait = waitForNetworkEvents(monitor, 0, 1);
+ yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+ content.wrappedJSObject.performRequests();
+ });
+ yield wait;
+
+ let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+ NetMonitorView.toggleDetailsPane({ visible: true });
+ RequestsMenu.selectedIndex = 0;
+ yield onEvent;
+
+ let tabEl = document.querySelectorAll("#details-pane tab")[0];
+ let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
+ let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2];
+
+ is(tabEl.getAttribute("selected"), "true",
+ "The headers tab in the network details pane should be selected.");
+ is(tabpanel.querySelectorAll(".variables-view-scope").length, 3,
+ "There should be 3 header scopes displayed in this tabpanel.");
+
+ is(requestFromUploadScope.querySelector(".name").getAttribute("value"),
+ L10N.getStr("requestHeadersFromUpload") + " (" +
+ L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74 / 1024, 3)) + ")",
+ "The request headers from upload scope doesn't have the correct title.");
+
+ is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2,
+ "There should be 2 headers displayed in the request headers from upload scope.");
+
+ is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0]
+ .getAttribute("value"),
+ "content-type", "The first request header name was incorrect.");
+ is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0]
+ .getAttribute("value"), "\"application/x-www-form-urlencoded\"",
+ "The first request header value was incorrect.");
+ is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1]
+ .getAttribute("value"),
+ "custom-header", "The second request header name was incorrect.");
+ is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1]
+ .getAttribute("value"),
+ "\"hello world!\"", "The second request header value was incorrect.");
+
+ onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
+ EventUtils.sendMouseEvent({ type: "mousedown" },
+ document.querySelectorAll("#details-pane tab")[2]);
+ yield onEvent;
+
+ tabEl = document.querySelectorAll("#details-pane tab")[2];
+ tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
+ let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
+
+ is(tab.getAttribute("selected"), "true",
+ "The response tab in the network details pane should be selected.");
+ is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
+ "There should be 1 header scope displayed in this tabpanel.");
+
+ is(formDataScope.querySelector(".name").getAttribute("value"),
+ L10N.getStr("paramsFormData"),
+ "The form data scope doesn't have the correct title.");
+
+ is(formDataScope.querySelectorAll(".variables-view-variable").length, 2,
+ "There should be 2 payload values displayed in the form data scope.");
+
+ is(formDataScope.querySelectorAll(".variables-view-variable .name")[0]
+ .getAttribute("value"),
+ "foo", "The first payload param name was incorrect.");
+ is(formDataScope.querySelectorAll(".variables-view-variable .value")[0]
+ .getAttribute("value"),
+ "\"bar\"", "The first payload param value was incorrect.");
+ is(formDataScope.querySelectorAll(".variables-view-variable .name")[1]
+ .getAttribute("value"),
+ "baz", "The second payload param name was incorrect.");
+ is(formDataScope.querySelectorAll(".variables-view-variable .value")[1]
+ .getAttribute("value"),
+ "\"123\"", "The second payload param value was incorrect.");
+
+ return teardown(monitor);
+});