Bug 1452699 - Work-around caching issues in test_same_site_cookies_*. r?ckerschb
MozReview-Commit-ID: cTH2uyPMTA
--- a/dom/security/test/general/file_same_site_cookies_cross_origin_context.sjs
+++ b/dom/security/test/general/file_same_site_cookies_cross_origin_context.sjs
@@ -21,30 +21,30 @@ const FRAME = `
</body>
</html>`;
function handleRequest(request, response)
{
// avoid confusing cache behaviors
response.setHeader("Cache-Control", "no-cache", false);
- if (request.queryString === "setSameSiteCookie") {
+ if (request.queryString.includes("setSameSiteCookie")) {
response.setHeader("Set-Cookie", "myKey=strictSameSiteCookie; samesite=strict", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
- if (request.queryString === "setRegularCookie") {
+ if (request.queryString.includes("setRegularCookie")) {
response.setHeader("Set-Cookie", "myKey=regularCookie;", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
- if (request.queryString === "loadFrame") {
+ if (request.queryString.includes("loadFrame")) {
response.write(FRAME);
return;
}
// we should never get here, but just in case return something unexpected
response.write("D'oh");
}
--- a/dom/security/test/general/file_same_site_cookies_from_script.sjs
+++ b/dom/security/test/general/file_same_site_cookies_from_script.sjs
@@ -29,21 +29,21 @@ const GET_COOKIE_FRAME = `
</body>
</html>`;
function handleRequest(request, response)
{
// avoid confusing cache behaviors
response.setHeader("Cache-Control", "no-cache", false);
- if (request.queryString === "setSameSiteCookieUsingInlineScript") {
+ if (request.queryString.includes("setSameSiteCookieUsingInlineScript")) {
response.write(SET_COOKIE_FRAME);
return;
}
- if (request.queryString === "getCookieFrame") {
+ if (request.queryString.includes("getCookieFrame")) {
response.write(GET_COOKIE_FRAME);
return;
}
// we should never get here, but just in case return something unexpected
response.write("D'oh");
}
--- a/dom/security/test/general/file_same_site_cookies_subrequest.sjs
+++ b/dom/security/test/general/file_same_site_cookies_subrequest.sjs
@@ -16,44 +16,44 @@ const FRAME = `
</body>
</html>`;
function handleRequest(request, response)
{
// avoid confusing cache behaviors
response.setHeader("Cache-Control", "no-cache", false);
- if (request.queryString === "setStrictSameSiteCookie") {
+ if (request.queryString.includes("setStrictSameSiteCookie")) {
response.setHeader("Set-Cookie", "myKey=strictSameSiteCookie; samesite=strict", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
- if (request.queryString === "setLaxSameSiteCookie") {
+ if (request.queryString.includes("setLaxSameSiteCookie")) {
response.setHeader("Set-Cookie", "myKey=laxSameSiteCookie; samesite=lax", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
// save the object state of the initial request, which returns
// async once the server has processed the img request.
- if (request.queryString === "queryresult") {
+ if (request.queryString.includes("queryresult")) {
response.processAsync();
setObjectState("queryResult", response);
return;
}
- if (request.queryString === "loadFrame") {
+ if (request.queryString.includes("loadFrame")) {
response.write(FRAME);
return;
}
- if (request.queryString === "checkCookie") {
+ if (request.queryString.includes("checkCookie")) {
var cookie = "unitialized";
if (request.hasHeader("Cookie")) {
cookie = request.getHeader("Cookie");
}
else {
cookie = "myKey=noCookie";
}
response.setHeader("Content-Type", "image/png");
--- a/dom/security/test/general/file_same_site_cookies_toplevel_nav.sjs
+++ b/dom/security/test/general/file_same_site_cookies_toplevel_nav.sjs
@@ -29,44 +29,44 @@ const WIN = `
</body>
</html>`;
function handleRequest(request, response)
{
// avoid confusing cache behaviors
response.setHeader("Cache-Control", "no-cache", false);
- if (request.queryString === "setStrictSameSiteCookie") {
+ if (request.queryString.includes("setStrictSameSiteCookie")) {
response.setHeader("Set-Cookie", "myKey=strictSameSiteCookie; samesite=strict", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
- if (request.queryString === "setLaxSameSiteCookie") {
+ if (request.queryString.includes("setLaxSameSiteCookie")) {
response.setHeader("Set-Cookie", "myKey=laxSameSiteCookie; samesite=lax", true);
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
return;
}
// save the object state of the initial request, which returns
// async once the server has processed the img request.
- if (request.queryString === "queryresult") {
+ if (request.queryString.includes("queryresult")) {
response.processAsync();
setObjectState("queryResult", response);
return;
}
- if (request.queryString === "loadFrame") {
+ if (request.queryString.includes("loadFrame")) {
response.write(FRAME);
return;
}
- if (request.queryString === "loadWin") {
+ if (request.queryString.includes("loadWin")) {
var cookie = "unitialized";
if (request.hasHeader("Cookie")) {
cookie = request.getHeader("Cookie");
}
else {
cookie = "myKey=noCookie";
}
response.write(WIN);
--- a/dom/security/test/general/test_same_site_cookies_cross_origin_context.html
+++ b/dom/security/test/general/test_same_site_cookies_cross_origin_context.html
@@ -47,41 +47,41 @@ var tests = [
];
window.addEventListener("message", receiveMessage);
function receiveMessage(event) {
is(event.data.result, tests[curTest].result, tests[curTest].description);
curTest += 1;
- // // lets see if we ran all the tests
+ // lets see if we ran all the tests
if (curTest == tests.length) {
window.removeEventListener("message", receiveMessage);
SimpleTest.finish();
return;
}
// otherwise it's time to run the next test
setCookieAndInitTest();
}
function setupQueryResultAndRunTest() {
let testframe = document.getElementById("testframe");
- testframe.src = tests[curTest].frameSRC;
+ testframe.src = tests[curTest].frameSRC + curTest;
}
function setCookieAndInitTest() {
var cookieImage = document.getElementById("cookieImage");
cookieImage.onload = function() {
ok(true, "trying to set cookie for test (" + tests[curTest].description + ")");
setupQueryResultAndRunTest();
}
cookieImage.onerror = function() {
ok(false, "could not load image for test (" + tests[curTest].description + ")");
}
- cookieImage.src = tests[curTest].imgSRC;
+ cookieImage.src = tests[curTest].imgSRC + curTest;
}
// fire up the test
setCookieAndInitTest();
</script>
</body>
</html>
--- a/dom/security/test/general/test_same_site_cookies_from_script.html
+++ b/dom/security/test/general/test_same_site_cookies_from_script.html
@@ -58,29 +58,29 @@ function receiveMessage(event) {
return;
}
// otherwise it's time to run the next test
setCookieAndInitTest();
}
function setupQueryResultAndRunTest() {
let getCookieFrame = document.getElementById("getCookieFrame");
- getCookieFrame.src = tests[curTest].getCookieSrc;
+ getCookieFrame.src = tests[curTest].getCookieSrc + curTest;
}
function setCookieAndInitTest() {
var cookieFrame = document.getElementById("setCookieFrame");
setCookieFrame.onload = function() {
ok(true, "trying to set cookie for test (" + tests[curTest].description + ")");
setupQueryResultAndRunTest();
}
setCookieFrame.onerror = function() {
ok(false, "could not load image for test (" + tests[curTest].description + ")");
}
- cookieFrame.src = tests[curTest].setCookieSrc;
+ cookieFrame.src = tests[curTest].setCookieSrc + curTest;
}
// fire up the test
setCookieAndInitTest();
</script>
</body>
</html>
--- a/dom/security/test/general/test_same_site_cookies_subrequest.html
+++ b/dom/security/test/general/test_same_site_cookies_subrequest.html
@@ -72,42 +72,42 @@ function checkResult(aCookieVal) {
return;
}
// otherwise it's time to run the next test
setCookieAndInitTest();
}
function setupQueryResultAndRunTest() {
var myXHR = new XMLHttpRequest();
- myXHR.open("GET", "file_same_site_cookies_subrequest.sjs?queryresult");
+ myXHR.open("GET", "file_same_site_cookies_subrequest.sjs?queryresult" + curTest);
myXHR.onload = function(e) {
checkResult(myXHR.responseText);
}
myXHR.onerror = function(e) {
ok(false, "could not query results from server (" + e.message + ")");
}
myXHR.send();
// give it some time and load the test frame
SimpleTest.executeSoon(function() {
let testframe = document.getElementById("testframe");
- testframe.src = tests[curTest].frameSRC;
+ testframe.src = tests[curTest].frameSRC + curTest;
});
}
function setCookieAndInitTest() {
var cookieImage = document.getElementById("cookieImage");
cookieImage.onload = function() {
ok(true, "set cookie for test (" + tests[curTest].description + ")");
setupQueryResultAndRunTest();
}
cookieImage.onerror = function() {
ok(false, "could not set cookie for test (" + tests[curTest].description + ")");
}
- cookieImage.src = tests[curTest].imgSRC;
+ cookieImage.src = tests[curTest].imgSRC + curTest;
}
// fire up the test
setCookieAndInitTest();
</script>
</body>
</html>
--- a/dom/security/test/general/test_same_site_cookies_toplevel_nav.html
+++ b/dom/security/test/general/test_same_site_cookies_toplevel_nav.html
@@ -73,42 +73,42 @@ function checkResult(aCookieVal) {
return;
}
// otherwise it's time to run the next test
setCookieAndInitTest();
}
function setupQueryResultAndRunTest() {
var myXHR = new XMLHttpRequest();
- myXHR.open("GET", "file_same_site_cookies_toplevel_nav.sjs?queryresult");
+ myXHR.open("GET", "file_same_site_cookies_toplevel_nav.sjs?queryresult" + curTest);
myXHR.onload = function(e) {
checkResult(myXHR.responseText);
}
myXHR.onerror = function(e) {
ok(false, "could not query results from server (" + e.message + ")");
}
myXHR.send();
// give it some time and load the test window
SimpleTest.executeSoon(function() {
let testframe = document.getElementById("testframe");
- testframe.src = tests[curTest].frameSRC;
+ testframe.src = tests[curTest].frameSRC + curTest;
});
}
function setCookieAndInitTest() {
var cookieImage = document.getElementById("cookieImage");
cookieImage.onload = function() {
ok(true, "set cookie for test (" + tests[curTest].description + ")");
setupQueryResultAndRunTest();
}
cookieImage.onerror = function() {
ok(false, "could not set cookie for test (" + tests[curTest].description + ")");
}
- cookieImage.src = tests[curTest].imgSRC;
+ cookieImage.src = tests[curTest].imgSRC + curTest;
}
// fire up the test
setCookieAndInitTest();
</script>
</body>
</html>