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