browser_net_large-response.js (2798B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests if very large response contents are just displayed as plain text. 8 */ 9 10 const HTML_LONG_URL = CONTENT_TYPE_SJS + "?fmt=html-long"; 11 12 add_task(async function () { 13 const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, { 14 requestCount: 1, 15 }); 16 info("Starting test... "); 17 18 // This test could potentially be slow because over 100 KB of stuff 19 // is going to be requested and displayed in the source editor. 20 requestLongerTimeout(2); 21 22 const { document, store, windowRequire } = monitor.panelWin; 23 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 24 const { getDisplayedRequests, getSortedRequests } = windowRequire( 25 "devtools/client/netmonitor/src/selectors/index" 26 ); 27 28 store.dispatch(Actions.batchEnable(false)); 29 30 let wait = waitForNetworkEvents(monitor, 1); 31 await SpecialPowers.spawn( 32 tab.linkedBrowser, 33 [HTML_LONG_URL], 34 async function (url) { 35 content.wrappedJSObject.performRequests(1, url); 36 } 37 ); 38 await wait; 39 40 const requestItem = document.querySelector(".request-list-item"); 41 requestItem.scrollIntoView(); 42 const requestsListStatus = requestItem.querySelector(".status-code"); 43 EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus); 44 await waitUntil(() => requestsListStatus.title); 45 await waitForDOMIfNeeded(requestItem, ".requests-list-timings-total"); 46 47 await verifyRequestItemTarget( 48 document, 49 getDisplayedRequests(store.getState()), 50 getSortedRequests(store.getState())[0], 51 "GET", 52 CONTENT_TYPE_SJS + "?fmt=html-long", 53 { 54 status: 200, 55 statusText: "OK", 56 } 57 ); 58 59 wait = waitForDOM(document, "#response-panel .data-header"); 60 store.dispatch(Actions.toggleNetworkDetails()); 61 clickOnSidebarTab(document, "response"); 62 await wait; 63 64 wait = waitForDOM(document, "#response-panel .cm-content"); 65 const payloadHeader = document.querySelector( 66 "#response-panel .raw-data-toggle-input .devtools-checkbox-toggle" 67 ); 68 clickElement(payloadHeader, monitor); 69 await wait; 70 71 ok( 72 getCodeMirrorValue(monitor).match(/^<p>/), 73 "The text shown in the source editor is incorrect." 74 ); 75 76 info("Check that search input can be displayed"); 77 getCMEditor(monitor).focus(); 78 synthesizeKeyShortcut("CmdOrCtrl+F"); 79 const searchInput = await waitFor(() => 80 document.querySelector(".cm-editor .cm-search input.cm-textfield") 81 ); 82 Assert.equal( 83 searchInput.ownerDocument.activeElement, 84 searchInput, 85 "search input is focused" 86 ); 87 88 await teardown(monitor); 89 90 // This test uses a lot of memory, so force a GC to help fragmentation. 91 info("Forcing GC after netmonitor test."); 92 Cu.forceGC(); 93 });