blob: 14ab81b3e832097cbcff4c19b42825e07f168b7e [file] [log] [blame]
<!-- webkit-test-runner [ useEphemeralSession=true ] -->
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="/resourceLoadStatistics/resources/util.js"></script>
<script>
description("Tests document.hasStorageAccess() for a 3rd-party with cookies under general third-party cookie blocking (ephemeral).");
jsTestIsAsync = true;
const firstPartyUrl = "http://127.0.0.1:8000";
const thirdPartyUrl = "http://localhost:8000";
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if (event.origin === thirdPartyUrl) {
if (event.data.indexOf("PASS") !== -1)
testPassed(event.data.replace("PASS ", ""));
else
testFailed(event.data.replace("FAIL ", ""));
} else
testFailed("Received a message from an unexpected origin: " + event.origin);
testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
setEnableFeature(false, finishJSTest);
});
}
function runTest() {
switch (document.location.hash) {
case "":
setEnableFeature(true, function() {
testRunner.setStatisticsShouldBlockThirdPartyCookies(true, function() {
// Set a cookie for the third-party and continue.
document.location.href = thirdPartyUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#" + firstPartyUrl + "/storageAccess/has-storage-access-under-general-third-party-cookie-blocking-with-cookie-ephemeral.html#step1";
});
});
break;
case "#step1":
testRunner.setStatisticsHasHadUserInteraction(thirdPartyUrl, true, function() {
let iframeElement = document.createElement("iframe");
iframeElement.src = thirdPartyUrl + "/storageAccess/resources/has-storage-access-iframe.html?dummy=" + Math.random() + "#policyShouldNotGrantAccess";
document.body.appendChild(iframeElement);
});
break;
}
}
</script>
</head>
<body onload="runTest()">
</body>
</html>