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 very long JSON responses are handled correctly.
6 */
8 function test() {
9 initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => {
10 info("Starting test... ");
12 // This is receiving over 80 KB of json and will populate over 6000 items
13 // in a variables view instance. Debug builds are slow.
14 requestLongerTimeout(4);
16 let { document, L10N, NetMonitorView } = aMonitor.panelWin;
17 let { RequestsMenu } = NetMonitorView;
19 RequestsMenu.lazyUpdate = false;
21 waitForNetworkEvents(aMonitor, 1).then(() => {
22 verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
23 "GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
24 status: 200,
25 statusText: "OK",
26 type: "json",
27 fullMimeType: "text/json; charset=utf-8",
28 size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)),
29 time: true
30 });
32 aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => {
33 testResponseTab();
34 teardown(aMonitor).then(finish);
35 });
37 EventUtils.sendMouseEvent({ type: "mousedown" },
38 document.getElementById("details-pane-toggle"));
39 EventUtils.sendMouseEvent({ type: "mousedown" },
40 document.querySelectorAll("#details-pane tab")[3]);
42 function testResponseTab() {
43 let tab = document.querySelectorAll("#details-pane tab")[3];
44 let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
46 is(tab.getAttribute("selected"), "true",
47 "The response tab in the network details pane should be selected.");
49 is(tabpanel.querySelector("#response-content-info-header")
50 .hasAttribute("hidden"), true,
51 "The response info header doesn't have the intended visibility.");
52 is(tabpanel.querySelector("#response-content-json-box")
53 .hasAttribute("hidden"), false,
54 "The response content json box doesn't have the intended visibility.");
55 is(tabpanel.querySelector("#response-content-textarea-box")
56 .hasAttribute("hidden"), true,
57 "The response content textarea box doesn't have the intended visibility.");
58 is(tabpanel.querySelector("#response-content-image-box")
59 .hasAttribute("hidden"), true,
60 "The response content image box doesn't have the intended visibility.");
62 is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
63 "There should be 1 json scope displayed in this tabpanel.");
64 is(tabpanel.querySelectorAll(".variables-view-property").length, 6143,
65 "There should be 6143 json properties displayed in this tabpanel.");
66 is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
67 "The empty notice should not be displayed in this tabpanel.");
69 let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
70 let names = ".variables-view-property > .title > .name";
71 let values = ".variables-view-property > .title > .value";
73 is(jsonScope.querySelector(".name").getAttribute("value"),
74 L10N.getStr("jsonScopeName"),
75 "The json scope doesn't have the correct title.");
77 is(jsonScope.querySelectorAll(names)[0].getAttribute("value"),
78 "0", "The first json property name was incorrect.");
79 is(jsonScope.querySelectorAll(values)[0].getAttribute("value"),
80 "Object", "The first json property value was incorrect.");
82 is(jsonScope.querySelectorAll(names)[1].getAttribute("value"),
83 "greeting", "The second json property name was incorrect.");
84 is(jsonScope.querySelectorAll(values)[1].getAttribute("value"),
85 "\"Hello long string JSON!\"", "The second json property value was incorrect.");
86 }
87 });
89 aDebuggee.performRequests();
90 });
91 }