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 JSON responses with unusal/custom MIME types are handled correctly. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | initNetMonitor(JSON_TEXT_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => { |
michael@0 | 10 | info("Starting test... "); |
michael@0 | 11 | |
michael@0 | 12 | let { document, L10N, NetMonitorView } = aMonitor.panelWin; |
michael@0 | 13 | let { RequestsMenu } = NetMonitorView; |
michael@0 | 14 | |
michael@0 | 15 | RequestsMenu.lazyUpdate = false; |
michael@0 | 16 | |
michael@0 | 17 | waitForNetworkEvents(aMonitor, 1).then(() => { |
michael@0 | 18 | verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), |
michael@0 | 19 | "GET", CONTENT_TYPE_SJS + "?fmt=json-text-mime", { |
michael@0 | 20 | status: 200, |
michael@0 | 21 | statusText: "OK", |
michael@0 | 22 | type: "plain", |
michael@0 | 23 | fullMimeType: "text/plain; charset=utf-8", |
michael@0 | 24 | size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), |
michael@0 | 25 | time: true |
michael@0 | 26 | }); |
michael@0 | 27 | |
michael@0 | 28 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 29 | document.getElementById("details-pane-toggle")); |
michael@0 | 30 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 31 | document.querySelectorAll("#details-pane tab")[3]); |
michael@0 | 32 | |
michael@0 | 33 | let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; |
michael@0 | 34 | waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED) |
michael@0 | 35 | .then(testResponseTab) |
michael@0 | 36 | .then(() => teardown(aMonitor)) |
michael@0 | 37 | .then(finish); |
michael@0 | 38 | |
michael@0 | 39 | function testResponseTab() { |
michael@0 | 40 | let tab = document.querySelectorAll("#details-pane tab")[3]; |
michael@0 | 41 | let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; |
michael@0 | 42 | |
michael@0 | 43 | is(tab.getAttribute("selected"), "true", |
michael@0 | 44 | "The response tab in the network details pane should be selected."); |
michael@0 | 45 | |
michael@0 | 46 | is(tabpanel.querySelector("#response-content-info-header") |
michael@0 | 47 | .hasAttribute("hidden"), true, |
michael@0 | 48 | "The response info header doesn't have the intended visibility."); |
michael@0 | 49 | is(tabpanel.querySelector("#response-content-json-box") |
michael@0 | 50 | .hasAttribute("hidden"), false, |
michael@0 | 51 | "The response content json box doesn't have the intended visibility."); |
michael@0 | 52 | is(tabpanel.querySelector("#response-content-textarea-box") |
michael@0 | 53 | .hasAttribute("hidden"), true, |
michael@0 | 54 | "The response content textarea box doesn't have the intended visibility."); |
michael@0 | 55 | is(tabpanel.querySelector("#response-content-image-box") |
michael@0 | 56 | .hasAttribute("hidden"), true, |
michael@0 | 57 | "The response content image box doesn't have the intended visibility."); |
michael@0 | 58 | |
michael@0 | 59 | is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, |
michael@0 | 60 | "There should be 1 json scope displayed in this tabpanel."); |
michael@0 | 61 | is(tabpanel.querySelectorAll(".variables-view-property").length, 2, |
michael@0 | 62 | "There should be 2 json properties displayed in this tabpanel."); |
michael@0 | 63 | is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, |
michael@0 | 64 | "The empty notice should not be displayed in this tabpanel."); |
michael@0 | 65 | |
michael@0 | 66 | let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; |
michael@0 | 67 | is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), |
michael@0 | 68 | "greeting", "The first json property name was incorrect."); |
michael@0 | 69 | is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), |
michael@0 | 70 | "\"Hello third-party JSON!\"", "The first json property value was incorrect."); |
michael@0 | 71 | |
michael@0 | 72 | is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), |
michael@0 | 73 | "__proto__", "The second json property name was incorrect."); |
michael@0 | 74 | is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), |
michael@0 | 75 | "Object", "The second json property value was incorrect."); |
michael@0 | 76 | } |
michael@0 | 77 | }); |
michael@0 | 78 | |
michael@0 | 79 | aDebuggee.performRequests(); |
michael@0 | 80 | }); |
michael@0 | 81 | } |