1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_post-data-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if the POST requests display the correct information in the UI, 1.9 + * for raw payloads with attached content-type headers. 1.10 + */ 1.11 + 1.12 +function test() { 1.13 + initNetMonitor(POST_RAW_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.14 + info("Starting test... "); 1.15 + 1.16 + let { document, L10N, NetMonitorView } = aMonitor.panelWin; 1.17 + let { RequestsMenu, NetworkDetails } = NetMonitorView; 1.18 + 1.19 + RequestsMenu.lazyUpdate = false; 1.20 + NetworkDetails._params.lazyEmpty = false; 1.21 + 1.22 + waitForNetworkEvents(aMonitor, 0, 1).then(() => { 1.23 + NetMonitorView.toggleDetailsPane({ visible: true }, 2) 1.24 + RequestsMenu.selectedIndex = 0; 1.25 + 1.26 + let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; 1.27 + waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => { 1.28 + let tab = document.querySelectorAll("#event-details-pane tab")[2]; 1.29 + let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2]; 1.30 + 1.31 + is(tab.getAttribute("selected"), "true", 1.32 + "The params tab in the network details pane should be selected."); 1.33 + 1.34 + is(tabpanel.querySelector("#request-params-box") 1.35 + .hasAttribute("hidden"), false, 1.36 + "The request params box doesn't have the indended visibility."); 1.37 + is(tabpanel.querySelector("#request-post-data-textarea-box") 1.38 + .hasAttribute("hidden"), true, 1.39 + "The request post data textarea box doesn't have the indended visibility."); 1.40 + 1.41 + is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, 1.42 + "There should be 1 param scopes displayed in this tabpanel."); 1.43 + is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, 1.44 + "The empty notice should not be displayed in this tabpanel."); 1.45 + 1.46 + let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; 1.47 + is(postScope.querySelector(".name").getAttribute("value"), 1.48 + L10N.getStr("paramsFormData"), 1.49 + "The post scope doesn't have the correct title."); 1.50 + 1.51 + is(postScope.querySelectorAll(".variables-view-variable").length, 2, 1.52 + "There should be 2 param values displayed in the post scope."); 1.53 + is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), 1.54 + "foo", "The first query param name was incorrect."); 1.55 + is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), 1.56 + "\"bar\"", "The first query param value was incorrect."); 1.57 + is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), 1.58 + "baz", "The second query param name was incorrect."); 1.59 + is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), 1.60 + "\"123\"", "The second query param value was incorrect."); 1.61 + 1.62 + teardown(aMonitor).then(finish); 1.63 + }); 1.64 + }); 1.65 + 1.66 + aDebuggee.performRequests(); 1.67 + }); 1.68 +}