<!DOCTYPE html>
<html>
<head>
<meta name='referrer' content='no-referrer-when-downgrade'>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests the behavior of no-referrer-when-downgrade referrer policy when same origin.");
jsTestIsAsync = true;

if (window.internals)
    internals.setTrackingPreventionEnabled(false);

window.onmessage = function(event) {
    referrer = event.data.referrer;
    // Should be the full URL
    shouldBeEqualToString("referrer", "http://127.0.0.1:8000/referrer-policy/no-referrer-when-downgrade/same-origin.html");
    if (window.internals)
        internals.setTrackingPreventionEnabled(true);
    finishJSTest();
}

if (window.testRunner) {
    testRunner.setStatisticsShouldDowngradeReferrer(false, function () {
        let iframeElement = document.createElement("iframe");
        iframeElement.src = "http://127.0.0.1:8000/referrer-policy/resources/document.html";
        document.body.appendChild(iframeElement);
    });
}
</script>
</body>
</html>
