Bug 1575341 - WebSocket Inspector Test: Limit number of frames. r=Honza

Test that the truncated message notification displays correctly.

Differential Revision: https://phabricator.services.mozilla.com/D42719

--HG--
extra : moz-landing-system : lando
This commit is contained in:
tanhengyeow 2019-08-30 17:26:40 +00:00
Родитель 2bee21f74c
Коммит 48f4c00ca8
2 изменённых файлов: 65 добавлений и 0 удалений

Просмотреть файл

@ -238,4 +238,5 @@ skip-if = (os == 'win' && os_version == '6.1' && !debug) # Bug 1547150
[browser_net_ws-basic.js]
[browser_net_ws-clear.js]
[browser_net_ws-filter-dropdown.js]
[browser_net_ws-limit-frames.js]
[browser_net-ws-filter-freetext.js]

Просмотреть файл

@ -0,0 +1,64 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test that WS connection is established successfully and the truncated message notification displays correctly.
*/
add_task(async function() {
await pushPref("devtools.netmonitor.features.webSockets", true);
// Set WS frames limit to a lower value for testing
await pushPref("devtools.netmonitor.ws.displayed-frames.limit", 30);
const { tab, monitor } = await initNetMonitor(WS_PAGE_URL);
info("Starting test... ");
const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
// Wait for WS connections to be established + send messages
await ContentTask.spawn(tab.linkedBrowser, {}, async () => {
await content.wrappedJSObject.openConnection(20);
});
const requests = document.querySelectorAll(".request-list-item");
is(requests.length, 1, "There should be one request");
// Wait for truncated message notification to appear
wait = waitForDOM(document, "#messages-panel .truncated-message");
// Select the first request
EventUtils.sendMouseEvent({ type: "mousedown" }, requests[0]);
// Click on the "Messages" panel
EventUtils.sendMouseEvent(
{ type: "click" },
document.querySelector("#messages-tab")
);
await wait;
// Get all messages present in the "Messages" panel
const frames = document.querySelectorAll(
"#messages-panel .ws-frames-list-table .ws-frame-list-item"
);
// Check expected results
is(frames.length, 30, "There should be thirty frames");
is(
document.querySelectorAll("#messages-panel .truncated-message").length,
1,
"Truncated message notification is shown"
);
// Close WS connection
await ContentTask.spawn(tab.linkedBrowser, {}, async () => {
await content.wrappedJSObject.closeConnection();
});
await teardown(monitor);
});