1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_json-long.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 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 very long JSON responses are handled correctly. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + // This is receiving over 80 KB of json and will populate over 6000 items 1.16 + // in a variables view instance. Debug builds are slow. 1.17 + requestLongerTimeout(4); 1.18 + 1.19 + let { document, L10N, NetMonitorView } = aMonitor.panelWin; 1.20 + let { RequestsMenu } = NetMonitorView; 1.21 + 1.22 + RequestsMenu.lazyUpdate = false; 1.23 + 1.24 + waitForNetworkEvents(aMonitor, 1).then(() => { 1.25 + verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), 1.26 + "GET", CONTENT_TYPE_SJS + "?fmt=json-long", { 1.27 + status: 200, 1.28 + statusText: "OK", 1.29 + type: "json", 1.30 + fullMimeType: "text/json; charset=utf-8", 1.31 + size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)), 1.32 + time: true 1.33 + }); 1.34 + 1.35 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => { 1.36 + testResponseTab(); 1.37 + teardown(aMonitor).then(finish); 1.38 + }); 1.39 + 1.40 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.41 + document.getElementById("details-pane-toggle")); 1.42 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.43 + document.querySelectorAll("#details-pane tab")[3]); 1.44 + 1.45 + function testResponseTab() { 1.46 + let tab = document.querySelectorAll("#details-pane tab")[3]; 1.47 + let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; 1.48 + 1.49 + is(tab.getAttribute("selected"), "true", 1.50 + "The response tab in the network details pane should be selected."); 1.51 + 1.52 + is(tabpanel.querySelector("#response-content-info-header") 1.53 + .hasAttribute("hidden"), true, 1.54 + "The response info header doesn't have the intended visibility."); 1.55 + is(tabpanel.querySelector("#response-content-json-box") 1.56 + .hasAttribute("hidden"), false, 1.57 + "The response content json box doesn't have the intended visibility."); 1.58 + is(tabpanel.querySelector("#response-content-textarea-box") 1.59 + .hasAttribute("hidden"), true, 1.60 + "The response content textarea box doesn't have the intended visibility."); 1.61 + is(tabpanel.querySelector("#response-content-image-box") 1.62 + .hasAttribute("hidden"), true, 1.63 + "The response content image box doesn't have the intended visibility."); 1.64 + 1.65 + is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, 1.66 + "There should be 1 json scope displayed in this tabpanel."); 1.67 + is(tabpanel.querySelectorAll(".variables-view-property").length, 6143, 1.68 + "There should be 6143 json properties displayed in this tabpanel."); 1.69 + is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, 1.70 + "The empty notice should not be displayed in this tabpanel."); 1.71 + 1.72 + let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; 1.73 + let names = ".variables-view-property > .title > .name"; 1.74 + let values = ".variables-view-property > .title > .value"; 1.75 + 1.76 + is(jsonScope.querySelector(".name").getAttribute("value"), 1.77 + L10N.getStr("jsonScopeName"), 1.78 + "The json scope doesn't have the correct title."); 1.79 + 1.80 + is(jsonScope.querySelectorAll(names)[0].getAttribute("value"), 1.81 + "0", "The first json property name was incorrect."); 1.82 + is(jsonScope.querySelectorAll(values)[0].getAttribute("value"), 1.83 + "Object", "The first json property value was incorrect."); 1.84 + 1.85 + is(jsonScope.querySelectorAll(names)[1].getAttribute("value"), 1.86 + "greeting", "The second json property name was incorrect."); 1.87 + is(jsonScope.querySelectorAll(values)[1].getAttribute("value"), 1.88 + "\"Hello long string JSON!\"", "The second json property value was incorrect."); 1.89 + } 1.90 + }); 1.91 + 1.92 + aDebuggee.performRequests(); 1.93 + }); 1.94 +}