tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_net_ws-limit-frames.js (2009B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that WS connection is established successfully and the truncated message notification displays correctly.
      8 */
      9 
     10 add_task(async function () {
     11  // Set WS messages limit to a lower value for testing
     12  await pushPref("devtools.netmonitor.msg.displayed-messages.limit", 30);
     13 
     14  const { tab, monitor } = await initNetMonitor(WS_PAGE_URL, {
     15    requestCount: 1,
     16  });
     17  info("Starting test... ");
     18 
     19  const { document, store, windowRequire } = monitor.panelWin;
     20  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     21 
     22  store.dispatch(Actions.batchEnable(false));
     23 
     24  // Wait for WS connections to be established + send messages
     25  const onNetworkEvents = waitForNetworkEvents(monitor, 1);
     26  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     27    await content.wrappedJSObject.openConnection(20);
     28  });
     29  await onNetworkEvents;
     30 
     31  const requests = document.querySelectorAll(".request-list-item");
     32  is(requests.length, 1, "There should be one request");
     33 
     34  // Wait for truncated message notification to appear
     35  const wait = waitForDOM(document, "#messages-view .truncated-message");
     36 
     37  // Select the first request
     38  EventUtils.sendMouseEvent({ type: "mousedown" }, requests[0]);
     39 
     40  // Click on the "Response" panel
     41  clickOnSidebarTab(document, "response");
     42  await wait;
     43 
     44  // Get all messages present in the "Response" panel
     45  const frames = document.querySelectorAll(
     46    "#messages-view .message-list-table .message-list-item"
     47  );
     48 
     49  // Check expected results
     50  is(frames.length, 30, "There should be thirty frames");
     51  is(
     52    document.querySelectorAll("#messages-view .truncated-message").length,
     53    1,
     54    "Truncated message notification is shown"
     55  );
     56 
     57  // Close WS connection
     58  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     59    await content.wrappedJSObject.closeConnection();
     60  });
     61 
     62  await teardown(monitor);
     63 });