blob: 45271b52bc910badd6832084f59d91b08c7ef582 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Tests that we do not grant User Interaction credit for unhandled keypress.");
jsTestIsAsync = true;
const statisticsUrl = "http://127.0.0.1:8000/temp";
onload = function() {
const testFrame = document.getElementById("testFrame");
if (window.testRunner && window.internals) {
internals.setResourceLoadStatisticsEnabled(true);
testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
}
testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("Host did not get set as prevalent resource.");
testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false);
if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
testFailed("Host did not get cleared of user interaction.");
testRunner.installStatisticsDidModifyDataRecordsCallback(function() {
if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
testPassed("Origin did not get user interaction credit.");
setTimeout(function() {
testFrame.src = "about:blank";
setTimeout(finishJSTest, 0);
}, 0);
});
testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
testRunner.statisticsProcessStatisticsAndDataRecords();
debug("Simulate an unhandled user key press.");
if (window.eventSender)
eventSender.keyDown("a", ["metaKey"]);
}
</script>
<iframe id="testFrame" src="resources/onclick.html"></iframe>
</body>
</html>