forked from mirrors/gecko-dev
Bug 1891610 - added zstd support to devtools. r=jesup,bomsy,necko-reviewers,devtools-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D207490
This commit is contained in:
parent
a6e0c6ac68
commit
b41bb321fe
6 changed files with 139 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ support-files = [
|
|||
"html_cause-test-page.html",
|
||||
"html_content-type-without-cache-test-page.html",
|
||||
"html_brotli-test-page.html",
|
||||
"html_zstd-test-page.html",
|
||||
"html_image-tooltip-test-page.html",
|
||||
"html_cache-test-page.html",
|
||||
"html_cors-test-page.html",
|
||||
|
|
@ -558,3 +559,5 @@ fail-if = ["a11y_checks"] # Bug 1849028 clicked element may not be focusable and
|
|||
["browser_net_ws-sse-persist-columns.js"]
|
||||
|
||||
["browser_net_ws-stomp-payload.js"]
|
||||
|
||||
["browser_net_zstd.js"]
|
||||
|
|
|
|||
81
devtools/client/netmonitor/test/browser_net_zstd.js
Normal file
81
devtools/client/netmonitor/test/browser_net_zstd.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const ZSTD_URL = HTTPS_EXAMPLE_URL + "html_zstd-test-page.html";
|
||||
const ZSTD_REQUESTS = 1;
|
||||
|
||||
/**
|
||||
* Test zstd encoded response is handled correctly on HTTPS.
|
||||
*/
|
||||
|
||||
add_task(async function () {
|
||||
const {
|
||||
L10N,
|
||||
} = require("resource://devtools/client/netmonitor/src/utils/l10n.js");
|
||||
|
||||
const { tab, monitor } = await initNetMonitor(ZSTD_URL, {
|
||||
requestCount: 1,
|
||||
});
|
||||
info("Starting test... ");
|
||||
|
||||
const { document, store, windowRequire } = monitor.panelWin;
|
||||
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
||||
const { getDisplayedRequests, getSortedRequests } = windowRequire(
|
||||
"devtools/client/netmonitor/src/selectors/index"
|
||||
);
|
||||
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
// Execute requests.
|
||||
await performRequests(monitor, tab, ZSTD_REQUESTS);
|
||||
|
||||
const requestItem = document.querySelector(".request-list-item");
|
||||
// Status code title is generated on hover
|
||||
const requestsListStatus = requestItem.querySelector(".status-code");
|
||||
EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus);
|
||||
await waitUntil(() => requestsListStatus.title);
|
||||
await waitForDOMIfNeeded(requestItem, ".requests-list-timings-total");
|
||||
|
||||
verifyRequestItemTarget(
|
||||
document,
|
||||
getDisplayedRequests(store.getState()),
|
||||
getSortedRequests(store.getState())[0],
|
||||
"GET",
|
||||
HTTPS_CONTENT_TYPE_SJS + "?fmt=zstd",
|
||||
{
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 261),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 64),
|
||||
time: true,
|
||||
}
|
||||
);
|
||||
|
||||
const wait = waitForDOM(document, ".CodeMirror-code");
|
||||
const onResponseContent = monitor.panelWin.api.once(
|
||||
TEST_EVENTS.RECEIVED_RESPONSE_CONTENT
|
||||
);
|
||||
store.dispatch(Actions.toggleNetworkDetails());
|
||||
clickOnSidebarTab(document, "response");
|
||||
await wait;
|
||||
await onResponseContent;
|
||||
await testResponse("zstd");
|
||||
await teardown(monitor);
|
||||
|
||||
function testResponse(type) {
|
||||
switch (type) {
|
||||
case "zstd": {
|
||||
is(
|
||||
getCodeMirrorValue(monitor),
|
||||
"X".repeat(64),
|
||||
"The text shown in the source editor is incorrect for the zstd request."
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
41
devtools/client/netmonitor/test/html_zstd-test-page.html
Normal file
41
devtools/client/netmonitor/test/html_zstd-test-page.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Zstd test</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* exported performRequests */
|
||||
"use strict";
|
||||
|
||||
function get(address) {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", address, true);
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if (this.readyState == this.DONE) {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
async function performRequests() {
|
||||
await get("sjs_content-type-test-server.sjs?fmt=zstd");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -372,6 +372,18 @@ function handleRequest(request, response) {
|
|||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "zstd": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/json", false);
|
||||
response.setHeader("Content-Encoding", "zstd", false);
|
||||
setCacheHeaders();
|
||||
// Use static data since we cannot encode zstandard.
|
||||
const data = "(\xb5/\xfd @E\x00\x00\x10XX\x01\x00\x93\x00\x16";
|
||||
response.setHeader("Content-Length", "" + data.length, false);
|
||||
response.write(data);
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "hls-m3u8": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "application/x-mpegurl", false);
|
||||
|
|
|
|||
|
|
@ -317,6 +317,7 @@ export class NetworkResponseListener {
|
|||
"br",
|
||||
"x-gzip",
|
||||
"x-deflate",
|
||||
"zstd",
|
||||
];
|
||||
for (const i in encodings) {
|
||||
// There can be multiple conversions applied
|
||||
|
|
|
|||
|
|
@ -646,6 +646,7 @@ Classes = [
|
|||
'@mozilla.org/streamconv;1?from=gzip&to=uncompressed',
|
||||
'@mozilla.org/streamconv;1?from=x-compress&to=uncompressed',
|
||||
'@mozilla.org/streamconv;1?from=x-gzip&to=uncompressed',
|
||||
'@mozilla.org/streamconv;1?from=zstd&to=uncompressed',
|
||||
],
|
||||
'legacy_constructor': 'CreateNewHTTPCompressConvFactory',
|
||||
'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
|
||||
|
|
|
|||
Loading…
Reference in a new issue