From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/unit/test_stale-while-revalidate_loop.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 netwerk/test/unit/test_stale-while-revalidate_loop.js (limited to 'netwerk/test/unit/test_stale-while-revalidate_loop.js') 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"); +}); -- cgit v1.2.3