blob: 4d4a28367bf6a47207acb59fb1b2a993be0bc811 [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>
<script>description("Tests that merged statistic does not overwrite old statistic");</script>
</head>
<body onload="setTimeout('setUpAndRun()', 0)">
<script>
jsTestIsAsync = true;
const url = "http://127.0.0.1:8000";
const sampleTopFrameURL = "http://localhost:8000";
const olderTimestamp = Math.round((new Date()).getTime() / 1000);
const newerTimestamp = olderTimestamp + 10;
function insertSecondStatistic() {
testRunner.setStatisticsMergeStatistic(url, "", "", olderTimestamp, false, 99, false, false, false, 0, function() {
if (testRunner.isStatisticsPrevalentResource(url))
testPassed("Host did not overwrite old prevalent resource value.");
else
testFailed("Host did overwrite old prevalent resource value.")
if (testRunner.isStatisticsVeryPrevalentResource(url))
testPassed("Host did not overwrite old very prevalent resource value.");
else
testFailed("Host did overwrite old very prevalent resource value.");
if (testRunner.isStatisticsHasHadUserInteraction(url))
testPassed("Host did not overwrite old had user interaction value");
else
testFailed("Host did overwrite old had user interaction value");
if (testRunner.isStatisticsGrandfathered(url))
testPassed("Host did not overwrite old grandfathered value.");
else
testFailed("Host did overwrite old grandfathered value.");
testRunner.statisticsResetToConsistentState(function() {
finishJSTest();
});
});
}
function runTestRunnerTest() {
testRunner.setStatisticsMergeStatistic(url, "", "", newerTimestamp, true, 100, true, true, true, 1, function() {
if (!testRunner.isStatisticsPrevalentResource(url))
testFailed("Host got set as prevalent resource.");
if (!testRunner.isStatisticsVeryPrevalentResource(url))
testFailed("Host got set as prevalent resource.");
if (!testRunner.isStatisticsHasHadUserInteraction(url))
testFailed("Host got logged for user interaction.");
if (!testRunner.isStatisticsGrandfathered(url))
testFailed("Host got set as grandfathered.");
insertSecondStatistic();
});
}
function setUpAndRun() {
if (window.testRunner) {
testRunner.setUseITPDatabase(true);
setEnableFeature(true, function () {
runTestRunnerTest();
});
} else {
testFailed("no testRunner");
testRunner.statisticsResetToConsistentState(function() {
finishJSTest();
});
}
}
</script>
</body>
</html>