blob: f7ddaf759490c056903a50d47fd5aa6edb7f7a22 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/util.js"></script>
</head>
<body>
<script>
description("Test for classification as very prevalent based on mixed statistics.");
jsTestIsAsync = true;
const hostUnderTest = "127.0.0.1:8000";
const statisticsUrl = "http://" + hostUnderTest + "/temp";
var topFrameOrigins = [];
const startNum = 2;
const numberOfSubresourceDomains = 30;
for (var i = startNum; i < numberOfSubresourceDomains + startNum; ++i)
topFrameOrigins.push("http://127.0.0." + i + ":8000/temp")
function completeTest() {
if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("Host did not get classified as prevalent resource.");
if (!testRunner.isStatisticsVeryPrevalentResource(statisticsUrl))
testFailed("Host did not get classified as very prevalent resource.");
else
testPassed("Host classified as very prevalent resource.");
setEnableFeature(false, finishJSTest);
}
function runTestRunnerTest() {
testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("Host started out as prevalent resource.");
var i = 0;
while (i < numberOfSubresourceDomains) {
testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i]);
testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i]);
testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+1]);
testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+1]);
testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigins[i+2]);
testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigins[i+2]);
i += 3;
}
testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
testRunner.statisticsProcessStatisticsAndDataRecords();
});
}
if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
testRunner.setUseITPDatabase(true);
setEnableFeature(true, runTestRunnerTest);
}
</script>
</body>
</html>