blob: f1dfc65bafd2c158ada3a1b02a0b098c25d6440d [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="/js-test-resources/ui-helper.js"></script>
<script src="/resourceLoadStatistics/resources/util.js"></script>
<script>
description("Tests that a cross-origin iframe from a prevalent domain with user interaction does not have storage access.");
jsTestIsAsync = true;
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if (event.origin === "http://localhost:8000") {
if (event.data.indexOf("PASS") !== -1)
testPassed(event.data.replace("PASS ", ""));
else
testFailed(event.data);
} else
testFailed("Received a message from an unexpected origin: " + event.origin);
setEnableFeature(false, finishJSTest);
}
const hostUnderTest = "localhost:8000";
const statisticsUrl = "http://" + hostUnderTest + "/temp";
function runTest() {
setEnableFeature(true, function() {
testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("Host did not get set as prevalent resource.");
testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
testFailed("Host did not get logged for user interaction.");
let iframeElement = document.createElement("iframe");
iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals");
iframeElement.id = "TheIframeThatRequestsStorageAccess";
iframeElement.src = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldNotGrantAccess";
document.body.appendChild(iframeElement);
});
});
});
}
</script>
</head>
<body onload="runTest()">
</body>
</html>