| <!-- webkit-test-runner [ useEphemeralSession=true ] --> |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| </head> |
| <body> |
| <script> |
| description("Tests that only the origin is sent as referrer for third-party resources in private browsing mode."); |
| jsTestIsAsync = true; |
| |
| testRunner.dumpChildFramesAsText(); |
| |
| function openIframe(url, onLoadHandler) { |
| const element = document.createElement("iframe"); |
| element.src = url; |
| if (onLoadHandler) { |
| element.onload = onLoadHandler; |
| } |
| document.body.appendChild(element); |
| } |
| |
| var referrer; |
| fetch("resources/echo-referrer.py").then(function(response) { |
| return response.text(); |
| }).then(function(data) { |
| referrer = data; |
| shouldBeEqualToString("referrer", "http://127.0.0.1:8000/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html"); |
| |
| fetch("http://localhost:8000/security/resources/echo-referrer.py").then(function(response) { |
| return response.text(); |
| }).then(function(data) { |
| referrer = data; |
| shouldBeEqualToString("referrer", "http://127.0.0.1:8000/"); |
| openIframe("http://localhost:8000/security/resources/echo-referrer.py", finishJSTest); |
| }).catch(function(error) { |
| console.log(error.message); |
| finishJSTest(); |
| }); |
| |
| }).catch(function(error) { |
| console.log(error.message); |
| finishJSTest(); |
| }); |
| |
| </script> |
| </body> |
| </html> |