blob: f8aee7ab082f5a7000405ea9652e71ab1175f2b9 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script src="/js-test-resources/ui-helper.js"></script>
<script src="resources/util.js"></script>
<script>
description("Tests that user interaction is reported after history removal since that means all statistics have been reset.");
jsTestIsAsync = true;
const topFrameOrigin = "http://127.0.0.1:8000";
const subFrameOrigin = "http://localhost:8000";
function activateElement(elementId, callback) {
var element = document.getElementById(elementId);
var centerX = element.offsetLeft + element.offsetWidth / 2;
var centerY = element.offsetTop + element.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY).then(
function() {
callback();
},
function() {
testFailed("Promise rejected.");
setEnableFeature(false, finishJSTest);
}
);
}
function firstInteraction() {
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
activateElement("testElement", clearWebsiteData);
}
function clearWebsiteData() {
shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
if (testRunner)
testRunner.statisticsClearThroughWebsiteDataRemoval(secondInteraction);
}
function secondInteraction() {
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
activateElement("testElement", finishTest);
}
function finishTest() {
shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
setEnableFeature(false, finishJSTest);
}
onload = function() {
setEnableFeature(true, function() {
shouldBe("document.location.origin", "topFrameOrigin");
firstInteraction();
});
};
</script>
<div id="testElement">This is the test element</div>
</body>
</html>