From 5913d0470e44f3ea39a14802f6eb384040bff9e2 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 28 Mar 2018 16:55:46 +1300 Subject: [PATCH] Bug 1443942 - Make redirect SJS' serve with headers to prevent Necko caching. r=jya Try to prevent Necko from caching the results of our SJS media responses, as some of the test that use it rely on the server being hit and serving a redirect. Sometimes the tests which rely on hitting a redirect in an SJS where timing out without this, as Necko would cache the response and not hit the server, and so not hit the redirect. Also include a noise parameter to increase the likelihood that the URL is unique, to further reduce the chance that Necko caches the result. MozReview-Commit-ID: 3cLEiDoh4HG --HG-- extra : rebase_source : 24c152d46540866f14211fae30f1e59c5d23b6d4 --- dom/media/test/dynamic_redirect.sjs | 1 + dom/media/test/midflight-redirect.sjs | 1 + dom/media/test/test_midflight_redirect_blocked.html | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dom/media/test/dynamic_redirect.sjs b/dom/media/test/dynamic_redirect.sjs index c8dd4358368d..60b7aeec4b83 100644 --- a/dom/media/test/dynamic_redirect.sjs +++ b/dom/media/test/dynamic_redirect.sjs @@ -63,6 +63,7 @@ function handleRequest(request, response) response.setHeader("Content-Length", contentLength, false); response.setHeader("Content-Type", type, false); response.setHeader("Accept-Ranges", "bytes", false); + response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.write(byterange, byterange.length); bis.close(); } diff --git a/dom/media/test/midflight-redirect.sjs b/dom/media/test/midflight-redirect.sjs index f8481f7c4ce9..48b0032c916f 100644 --- a/dom/media/test/midflight-redirect.sjs +++ b/dom/media/test/midflight-redirect.sjs @@ -64,6 +64,7 @@ function handleRequest(request, response) response.setHeader("Content-Length", contentLength, false); response.setHeader("Content-Type", type, false); response.setHeader("Accept-Ranges", "bytes", false); + response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); if (redirected && useCors) { response.setHeader("Access-Control-Allow-Origin", "*"); } diff --git a/dom/media/test/test_midflight_redirect_blocked.html b/dom/media/test/test_midflight_redirect_blocked.html index fc2ccacbcd88..3dcd3c965e91 100644 --- a/dom/media/test/test_midflight_redirect_blocked.html +++ b/dom/media/test/test_midflight_redirect_blocked.html @@ -41,9 +41,11 @@ removeNodeAndSource(element); }, false); + var noise = Math.floor(Math.random() * 100000000); element.src = "midflight-redirect.sjs?resource=" + test.name + (useCors ? "&cors" : "") - + "&type=" + test.type; + + "&type=" + test.type + + "&noise=" + noise; element.preload = "metadata"; document.body.appendChild(element); element.load()