diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /netwerk/test/unit/test_stale-while-revalidate_loop.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_stale-while-revalidate_loop.js')
-rw-r--r-- | netwerk/test/unit/test_stale-while-revalidate_loop.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_stale-while-revalidate_loop.js b/netwerk/test/unit/test_stale-while-revalidate_loop.js new file mode 100644 index 0000000000..dc28815119 --- /dev/null +++ b/netwerk/test/unit/test_stale-while-revalidate_loop.js @@ -0,0 +1,43 @@ +/* + +Tests the Cache-control: stale-while-revalidate response directive. + +Loads a HTTPS resource with the stale-while-revalidate and tries to load it +twice. + +*/ + +"use strict"; + +function make_channel(url) { + return NetUtil.newChannel({ + uri: url, + loadUsingSystemPrincipal: true, + }).QueryInterface(Ci.nsIHttpChannel); +} + +async function get_response(channel, fromCache) { + return new Promise(resolve => { + channel.asyncOpen( + new ChannelListener((request, buffer, ctx, isFromCache) => { + resolve(buffer); + }) + ); + }); +} + +add_task(async function () { + do_get_profile(); + const PORT = Services.env.get("MOZHTTP2_PORT"); + const URI = `https://localhost:${PORT}/stale-while-revalidate-loop-test`; + + let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService( + Ci.nsIX509CertDB + ); + addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u"); + + let response = await get_response(make_channel(URI), false); + ok(response == "1", "got response ver 1"); + response = await get_response(make_channel(URI), false); + ok(response == "1", "got response ver 1"); +}); |