blob: 564ef097b948f6b3e8bba04eaa6d71408769909b [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 always logged for the top document/frame.");
jsTestIsAsync = true;
const topFrameOrigin = "http://127.0.0.1:8000";
const subFrameOrigin = "http://localhost:8000";
function activateElement(elementId) {
var element = document.getElementById(elementId);
var centerX = element.offsetLeft + element.offsetWidth / 2;
var centerY = element.offsetTop + element.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY);
}
function finishTest() {
shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
setEnableFeature(false, finishJSTest);
}
onload = function() {
setEnableFeature(true, function() {
if (testRunner) {
testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
}
shouldBe("document.location.origin", "topFrameOrigin");
if (testRunner) {
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
activateElement("testFrame");
}
});
};
</script>
<iframe id="testFrame" src="http://localhost:8000/resourceLoadStatistics/resources/dummy.html"></iframe>
</body>
</html>