mirror of
https://github.com/servo/servo.git
synced 2025-07-13 02:13:40 +01:00
44 lines
1.9 KiB
HTML
44 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Referrer Policy: iframes correctly inherit the ancestor's referrer</title>
|
|
<link rel="author" title="Jochen Eisinger" href="mailto:jochen@chromium.org">
|
|
<link rel="help" href="https://www.w3.org/TR/referrer-policy/#referrer-policy-delivery-nested">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<!-- Common global functions for referrer-policy tests. -->
|
|
<script src="/common/security-features/resources/common.js"></script>
|
|
<script src="/referrer-policy/generic/referrer-policy-test-case.js"></script>
|
|
<meta name="referrer" content="origin">
|
|
</head>
|
|
<body onload="runTest()">
|
|
<h1>Referrer Policy: iframes correctly inherit the ancestor's referrer</h1>
|
|
<script>
|
|
var test = async_test("iframes correctly inherit the ancestor's referrer");
|
|
window.addEventListener("message", test.step_func((msg) => {
|
|
assert_equals(msg.data.referrer, document.location.origin + "/");
|
|
test.done();
|
|
}));
|
|
|
|
function runTest() {
|
|
var iframe = document.createElement("iframe");
|
|
iframe.src = "about:blank";
|
|
document.body.appendChild(iframe);
|
|
iframe.contentDocument.write(`
|
|
<script src = "/common/security-features/resources/common.js"></` + `script>
|
|
<script src = "/referrer-policy/generic/referrer-policy-test-case.js"></` + `script>
|
|
<script>
|
|
var urlPath = "/common/security-features/subresource/xhr.py";
|
|
var url = "${location.protocol}//www1.${location.hostname}:${location.port}" + urlPath;
|
|
requestViaXhr(url).then((msg) => {
|
|
parent.postMessage({referrer: msg.referrer}, "*")})
|
|
.catch((e) => {
|
|
parent.postMessage({referrer: "FAILURE"}, "*");
|
|
});
|
|
</` + "script>");
|
|
}
|
|
</script>
|
|
|
|
<div id="log"></div>
|
|
</body>
|
|
</html>
|