Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if the POST requests display the correct information in the UI, |
michael@0 | 6 | * for raw payloads with content-type headers attached to the upload stream. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | function test() { |
michael@0 | 10 | initNetMonitor(POST_RAW_WITH_HEADERS_URL).then(([aTab, aDebuggee, aMonitor]) => { |
michael@0 | 11 | info("Starting test... "); |
michael@0 | 12 | |
michael@0 | 13 | let { document, L10N, NetMonitorView } = aMonitor.panelWin; |
michael@0 | 14 | let { RequestsMenu, NetworkDetails } = NetMonitorView; |
michael@0 | 15 | let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED; |
michael@0 | 16 | RequestsMenu.lazyUpdate = false; |
michael@0 | 17 | |
michael@0 | 18 | Task.spawn(function*() { |
michael@0 | 19 | yield waitForNetworkEvents(aMonitor, 0, 1); |
michael@0 | 20 | |
michael@0 | 21 | NetMonitorView.toggleDetailsPane({ visible: true }); |
michael@0 | 22 | RequestsMenu.selectedIndex = 0; |
michael@0 | 23 | |
michael@0 | 24 | yield waitFor(aMonitor.panelWin, TAB_UPDATED); |
michael@0 | 25 | |
michael@0 | 26 | let tab = document.querySelectorAll("#details-pane tab")[0]; |
michael@0 | 27 | let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0]; |
michael@0 | 28 | let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2]; |
michael@0 | 29 | |
michael@0 | 30 | is(tab.getAttribute("selected"), "true", |
michael@0 | 31 | "The headers tab in the network details pane should be selected."); |
michael@0 | 32 | is(tabpanel.querySelectorAll(".variables-view-scope").length, 3, |
michael@0 | 33 | "There should be 3 header scopes displayed in this tabpanel."); |
michael@0 | 34 | |
michael@0 | 35 | is(requestFromUploadScope.querySelector(".name").getAttribute("value"), |
michael@0 | 36 | L10N.getStr("requestHeadersFromUpload") + " (" + |
michael@0 | 37 | L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74/1024, 3)) + ")", |
michael@0 | 38 | "The request headers from upload scope doesn't have the correct title."); |
michael@0 | 39 | |
michael@0 | 40 | is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2, |
michael@0 | 41 | "There should be 2 header values displayed in the request headers from upload scope."); |
michael@0 | 42 | |
michael@0 | 43 | is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), |
michael@0 | 44 | "content-type", "The first request header name was incorrect."); |
michael@0 | 45 | is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), |
michael@0 | 46 | "\"application/x-www-form-urlencoded\"", "The first request header value was incorrect."); |
michael@0 | 47 | is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), |
michael@0 | 48 | "custom-header", "The second request header name was incorrect."); |
michael@0 | 49 | is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), |
michael@0 | 50 | "\"hello world!\"", "The second request header value was incorrect."); |
michael@0 | 51 | |
michael@0 | 52 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 53 | document.querySelectorAll("#details-pane tab")[2]); |
michael@0 | 54 | |
michael@0 | 55 | yield waitFor(aMonitor.panelWin, TAB_UPDATED); |
michael@0 | 56 | |
michael@0 | 57 | let tab = document.querySelectorAll("#details-pane tab")[2]; |
michael@0 | 58 | let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2]; |
michael@0 | 59 | let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; |
michael@0 | 60 | |
michael@0 | 61 | is(tab.getAttribute("selected"), "true", |
michael@0 | 62 | "The response tab in the network details pane should be selected."); |
michael@0 | 63 | is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, |
michael@0 | 64 | "There should be 1 header scope displayed in this tabpanel."); |
michael@0 | 65 | |
michael@0 | 66 | is(formDataScope.querySelector(".name").getAttribute("value"), |
michael@0 | 67 | L10N.getStr("paramsFormData"), |
michael@0 | 68 | "The form data scope doesn't have the correct title."); |
michael@0 | 69 | |
michael@0 | 70 | is(formDataScope.querySelectorAll(".variables-view-variable").length, 2, |
michael@0 | 71 | "There should be 2 payload values displayed in the form data scope."); |
michael@0 | 72 | |
michael@0 | 73 | is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"), |
michael@0 | 74 | "foo", "The first payload param name was incorrect."); |
michael@0 | 75 | is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"), |
michael@0 | 76 | "\"bar\"", "The first payload param value was incorrect."); |
michael@0 | 77 | is(formDataScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"), |
michael@0 | 78 | "baz", "The second payload param name was incorrect."); |
michael@0 | 79 | is(formDataScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"), |
michael@0 | 80 | "\"123\"", "The second payload param value was incorrect."); |
michael@0 | 81 | |
michael@0 | 82 | teardown(aMonitor).then(finish); |
michael@0 | 83 | }); |
michael@0 | 84 | |
michael@0 | 85 | aDebuggee.performRequests(); |
michael@0 | 86 | }); |
michael@0 | 87 | } |