<!DOCTYPE html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="early-hints-helpers.sub.js"></script>
<body>
<script>
promise_test(async (t) => {
    const params = new URLSearchParams(window.location.search);

    const preload_before_redirect = params.get("preload-before-redirect");
    await fetchScript(preload_before_redirect);
    assert_true(isPreloadedByEarlyHints(preload_before_redirect),
        "Early hints before redirect should preload.");

    const preload_after_redirect = params.get("preload-after-redirect");
    await fetchScript(preload_after_redirect);
    assert_false(isPreloadedByEarlyHints(preload_after_redirect),
        "Early hints after same origin redirect should be ignored.");
}, "Early hints -> same origin redirect -> early hints -> final response.");
</script>
</body>
