michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if the POST requests display the correct information in the UI, michael@0: * for raw payloads with content-type headers attached to the upload stream. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(POST_RAW_WITH_HEADERS_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { document, L10N, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu, NetworkDetails } = NetMonitorView; michael@0: let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: Task.spawn(function*() { michael@0: yield waitForNetworkEvents(aMonitor, 0, 1); michael@0: michael@0: NetMonitorView.toggleDetailsPane({ visible: true }); michael@0: RequestsMenu.selectedIndex = 0; michael@0: michael@0: yield waitFor(aMonitor.panelWin, TAB_UPDATED); michael@0: michael@0: let tab = document.querySelectorAll("#details-pane tab")[0]; michael@0: let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0]; michael@0: let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2]; michael@0: michael@0: is(tab.getAttribute("selected"), "true", michael@0: "The headers tab in the network details pane should be selected."); michael@0: is(tabpanel.querySelectorAll(".variables-view-scope").length, 3, michael@0: "There should be 3 header scopes displayed in this tabpanel."); michael@0: michael@0: is(requestFromUploadScope.querySelector(".name").getAttribute("value"), michael@0: L10N.getStr("requestHeadersFromUpload") + " (" + michael@0: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74/1024, 3)) + ")", michael@0: "The request headers from upload scope doesn't have the correct title."); michael@0: michael@0: is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2, michael@0: "There should be 2 header values displayed in the request headers from upload scope."); michael@0: michael@0: is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), michael@0: "content-type", "The first request header name was incorrect."); michael@0: is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), michael@0: "\"application/x-www-form-urlencoded\"", "The first request header value was incorrect."); michael@0: is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), michael@0: "custom-header", "The second request header name was incorrect."); michael@0: is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), michael@0: "\"hello world!\"", "The second request header value was incorrect."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.querySelectorAll("#details-pane tab")[2]); michael@0: michael@0: yield waitFor(aMonitor.panelWin, TAB_UPDATED); michael@0: michael@0: let tab = document.querySelectorAll("#details-pane tab")[2]; michael@0: let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; michael@0: let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; michael@0: michael@0: is(tab.getAttribute("selected"), "true", michael@0: "The response tab in the network details pane should be selected."); michael@0: is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, michael@0: "There should be 1 header scope displayed in this tabpanel."); michael@0: michael@0: is(formDataScope.querySelector(".name").getAttribute("value"), michael@0: L10N.getStr("paramsFormData"), michael@0: "The form data scope doesn't have the correct title."); michael@0: michael@0: is(formDataScope.querySelectorAll(".variables-view-variable").length, 2, michael@0: "There should be 2 payload values displayed in the form data scope."); michael@0: michael@0: is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), michael@0: "foo", "The first payload param name was incorrect."); michael@0: is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), michael@0: "\"bar\"", "The first payload param value was incorrect."); michael@0: is(formDataScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), michael@0: "baz", "The second payload param name was incorrect."); michael@0: is(formDataScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), michael@0: "\"123\"", "The second payload param value was incorrect."); michael@0: michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: }