blob: 2d2874192727bbb7bd2af1084fcf9ec65f3050b9 [file]
<html><!-- webkit-test-runner [ OptInPartitionedCookiesEnabled=true CFNetworkNetworkLoaderEnabled=false ] -->
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/resetCookies.js"></script>
<script>
description("Tests that first and third-party partitioned cookies are accepted.");
jsTestIsAsync = true;
const iframeUrls = {
echoCookies : "https://localhost:8443/cookies/resources/echo-cookies.py",
resetCookies : "https://localhost:8443/cookies/resources/reset-cookies.html"
};
function injectThirdPartyIframe(url) {
let iframeElement = document.createElement("iframe");
iframeElement.src = url;
iframeElement.onload = runNextTestOrFinish;
document.body.appendChild(iframeElement);
}
function setCookieInRedirect(hashValue) {
document.location.href = "https://localhost:8443/cookies/resources/set-cookie-and-redirect-back.py?isPartitioned=True&redirectBackTo=https://127.0.0.1:8443/cookies/accept-partitioned-first-and-third-party-cookies.https.html#" + hashValue;
}
function runNextTestOrFinish() {
if (!window.testRunner) {
testFailed("No testRunner.");
finishJSTest();
}
switch (document.location.hash) {
case "":
internals.setTrackingPreventionEnabled(true);
testRunner.setStatisticsIsRunningTest(true);
testRunner.setOnlyAcceptFirstPartyCookies(false);
testRunner.dumpChildFramesAsText();
document.location.hash = "1";
injectThirdPartyIframe(iframeUrls.resetCookies);
break;
case "#1":
setCookieInRedirect(2);
break;
case "#2":
document.location.hash = "3";
// Should see one cookie.
injectThirdPartyIframe(`https://localhost:8443/cookies/resources/set-cookie-and-redirect-back.py?isPartitioned=True&redirectBackTo=${iframeUrls.echoCookies}`);
break;
case "#3":
document.location.hash = "4";
testRunner.setStatisticsShouldBlockThirdPartyCookies(true, () => {
// Should not have cookies.
injectThirdPartyIframe(iframeUrls.echoCookies);
}, true);
break;
case "#4":
document.location.hash = "5";
testRunner.setStatisticsHasHadUserInteraction("https://127.0.0.1:8443", true, () => {
// Should see one cookie.
injectThirdPartyIframe(iframeUrls.echoCookies);
});
break;
case "#5":
document.location.hash = "6";
testRunner.setStatisticsShouldBlockThirdPartyCookies(false, () => {
// Should see one cookie.
injectThirdPartyIframe(iframeUrls.echoCookies);
}, true);
break;
case "#6":
document.location.hash = "7";
injectThirdPartyIframe(iframeUrls.resetCookies);
break;
case "#7":
internals.setTrackingPreventionEnabled(false);
testRunner.setStatisticsIsRunningTest(false);
finishJSTest();
break;
default:
internals.setTrackingPreventionEnabled(false);
testRunner.setStatisticsIsRunningTest(false);
testFailed("Unknown location hash value.");
finishJSTest();
}
}
</script>
</head>
<body onload="runNextTestOrFinish()">
</body>
</html>