test: Update tests/wpt/mozilla/.../referrer-policy/

Only has changes to spec.src.json, generate.py etc., no actual tests generated yet.
This commit is contained in:
Aravind Gollakota 2016-07-07 21:47:31 -07:00
parent eeccb75fc1
commit fd50eb17fd
5 changed files with 128 additions and 41 deletions

View file

@ -222,7 +222,7 @@ A **selection** is a single **test instance** (scenario) with explicit values, f
```javascript ```javascript
var scenario = { var scenario = {
"referrer_policy": "origin-when-crossorigin", "referrer_policy": "origin-when-cross-origin",
"delivery_method": "meta-referrer", "delivery_method": "meta-referrer",
"redirection": "no-redirect", "redirection": "no-redirect",
"origin": "cross-origin", "origin": "cross-origin",

View file

@ -22,7 +22,7 @@ function parseUrlQueryString(queryString) {
function appendIframeToBody(url, attributes) { function appendIframeToBody(url, attributes) {
var iframe = document.createElement("iframe"); var iframe = document.createElement("iframe");
iframe.src = url; iframe.src = url;
// Extend element with attributes. (E.g. "referrer_policy" or "rel") // Extend element with attributes. (E.g. "referrerPolicy" or "rel")
if (attributes) { if (attributes) {
for (var attr in attributes) { for (var attr in attributes) {
iframe[attr] = attributes[attr]; iframe[attr] = attributes[attr];
@ -40,7 +40,7 @@ function loadImage(src, callback, attributes) {
callback(image); callback(image);
} }
image.src = src; image.src = src;
// Extend element with attributes. (E.g. "referrer_policy" or "rel") // Extend element with attributes. (E.g. "referrerPolicy" or "rel")
if (attributes) { if (attributes) {
for (var attr in attributes) { for (var attr in attributes) {
image[attr] = attributes[attr]; image[attr] = attributes[attr];

View file

@ -76,7 +76,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
// Depending on the delivery method, extend the subresource element with // Depending on the delivery method, extend the subresource element with
// these attributes. // these attributes.
var elementAttributesForDeliveryMethod = { var elementAttributesForDeliveryMethod = {
"attr-referrer": {referrerpolicy: t._scenario.referrer_policy}, "attr-referrer": {referrerPolicy: t._scenario.referrer_policy},
"rel-noreferrer": {rel: "noreferrer"} "rel-noreferrer": {rel: "noreferrer"}
}; };

View file

@ -93,13 +93,13 @@ def generate_selection(selection, spec, subresource_path,
selection['meta_delivery_method'] = \ selection['meta_delivery_method'] = \
'<meta http-equiv="Content-Security-Policy" ' + \ '<meta http-equiv="Content-Security-Policy" ' + \
'content="referrer %(referrer_policy)s">' % spec 'content="referrer %(referrer_policy)s">' % spec
elif selection['delivery_method'] == 'http-csp': elif selection['delivery_method'] == 'http-rp':
selection['meta_delivery_method'] = \ selection['meta_delivery_method'] = \
"<!-- No meta: CSP delivered via HTTP headers. -->" "<!-- No meta: Referrer policy delivered via HTTP headers. -->"
test_headers_filename = test_filename + ".headers" test_headers_filename = test_filename + ".headers"
with open(test_headers_filename, "w") as f: with open(test_headers_filename, "w") as f:
f.write('Content-Security-Policy: ' + \ f.write('Referrer-Policy: ' + \
'referrer %(referrer_policy)s\n' % spec) '%(referrer_policy)s\n' % spec)
# TODO(kristijanburnik): Limit to WPT origins. # TODO(kristijanburnik): Limit to WPT origins.
f.write('Access-Control-Allow-Origin: *\n') f.write('Access-Control-Allow-Origin: *\n')
elif selection['delivery_method'] == 'attr-referrer': elif selection['delivery_method'] == 'attr-referrer':

View file

@ -3,16 +3,49 @@
{ {
"name": "unset-referrer-policy", "name": "unset-referrer-policy",
"title": "Referrer Policy is not explicitly defined", "title": "Referrer Policy is not explicitly defined",
"description": "Check that sub-resource gets the referrer URL when no explicit Referrer Policy is set.", "description": "Check that referrer URL follows no-referrer-when-downgrade policy when no explicit Referrer Policy is set.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-states", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policies",
"referrer_policy": null, "referrer_policy": null,
"test_expansion": [ "test_expansion": [
{ {
"name": "generic", "name": "insecure-protocol",
"expansion": "default", "expansion": "default",
"source_protocol": "*", "source_protocol": "http",
"target_protocol": "*", "target_protocol": "http",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "*",
"subresource": "*",
"referrer_url": "stripped-referrer"
},
{
"name": "upgrade-protocol",
"expansion": "default",
"source_protocol": "http",
"target_protocol": "https",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "*",
"subresource": "*",
"referrer_url": "stripped-referrer"
},
{
"name": "downgrade-protocol",
"expansion": "default",
"source_protocol": "https",
"target_protocol": "http",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "*",
"subresource": "*",
"referrer_url": "omitted"
},
{
"name": "secure-protocol",
"expansion": "default",
"source_protocol": "https",
"target_protocol": "https",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -24,7 +57,7 @@
"name": "no-referrer", "name": "no-referrer",
"title": "Referrer Policy is set to 'no-referrer'", "title": "Referrer Policy is set to 'no-referrer'",
"description": "Check that sub-resource never gets the referrer URL.", "description": "Check that sub-resource never gets the referrer URL.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer",
"referrer_policy": "no-referrer", "referrer_policy": "no-referrer",
"test_expansion": [ "test_expansion": [
{ {
@ -32,7 +65,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "*", "source_protocol": "*",
"target_protocol": "*", "target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -44,7 +77,7 @@
"name": "no-referrer-when-downgrade", "name": "no-referrer-when-downgrade",
"title": "Referrer Policy is set to 'no-referrer-when-downgrade'", "title": "Referrer Policy is set to 'no-referrer-when-downgrade'",
"description": "Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.", "description": "Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer-when-downgrade", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade",
"referrer_policy": "no-referrer-when-downgrade", "referrer_policy": "no-referrer-when-downgrade",
"test_expansion": [ "test_expansion": [
{ {
@ -52,7 +85,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "http", "source_protocol": "http",
"target_protocol": "http", "target_protocol": "http",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -63,7 +96,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "http", "source_protocol": "http",
"target_protocol": "https", "target_protocol": "https",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -74,18 +107,18 @@
"expansion": "default", "expansion": "default",
"source_protocol": "https", "source_protocol": "https",
"target_protocol": "http", "target_protocol": "http",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
"referrer_url": "origin" "referrer_url": "omitted"
}, },
{ {
"name": "secure-protocol", "name": "secure-protocol",
"expansion": "default", "expansion": "default",
"source_protocol": "https", "source_protocol": "https",
"target_protocol": "https", "target_protocol": "https",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -94,10 +127,10 @@
] ]
}, },
{ {
"name": "origin-only", "name": "origin",
"title": "Referrer Policy is set to 'origin-only'", "title": "Referrer Policy is set to 'origin'",
"description": "Check that all subresources in all casses get only the origin portion of the referrer URL.", "description": "Check that all subresources in all casses get only the origin portion of the referrer URL.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-origin",
"referrer_policy": "origin", "referrer_policy": "origin",
"test_expansion": [ "test_expansion": [
{ {
@ -105,7 +138,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "*", "source_protocol": "*",
"target_protocol": "*", "target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -114,18 +147,18 @@
] ]
}, },
{ {
"name": "origin-when-cross-origin", "name": "same-origin",
"title": "Referrer Policy is set to 'origin-when-crossorigin'", "title": "Referrer Policy is set to 'same-origin'",
"description": "Check that cross-origin subresources get the origin portion of the referrer URL and same-origin get the stripped referrer URL.", "description": "Check that cross-origin subresources get no referrer information and same-origin get the stripped referrer URL.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin-when-cross-origin", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-same-origin",
"referrer_policy": "origin-when-crossorigin", "referrer_policy": "same-origin",
"test_expansion": [ "test_expansion": [
{ {
"name": "same-origin-insecure", "name": "same-origin-insecure",
"expansion": "default", "expansion": "default",
"source_protocol": "http", "source_protocol": "http",
"target_protocol": "http", "target_protocol": "http",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "same-origin", "origin": "same-origin",
"subresource": "*", "subresource": "*",
@ -136,7 +169,60 @@
"expansion": "default", "expansion": "default",
"source_protocol": "https", "source_protocol": "https",
"target_protocol": "https", "target_protocol": "https",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "same-origin",
"subresource": "*",
"referrer_url": "stripped-referrer"
},
{
"name": "same-origin-insecure",
"expansion": "override",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "swap-origin-redirect",
"origin": "same-origin",
"subresource": "*",
"referrer_url": "omitted"
},
{
"name": "cross-origin",
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "cross-origin",
"subresource": "*",
"referrer_url": "omitted"
}
]
},
{
"name": "origin-when-cross-origin",
"title": "Referrer Policy is set to 'origin-when-cross-origin'",
"description": "Check that cross-origin subresources get the origin portion of the referrer URL and same-origin get the stripped referrer URL.",
"specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-origin-when-cross-origin",
"referrer_policy": "origin-when-cross-origin",
"test_expansion": [
{
"name": "same-origin-insecure",
"expansion": "default",
"source_protocol": "http",
"target_protocol": "http",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "same-origin",
"subresource": "*",
"referrer_url": "stripped-referrer"
},
{
"name": "same-origin-secure-default",
"expansion": "default",
"source_protocol": "https",
"target_protocol": "https",
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "same-origin", "origin": "same-origin",
"subresource": "*", "subresource": "*",
@ -147,7 +233,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "http", "source_protocol": "http",
"target_protocol": "https", "target_protocol": "https",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "same-origin", "origin": "same-origin",
"subresource": "*", "subresource": "*",
@ -158,7 +244,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "http", "source_protocol": "http",
"target_protocol": "https", "target_protocol": "https",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "same-origin", "origin": "same-origin",
"subresource": "*", "subresource": "*",
@ -169,7 +255,7 @@
"expansion": "override", "expansion": "override",
"source_protocol": "*", "source_protocol": "*",
"target_protocol": "*", "target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "swap-origin-redirect", "redirection": "swap-origin-redirect",
"origin": "same-origin", "origin": "same-origin",
"subresource": "*", "subresource": "*",
@ -180,7 +266,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "*", "source_protocol": "*",
"target_protocol": "*", "target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "cross-origin", "origin": "cross-origin",
"subresource": "*", "subresource": "*",
@ -192,7 +278,7 @@
"name": "unsafe-url", "name": "unsafe-url",
"title": "Referrer Policy is set to 'unsafe-url'", "title": "Referrer Policy is set to 'unsafe-url'",
"description": "Check that all sub-resources get the stripped referrer URL.", "description": "Check that all sub-resources get the stripped referrer URL.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-unsafe-url", "specification_url": "https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-unsafe-url",
"referrer_policy": "unsafe-url", "referrer_policy": "unsafe-url",
"test_expansion": [ "test_expansion": [
{ {
@ -200,7 +286,7 @@
"expansion": "default", "expansion": "default",
"source_protocol": "*", "source_protocol": "*",
"target_protocol": "*", "target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*", "redirection": "*",
"origin": "*", "origin": "*",
"subresource": "*", "subresource": "*",
@ -329,8 +415,9 @@
null, null,
"no-referrer", "no-referrer",
"no-referrer-when-downgrade", "no-referrer-when-downgrade",
"same-origin",
"origin", "origin",
"origin-when-crossorigin", "origin-when-cross-origin",
"unsafe-url" "unsafe-url"
], ],
@ -341,7 +428,7 @@
], ],
"delivery_method": [ "delivery_method": [
"http-csp", "http-rp",
"meta-referrer", "meta-referrer",
"meta-csp", "meta-csp",
"attr-referrer", "attr-referrer",