michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if very long JSON responses are handled correctly. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: // This is receiving over 80 KB of json and will populate over 6000 items michael@0: // in a variables view instance. Debug builds are slow. michael@0: requestLongerTimeout(4); michael@0: michael@0: let { document, L10N, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: waitForNetworkEvents(aMonitor, 1).then(() => { michael@0: verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), michael@0: "GET", CONTENT_TYPE_SJS + "?fmt=json-long", { michael@0: status: 200, michael@0: statusText: "OK", michael@0: type: "json", michael@0: fullMimeType: "text/json; charset=utf-8", michael@0: size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975/1024, 2)), michael@0: time: true michael@0: }); michael@0: michael@0: aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => { michael@0: testResponseTab(); michael@0: teardown(aMonitor).then(finish); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.getElementById("details-pane-toggle")); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.querySelectorAll("#details-pane tab")[3]); michael@0: michael@0: function testResponseTab() { michael@0: let tab = document.querySelectorAll("#details-pane tab")[3]; michael@0: let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; michael@0: michael@0: is(tab.getAttribute("selected"), "true", michael@0: "The response tab in the network details pane should be selected."); michael@0: michael@0: is(tabpanel.querySelector("#response-content-info-header") michael@0: .hasAttribute("hidden"), true, michael@0: "The response info header doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-json-box") michael@0: .hasAttribute("hidden"), false, michael@0: "The response content json box doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-textarea-box") michael@0: .hasAttribute("hidden"), true, michael@0: "The response content textarea box doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-image-box") michael@0: .hasAttribute("hidden"), true, michael@0: "The response content image box doesn't have the intended visibility."); michael@0: michael@0: is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, michael@0: "There should be 1 json scope displayed in this tabpanel."); michael@0: is(tabpanel.querySelectorAll(".variables-view-property").length, 6143, michael@0: "There should be 6143 json properties displayed in this tabpanel."); michael@0: is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, michael@0: "The empty notice should not be displayed in this tabpanel."); michael@0: michael@0: let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; michael@0: let names = ".variables-view-property > .title > .name"; michael@0: let values = ".variables-view-property > .title > .value"; michael@0: michael@0: is(jsonScope.querySelector(".name").getAttribute("value"), michael@0: L10N.getStr("jsonScopeName"), michael@0: "The json scope doesn't have the correct title."); michael@0: michael@0: is(jsonScope.querySelectorAll(names)[0].getAttribute("value"), michael@0: "0", "The first json property name was incorrect."); michael@0: is(jsonScope.querySelectorAll(values)[0].getAttribute("value"), michael@0: "Object", "The first json property value was incorrect."); michael@0: michael@0: is(jsonScope.querySelectorAll(names)[1].getAttribute("value"), michael@0: "greeting", "The second json property name was incorrect."); michael@0: is(jsonScope.querySelectorAll(values)[1].getAttribute("value"), michael@0: "\"Hello long string JSON!\"", "The second json property value was incorrect."); michael@0: } michael@0: }); michael@0: michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: }