зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1455162 - Test about: URLs with and without same-site.enabled. r=ckerschb
MozReview-Commit-ID: Wi8SXkGIci --HG-- extra : rebase_source : 88305c0be0117e538bd996626aace14a5a952749
This commit is contained in:
Родитель
df340972e4
Коммит
708b70167e
|
@ -22,7 +22,7 @@ function handleRequest(request, response)
|
|||
}
|
||||
|
||||
// navigation tests
|
||||
if (request.queryString === "loadsrcdocframeNav") {
|
||||
if (request.queryString.includes("loadsrcdocframeNav")) {
|
||||
let FRAME = `
|
||||
<iframe srcdoc="foo"
|
||||
onload="document.location='http://mochi.test:8888/tests/dom/security/test/general/file_same_site_cookies_about_navigation.html'">
|
||||
|
@ -31,7 +31,7 @@ function handleRequest(request, response)
|
|||
return;
|
||||
}
|
||||
|
||||
if (request.queryString === "loadblankframeNav") {
|
||||
if (request.queryString.includes("loadblankframeNav")) {
|
||||
let FRAME = `
|
||||
<iframe src="about:blank"
|
||||
onload="document.location='http://mochi.test:8888/tests/dom/security/test/general/file_same_site_cookies_about_navigation.html'">
|
||||
|
@ -41,12 +41,12 @@ function handleRequest(request, response)
|
|||
}
|
||||
|
||||
// inclusion tets
|
||||
if (request.queryString === "loadsrcdocframeInc") {
|
||||
if (request.queryString.includes("loadsrcdocframeInc")) {
|
||||
response.write("<iframe srcdoc=\"" + IFRAME_INC + "\"></iframe>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.queryString === "loadblankframeInc") {
|
||||
if (request.queryString.includes("loadblankframeInc")) {
|
||||
let FRAME = `
|
||||
<iframe id="blankframe" src="about:blank"></iframe>
|
||||
<script>
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
* 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/"
|
||||
|
@ -36,44 +39,100 @@ var 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);
|
||||
|
@ -81,7 +140,7 @@ 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();
|
||||
|
@ -93,10 +152,11 @@ function receiveMessage(event) {
|
|||
|
||||
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 + ")");
|
||||
|
@ -105,8 +165,7 @@ function setCookieAndInitTest() {
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче