1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
});
|