--- a/dom/security/test/general/test_same_site_cookies_about.html
+++ b/dom/security/test/general/test_same_site_cookies_about.html
@@ -18,100 +18,159 @@
* (a) cross-origin iframe
* (b) same-origin iframe
* which both load a:
* * nested about:srcdoc frame and nested about:blank frame
* * navigate about:srcdoc frame and navigate about:blank frame
* 3) We evaluate that the same-site cookie is available in the same-origin case.
*/
+SimpleTest.registerCleanupFunction(() => {
+ SpecialPowers.clearUserPref("network.cookie.same-site.enabled");
+});
SimpleTest.waitForExplicitFinish();
const SAME_ORIGIN = "http://mochi.test:8888/"
const CROSS_ORIGIN = "http://example.com/";
const PATH = "tests/dom/security/test/general/file_same_site_cookies_about.sjs";
let curTest = 0;
var tests = [
// NAVIGATION TESTS
{
description: "nested same origin iframe about:srcdoc navigation [mochi.test -> mochi.test -> about:srcdoc -> mochi.test]",
frameSRC: SAME_ORIGIN + PATH + "?loadsrcdocframeNav",
+ sameSiteEnabled: true,
result: "myKey=mySameSiteAboutCookie", // cookie should be set for baseline test
},
{
description: "nested cross origin iframe about:srcdoc navigation [mochi.test -> example.com -> about:srcdoc -> mochi.test]",
frameSRC: CROSS_ORIGIN + PATH + "?loadsrcdocframeNav",
+ sameSiteEnabled: true,
result: "", // no same-site cookie should be available
},
{
description: "nested same origin iframe about:blank navigation [mochi.test -> mochi.test -> about:blank -> mochi.test]",
frameSRC: SAME_ORIGIN + PATH + "?loadblankframeNav",
+ sameSiteEnabled: true,
result: "myKey=mySameSiteAboutCookie", // cookie should be set for baseline test
},
{
description: "nested cross origin iframe about:blank navigation [mochi.test -> example.com -> about:blank -> mochi.test]",
frameSRC: CROSS_ORIGIN + PATH + "?loadblankframeNav",
+ sameSiteEnabled: true,
result: "", // no same-site cookie should be available
},
+ {
+ description: "nested same origin iframe about:srcdoc navigation [mochi.test -> mochi.test -> about:srcdoc -> mochi.test] (same-site off)",
+ frameSRC: SAME_ORIGIN + PATH + "?loadsrcdocframeNav",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested cross origin iframe about:srcdoc navigation [mochi.test -> example.com -> about:srcdoc -> mochi.test] (same-site off)",
+ frameSRC: CROSS_ORIGIN + PATH + "?loadsrcdocframeNav",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested same origin iframe about:blank navigation [mochi.test -> mochi.test -> about:blank -> mochi.test] (same-site off)",
+ frameSRC: SAME_ORIGIN + PATH + "?loadblankframeNav",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested cross origin iframe about:blank navigation [mochi.test -> example.com -> about:blank -> mochi.test] (same-site off)",
+ frameSRC: CROSS_ORIGIN + PATH + "?loadblankframeNav",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
// INCLUSION TESTS
{
description: "nested same origin iframe about:srcdoc inclusion [mochi.test -> mochi.test -> about:srcdoc -> mochi.test]",
frameSRC: SAME_ORIGIN + PATH + "?loadsrcdocframeInc",
+ sameSiteEnabled: true,
result: "myKey=mySameSiteAboutCookie", // cookie should be set for baseline test
},
{
description: "nested cross origin iframe about:srcdoc inclusion [mochi.test -> example.com -> about:srcdoc -> mochi.test]",
frameSRC: CROSS_ORIGIN + PATH + "?loadsrcdocframeInc",
+ sameSiteEnabled: true,
result: "", // no same-site cookie should be available
},
{
description: "nested same origin iframe about:blank inclusion [mochi.test -> mochi.test -> about:blank -> mochi.test]",
frameSRC: SAME_ORIGIN + PATH + "?loadblankframeInc",
+ sameSiteEnabled: true,
result: "myKey=mySameSiteAboutCookie", // cookie should be set for baseline test
},
{
description: "nested cross origin iframe about:blank inclusion [mochi.test -> example.com -> about:blank -> mochi.test]",
frameSRC: CROSS_ORIGIN + PATH + "?loadblankframeInc",
+ sameSiteEnabled: true,
result: "", // no same-site cookie should be available
},
+ {
+ description: "nested same origin iframe about:srcdoc inclusion [mochi.test -> mochi.test -> about:srcdoc -> mochi.test] (same-site off)",
+ frameSRC: SAME_ORIGIN + PATH + "?loadsrcdocframeInc",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested cross origin iframe about:srcdoc inclusion [mochi.test -> example.com -> about:srcdoc -> mochi.test] (same-site off)",
+ frameSRC: CROSS_ORIGIN + PATH + "?loadsrcdocframeInc",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested same origin iframe about:blank inclusion [mochi.test -> mochi.test -> about:blank -> mochi.test] (same-site off)",
+ frameSRC: SAME_ORIGIN + PATH + "?loadblankframeInc",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
+ {
+ description: "nested cross origin iframe about:blank inclusion [mochi.test -> example.com -> about:blank -> mochi.test] (same-site off)",
+ frameSRC: CROSS_ORIGIN + PATH + "?loadblankframeInc",
+ sameSiteEnabled: false,
+ result: "myKey=mySameSiteAboutCookie",
+ },
];
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() {
+ SpecialPowers.setBoolPref("network.cookie.same-site.enabled", tests[curTest].sameSiteEnabled);
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 + ")");
}
- // appending math.random to avoid any unexpected caching behavior
- cookieImage.src = SAME_ORIGIN + PATH + "?setSameSiteCookie" + Math.random();
+ cookieImage.src = SAME_ORIGIN + PATH + "?setSameSiteCookie" + curTest;
}
// fire up the test
setCookieAndInitTest();
</script>
</body>
</html>