| <!-- webkit-test-runner [ useEphemeralSession=true ] --> |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script src="/resourceLoadStatistics/resources/util.js"></script> |
| <script> |
| description("Tests that document.hasStorageAccess() returns true for a 3rd-party iframe if the 3rd-party has cookies set (ephemeral session)."); |
| jsTestIsAsync = true; |
| |
| window.addEventListener("message", receiveMessage, false); |
| |
| function receiveMessage(event) { |
| if (event.origin === "http://localhost:8000") { |
| if (event.data.indexOf("PASS") !== -1) |
| testPassed(event.data.replace("PASS ", "")); |
| else |
| testFailed(event.data.replace("FAIL ", "")); |
| } else |
| testFailed("Received a message from an unexpected origin: " + event.origin); |
| finishJSTest(); |
| } |
| |
| const hostUnderTest = "localhost:8000"; |
| const statisticsUrl = "http://" + hostUnderTest; |
| function runTest() { |
| testRunner.setUseITPDatabase(true); |
| if (document.location.hash !== "#firstPartyCookieSet") { |
| document.location.href = statisticsUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#http://127.0.0.1:8000/storageAccess/has-storage-access-true-if-third-party-has-cookies.html#firstPartyCookieSet"; |
| } else { |
| let iframeElement = document.createElement("iframe"); |
| iframeElement.id = "TheIframeThatRequestsStorageAccess"; |
| iframeElement.src = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldGrantAccess"; |
| document.body.appendChild(iframeElement); |
| } |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| </body> |
| </html> |