c3ad86c9422df5cfeba2aacec513d903288952e9
[WebKit-https.git] / LayoutTests / http / tests / loading / resourceLoadStatistics / user-interaction-in-cross-origin-sub-frame.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="/js-test-resources/js-test.js"></script>
5 <script src="/js-test-resources/ui-helper.js"></script>
6 <script>
7 description("Tests that user interaction is always logged for the top document/frame.");
8 jsTestIsAsync = true;
9
10 const topFrameOrigin = "http://127.0.0.1:8000";
11 const subFrameOrigin = "http://localhost:8000";
12
13 function activateElement(elementId) {
14     var element = document.getElementById(elementId);
15     var centerX = element.offsetLeft + element.offsetWidth / 2;
16     var centerY = element.offsetTop + element.offsetHeight / 2;
17     UIHelper.activateAt(centerX, centerY);
18 }
19
20 function finishTest() {
21     shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
22     shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
23
24     finishJSTest();
25 }
26
27 onload = function() {
28     if (internals)
29         internals.setResourceLoadStatisticsEnabled(true);
30
31     if (testRunner) {
32         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
33         testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
34     }
35
36     shouldBe("document.location.origin", "topFrameOrigin");
37
38     if (testRunner) {
39         shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
40         shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
41
42         activateElement("testFrame");
43     }
44 };
45 </script>
46 <iframe id="testFrame" src="http://localhost:8000/loading/resourceLoadStatistics/resources/dummy.html"></iframe>
47 </body>
48 </html>