Bug 1219556 - report full body size from NetworkResponseListener; r=jryans

MozReview-Commit-ID: LMMycsbcRg1

--HG--
extra : rebase_source : 7d1a89930eb10e611a8d84641c12f3473a67b46d
This commit is contained in:
Tom Tromey 2016-12-23 11:11:37 -07:00
Родитель 005c2ba3de
Коммит 826502ca19
5 изменённых файлов: 65 добавлений и 2 удалений

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

@ -43,6 +43,7 @@ support-files =
sjs_simple-test-server.sjs
sjs_sorting-test-server.sjs
sjs_status-codes-test-server.sjs
sjs_truncate-test-server.sjs
test-image.png
service-workers/status-codes.html
service-workers/status-codes-service-worker.js
@ -153,4 +154,5 @@ skip-if = true # Redundant for React/Redux version
[browser_net_timeline_ticks.js]
skip-if = true # TODO: fix the test
[browser_net_timing-division.js]
[browser_net_truncate.js]
[browser_net_persistent_logs.js]

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

@ -57,7 +57,7 @@ add_task(function* () {
statusText: "See Other",
type: "plain",
fullMimeType: "text/plain; charset=utf-8",
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
time: true
}
},

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

@ -0,0 +1,41 @@
/* 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.
*/
function test() {
let { L10N } = require("devtools/client/netmonitor/l10n");
const { RESPONSE_BODY_LIMIT } = require("devtools/shared/webconsole/network-monitor");
const URL = EXAMPLE_URL + "sjs_truncate-test-server.sjs?limit=" + RESPONSE_BODY_LIMIT;
initNetMonitor(URL).then(({ tab, monitor }) => {
info("Starting test... ");
let { NetMonitorView } = monitor.panelWin;
let { RequestsMenu } = NetMonitorView;
RequestsMenu.lazyUpdate = false;
waitForNetworkEvents(monitor, 1)
.then(() => teardown(monitor))
.then(finish);
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => {
let requestItem = RequestsMenu.getItemAtIndex(0);
verifyRequestItemTarget(RequestsMenu, requestItem, "GET", URL, {
type: "plain",
fullMimeType: "text/plain; charset=utf-8",
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeMB", 2),
size: L10N.getFormatStrWithNumbers("networkMenu.sizeMB", 2),
});
});
tab.linkedBrowser.reload();
});
}

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

@ -0,0 +1,18 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function handleRequest(request, response) {
let params = request.queryString.split("&");
let limit = (params.filter((s) => s.includes("limit="))[0] || "").split("=")[1];
response.setStatusLine(request.httpVersion, 200, "Och Aye");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
response.write("x".repeat(2 * parseInt(limit, 10)));
response.write("Hello world!");
}

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

@ -37,6 +37,8 @@ const HTTP_TEMPORARY_REDIRECT = 307;
// The maximum number of bytes a NetworkResponseListener can hold: 1 MB
const RESPONSE_BODY_LIMIT = 1048576;
// Exported for testing.
exports.RESPONSE_BODY_LIMIT = RESPONSE_BODY_LIMIT;
/**
* Check if a given network request should be logged by a network monitor
@ -598,7 +600,7 @@ NetworkResponseListener.prototype = {
text: data || "",
};
response.size = response.text.length;
response.size = this.bodySize;
response.transferredSize = this.transferredSize;
try {