Bug 1495623 [wpt PR 5054] - Add test cases for multiple Referrer-Policy headers, a=testonly

Automatic update from web-platform-testsAdd test cases for multiple Referrer-Policy headers (#5054)

* Add test cases for multiple Referrer-Policy headers

The test cases exercise various ways that multiple policies can be delivered in
Referrer-Policy headers, such as:

Referrer-Policy: origin, no-referrer

Referrer-Policy: origin
Referrer-Policy: no-referrer

Referrer-Policy: origin
Referrer-Policy: origin no-referrer

As requested in https://github.com/w3c/webappsec-referrer-policy/issues/81

* Update expectation for invalid header, add extension-token test

--

wpt-commits: 028ac8c49c304bbc7b4d0000c83641b19947612c
wpt-pr: 5054
This commit is contained in:
Emily Stark 2018-10-09 04:12:06 +00:00 committed by moz-wptsync-bot
parent 634051957d
commit 15bb3ce079
10 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Referrer Policy: multiple Referrer-Policy header and header values are allowed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/referrer-policy/generic/common.js"></script>
</head>
<body>
<h1>Referrer Policy: multiple Referrer-Policy header and header values are allowed</h1>
<p></p>
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Image uses the last recognized Referrer-Policy header value");
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
assert_equals(message.referrer, document.location.origin + "/");
test.done();
}), null, 'no-referrer', test);
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,2 @@
Referrer-Policy: no-referrer
Referrer-Policy: no-referrer,origin

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Referrer Policy: multiple Referrer-Policy header values are allowed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/referrer-policy/generic/common.js"></script>
</head>
<body>
<h1>Referrer Policy: multiple Referrer-Policy header values are allowed</h1>
<p></p>
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Image uses the last recognized Referrer-Policy header value");
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
assert_equals(message.referrer, document.location.origin + "/");
test.done();
}), null, 'no-referrer', test);
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1 @@
Referrer-Policy: no-referrer, origin

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Referrer Policy: multiple Referrer-Policy headers with one invalid</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/referrer-policy/generic/common.js"></script>
</head>
<body>
<h1>Referrer Policy: multiple Referrer-Policy headers with one invalid</h1>
<p></p>
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Referrer policy header parsing fails if one header is invalid");
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
assert_equals(message.referrer, document.location.href);
test.done();
}), null, 'no-referrer', test);
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,2 @@
Referrer-Policy: origin
Referrer-Policy: origin no-referrer

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Referrer Policy: multiple Referrer-Policy headers with one invalid</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/referrer-policy/generic/common.js"></script>
</head>
<body>
<h1>Referrer Policy: multiple Referrer-Policy headers with one invalid</h1>
<p></p>
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Image uses last recognized referrer policy token from Referrer-Policy headers");
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
assert_equals(message.referrer, document.location.origin + "/");
test.done();
}), null, 'no-referrer', test);
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,2 @@
Referrer-Policy: no-referrer
Referrer-Policy: origin,not-a-valid-token

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Referrer Policy: multiple Referrer-Policy headers are allowed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/referrer-policy/generic/common.js"></script>
</head>
<body>
<h1>Referrer Policy: multiple Referrer-Policy headers are allowed</h1>
<p></p>
<pre id="received_message">Running...</pre>
<script>
var test = async_test("Image uses the last recognized Referrer-Policy header");
var urlPath = '/referrer-policy/generic/subresource/image.py?cache_destroyer=' + (new Date()).getTime();
var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
urlPath;
queryImage(url, test.step_func(function(message) {
assert_equals(message.referrer, document.location.origin + "/");
test.done();
}), null, 'no-referrer', test);
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,2 @@
Referrer-Policy: no-referrer
Referrer-Policy: origin