| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script src="/js-test-resources/ui-helper.js"></script> |
| <script src="/resourceLoadStatistics/resources/util.js"></script> |
| <script> |
| description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and has the unique origin because it lacks the allow-same-origin token."); |
| jsTestIsAsync = true; |
| |
| window.addEventListener("message", receiveMessage, false); |
| |
| function receiveMessage(event) { |
| if (event.origin === "null") { |
| 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); |
| setEnableFeature(false, finishJSTest); |
| } |
| |
| function activateElement(elementId) { |
| var element = document.getElementById(elementId); |
| var centerX = element.offsetLeft + element.offsetWidth / 2; |
| var centerY = element.offsetTop + element.offsetHeight / 2; |
| UIHelper.activateAt(centerX, centerY).then( |
| function () { |
| if (window.eventSender) |
| eventSender.keyDown("escape"); |
| else { |
| testFailed("No eventSender."); |
| setEnableFeature(false, finishJSTest); |
| } |
| }, |
| function () { |
| testFailed("Promise rejected."); |
| setEnableFeature(false, finishJSTest); |
| } |
| ); |
| } |
| |
| function runTest() { |
| setEnableFeature(true, function() { |
| activateElement("TheIframeThatRequestsStorageAccess"); |
| }); |
| } |
| </script> |
| </head> |
| <body> |
| <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-modals" onload="runTest()" id="TheIframeThatRequestsStorageAccess" src="http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldNotBeConsulted,policyShouldDenyAccess,isNotSameOriginIframe,originIsNull"></iframe> |
| </body> |
| </html> |