diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /netwerk/test/unit/test_brotli_http.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_brotli_http.js')
-rw-r--r-- | netwerk/test/unit/test_brotli_http.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_brotli_http.js b/netwerk/test/unit/test_brotli_http.js new file mode 100644 index 0000000000..5c3d2452f0 --- /dev/null +++ b/netwerk/test/unit/test_brotli_http.js @@ -0,0 +1,44 @@ +// This test exists mostly as documentation that +// Firefox can load brotli files over HTTP if we set the proper pref. + +"use strict"; + +function contentHandler(metadata, response) { + response.setHeader("Content-Type", "text/plain", false); + response.setHeader("Content-Encoding", "br", false); + response.write("\x0b\x02\x80hello\x03"); +} + +const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js"); + +XPCOMUtils.defineLazyGetter(this, "URL", function() { + return "http://localhost:" + httpServer.identity.primaryPort + "/content"; +}); + +var httpServer = null; + +add_task(async function test() { + httpServer = new HttpServer(); + httpServer.registerPathHandler("/content", contentHandler); + httpServer.start(-1); + Services.prefs.setCharPref( + "network.http.accept-encoding", + "gzip, deflate, br" + ); + + let chan = NetUtil.newChannel({ uri: URL, loadUsingSystemPrincipal: true }); + let [, buff] = await new Promise(resolve => { + chan.asyncOpen( + new ChannelListener( + (req, buff) => { + resolve([req, buff]); + }, + null, + CL_IGNORE_CL + ) + ); + }); + equal(buff, "hello"); + Services.prefs.clearUserPref("network.http.accept-encoding"); + await httpServer.stop(); +}); |