blob: da9d14cbf36e3e34026546c74dc905408dd1b4e8 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tests that removal of website data deletes ITP data</title>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/util.js"></script>
</head>
<body onload="runTest()">
<script>
const host = "localhost";
const thirdPartyOrigin = "http://localhost:8000";
const thirdPartyBaseUrl = thirdPartyOrigin + "/resourceLoadStatistics/resources";
function finishTest() {
testRunner.clearStatisticsDataForDomain(host);
// Must use domainID to ensure this was properly
// deleted, otherwise the lack of registrable domain --> domainID mapping
// could create a false-positive test result even when the domainID persists.
if (testRunner.doesStatisticsDomainIDExistInDatabase(1))
testFailed("Domain ID was not deleted from the database.");
else
testPassed("Domain ID was successfully deleted from the database.")
setEnableFeature(false, function() {
testRunner.notifyDone();
});
}
function runTest() {
switch (document.location.hash) {
case "":
if (window.testRunner && window.internals) {
testRunner.waitUntilDone();
testRunner.setUseITPDatabase(true);
setEnableFeature(true, function() {
testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
document.location.hash = "step1";
runTest();
});
}
break;
case "#step1":
document.location.hash = "step2";
let scriptElement = document.createElement("script");
scriptElement.onload = runTest;
scriptElement.src = thirdPartyBaseUrl + "/dummy.js?dummyParam=" + Math.random();
document.body.appendChild(scriptElement);
break;
case "#step2":
testRunner.statisticsNotifyObserver();
break;
}
}
</script>
</body>
</html>