1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_large-response.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 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 large response contents are just displayed as plain text. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + // This test could potentially be slow because over 100 KB of stuff 1.16 + // is going to be requested and displayed in the source editor. 1.17 + requestLongerTimeout(2); 1.18 + 1.19 + let { document, Editor, 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=html-long", { 1.27 + status: 200, 1.28 + statusText: "OK" 1.29 + }); 1.30 + 1.31 + aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => { 1.32 + NetMonitorView.editor("#response-content-textarea").then((aEditor) => { 1.33 + ok(aEditor.getText().match(/^<p>/), 1.34 + "The text shown in the source editor is incorrect."); 1.35 + is(aEditor.getMode(), Editor.modes.text, 1.36 + "The mode active in the source editor is incorrect."); 1.37 + 1.38 + teardown(aMonitor).then(finish); 1.39 + }); 1.40 + }); 1.41 + 1.42 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.43 + document.getElementById("details-pane-toggle")); 1.44 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.45 + document.querySelectorAll("#details-pane tab")[3]); 1.46 + }); 1.47 + 1.48 + aDebuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=html-long"); 1.49 + }); 1.50 + 1.51 + // This test uses a lot of memory, so force a GC to help fragmentation. 1.52 + info("Forcing GC after netmonitor test."); 1.53 + Cu.forceGC(); 1.54 +}