Storage Access API: Make document.hasStorageAccess() retrieve current status from...
[WebKit-https.git] / LayoutTests / http / tests / storageAccess / has-storage-access-from-prevalent-domain-with-recent-user-interaction.html
1 <!DOCTYPE html>
2 <html>
3 <head>
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 a cross-origin iframe from a prevalent domain with recent user interaction does have storage access.");
8         jsTestIsAsync = true;
9
10         window.addEventListener("message", receiveMessage, false);
11
12         function receiveMessage(event) {
13             if (event.origin === "http://localhost:8000") {
14                 if (event.data.indexOf("PASS") !== -1)
15                     testPassed(event.data.replace("PASS ", ""));
16                 else
17                     testFailed(event.data);
18             } else
19                 testFailed("Received a message from an unexpected origin: " + event.origin);
20             finishJSTest();
21         }
22
23         const hostUnderTest = "localhost:8000";
24         const statisticsUrl = "http://" + hostUnderTest + "/temp";
25         testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
26         if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
27             testFailed("Host did not get set as prevalent resource.");
28         testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true);
29         if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
30             testFailed("Host did not get logged for user interaction.");
31     </script>
32 </head>
33 <body>
34 <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" id="theIframe" src="http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldGrantAccess"></iframe>
35 </body>
36 </html>