diff options
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_truncate.js')
-rw-r--r-- | devtools/client/netmonitor/test/browser_net_truncate.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_truncate.js b/devtools/client/netmonitor/test/browser_net_truncate.js new file mode 100644 index 0000000000..77e6451f7e --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_truncate.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Verifies that truncated response bodies still have the correct reported size. + */ +add_task(async function () { + const limit = Services.prefs.getIntPref( + "devtools.netmonitor.responseBodyLimit" + ); + const URL = EXAMPLE_URL + "sjs_truncate-test-server.sjs?limit=" + limit; + const { monitor } = await initNetMonitor(URL, { requestCount: 1 }); + + info("Starting test... "); + + const { + L10N, + } = require("resource://devtools/client/netmonitor/src/utils/l10n.js"); + + const { document } = monitor.panelWin; + + const wait = waitForNetworkEvents(monitor, 1); + await reloadBrowser(); + await wait; + + // Response content will be updated asynchronously, we should make sure data is updated + // on DOM before asserting. + await waitUntil(() => document.querySelector(".request-list-item")); + const item = document.querySelectorAll(".request-list-item")[0]; + await waitUntil(() => item.querySelector(".requests-list-type").title); + + const type = item.querySelector(".requests-list-type").textContent; + const fullMimeType = item.querySelector(".requests-list-type").title; + const transferred = item.querySelector( + ".requests-list-transferred" + ).textContent; + const size = item.querySelector(".requests-list-size").textContent; + + is(type, "plain", "Type should be rendered correctly."); + is( + fullMimeType, + "text/plain; charset=utf-8", + "Mimetype should be rendered correctly." + ); + is( + transferred, + L10N.getFormatStrWithNumbers("networkMenu.sizeMB", 2.1), + "Transferred size should be rendered correctly." + ); + is( + size, + L10N.getFormatStrWithNumbers("networkMenu.sizeMB", 2.1), + "Size should be rendered correctly." + ); + + return teardown(monitor); +}); |