-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
prevalent-resource-handled-keydown.html
65 lines (55 loc) · 2.32 KB
/
prevalent-resource-handled-keydown.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/util.js"></script>
<script>
description("Tests that we grant User Interaction credit for handled keypresses.");
jsTestIsAsync = true;
const statisticsUrl = "http://127.0.0.1:8000/temp";
function completeTestWhenKeyDownIsReceived() {
if (testInput.value != "a") {
setTimeout(completeTestWhenKeyDownIsReceived, 100);
return;
}
shouldBeEqualToString("testInput.value", "a");
if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
testFailed("Origin did not get user interaction credit.");
else
testPassed("Origin was granted user interaction.");
setTimeout(function() {
testFrame.src = "about:blank";
setTimeout(function() {
setEnableFeature(false, finishJSTest);
}, 0);
}, 0);
}
onload = function() {
const testFrame = document.getElementById("testFrame");
if (window.testRunner && window.internals) {
setEnableFeature(true, function() {
testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("Host did not get set as prevalent resource.");
testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, async function() {
if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
testFailed("Host did not get cleared of user interaction.");
testInput = document.getElementById("testInput");
testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
await testRunner.statisticsProcessStatisticsAndDataRecords();
debug("Simulate user typing letter 'a' into the field.");
testInput.focus();
if (window.eventSender)
eventSender.keyDown("a");
completeTestWhenKeyDownIsReceived();
});
});
});
}
}
</script>
<iframe id="testFrame" src="resources/onclick.html"></iframe>
<input id="testInput" type="text">
</body>
</html>