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
--- a/dom/media/test/dynamic_redirect.sjs
+++ b/dom/media/test/dynamic_redirect.sjs
@@ -58,11 +58,12 @@ function handleRequest(request, response
dump("Response Content-Range = "+ contentRange +"\n");
dump("Response Content-Length = "+ contentLength +"\n");
response.setStatusLine(request.httpVersion, 206, "Partial Content");
response.setHeader("Content-Range", contentRange);
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();
}
--- a/dom/media/test/midflight-redirect.sjs
+++ b/dom/media/test/midflight-redirect.sjs
@@ -59,14 +59,15 @@ function handleRequest(request, response
let contentRange = "bytes "+ from +"-"+ to +"/"+ bytes.length;
let contentLength = (to - from + 1).toString();
response.setStatusLine(request.httpVersion, 206, "Partial Content");
response.setHeader("Content-Range", contentRange);
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", "*");
}
response.write(byterange, byterange.length);
bis.close();
}
--- a/dom/media/test/test_midflight_redirect_blocked.html
+++ b/dom/media/test/test_midflight_redirect_blocked.html
@@ -36,19 +36,21 @@
removeNodeAndSource(element);
}, false);
element.addEventListener("error", ()=>{
resolve(false);
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()
});
}
let v = document.createElement("video");
const testCases = gSmallTests.filter(t => v.canPlayType(t.type));