Skip to content

Commit

Permalink
test: Update tests/wpt/mozilla/.../referrer-policy/
Browse files Browse the repository at this point in the history
Only has changes to spec.src.json, generate.py etc., no actual tests generated yet.
  • Loading branch information
aravind-pg committed Jul 8, 2016
1 parent eeccb75 commit fd50eb1
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 39 deletions.
2 changes: 1 addition & 1 deletion tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md
Expand Up @@ -222,7 +222,7 @@ A **selection** is a single **test instance** (scenario) with explicit values, f

```javascript
var scenario = {
"referrer_policy": "origin-when-crossorigin",
"referrer_policy": "origin-when-cross-origin",
"delivery_method": "meta-referrer",
"redirection": "no-redirect",
"origin": "cross-origin",
Expand Down
Expand Up @@ -22,7 +22,7 @@ function parseUrlQueryString(queryString) {
function appendIframeToBody(url, attributes) {
var iframe = document.createElement("iframe");
iframe.src = url;
// Extend element with attributes. (E.g. "referrer_policy" or "rel")
// Extend element with attributes. (E.g. "referrerPolicy" or "rel")
if (attributes) {
for (var attr in attributes) {
iframe[attr] = attributes[attr];
Expand All @@ -40,7 +40,7 @@ function loadImage(src, callback, attributes) {
callback(image);
}
image.src = src;
// Extend element with attributes. (E.g. "referrer_policy" or "rel")
// Extend element with attributes. (E.g. "referrerPolicy" or "rel")
if (attributes) {
for (var attr in attributes) {
image[attr] = attributes[attr];
Expand Down
Expand Up @@ -76,7 +76,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
// Depending on the delivery method, extend the subresource element with
// these attributes.
var elementAttributesForDeliveryMethod = {
"attr-referrer": {referrerpolicy: t._scenario.referrer_policy},
"attr-referrer": {referrerPolicy: t._scenario.referrer_policy},
"rel-noreferrer": {rel: "noreferrer"}
};

Expand Down
Expand Up @@ -93,13 +93,13 @@ def generate_selection(selection, spec, subresource_path,
selection['meta_delivery_method'] = \
'<meta http-equiv="Content-Security-Policy" ' + \
'content="referrer %(referrer_policy)s">' % spec
elif selection['delivery_method'] == 'http-csp':
elif selection['delivery_method'] == 'http-rp':
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"
with open(test_headers_filename, "w") as f:
f.write('Content-Security-Policy: ' + \
'referrer %(referrer_policy)s\n' % spec)
f.write('Referrer-Policy: ' + \
'%(referrer_policy)s\n' % spec)
# TODO(kristijanburnik): Limit to WPT origins.
f.write('Access-Control-Allow-Origin: *\n')
elif selection['delivery_method'] == 'attr-referrer':
Expand Down
149 changes: 118 additions & 31 deletions tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json
Expand Up @@ -3,16 +3,49 @@
{
"name": "unset-referrer-policy",
"title": "Referrer Policy is not explicitly defined",
"description": "Check that sub-resource gets the referrer URL when no explicit Referrer Policy is set.",
"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-states",
"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-referrer-policy/#referrer-policies",
"referrer_policy": null,
"test_expansion": [
{
"name": "generic",
"name": "insecure-protocol",
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"],
"source_protocol": "http",
"target_protocol": "http",
"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": "*",
"origin": "*",
"subresource": "*",
Expand All @@ -24,15 +57,15 @@
"name": "no-referrer",
"title": "Referrer Policy is set to 'no-referrer'",
"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",
"test_expansion": [
{
"name": "generic",
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"],
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "*",
"subresource": "*",
Expand All @@ -44,15 +77,15 @@
"name": "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.",
"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",
"test_expansion": [
{
"name": "insecure-protocol",
"expansion": "default",
"source_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": "*",
"origin": "*",
"subresource": "*",
Expand All @@ -63,7 +96,7 @@
"expansion": "default",
"source_protocol": "http",
"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": "*",
"subresource": "*",
Expand All @@ -74,18 +107,18 @@
"expansion": "default",
"source_protocol": "https",
"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": "origin"
"referrer_url": "omitted"
},
{
"name": "secure-protocol",
"expansion": "default",
"source_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": "*",
"subresource": "*",
Expand All @@ -94,38 +127,91 @@
]
},
{
"name": "origin-only",
"title": "Referrer Policy is set to 'origin-only'",
"name": "origin",
"title": "Referrer Policy is set to 'origin'",
"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",
"test_expansion": [
{
"name": "generic",
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"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": "origin"
}
]
},
{
"name": "same-origin",
"title": "Referrer Policy is set to 'same-origin'",
"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-referrer-policy/#referrer-policy-same-origin",
"referrer_policy": "same-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": "*",
"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-crossorigin'",
"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/specs/referrer-policy/#referrer-policy-state-origin-when-cross-origin",
"referrer_policy": "origin-when-crossorigin",
"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-csp", "meta-referrer", "meta-csp", "attr-referrer"],
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "same-origin",
"subresource": "*",
Expand All @@ -136,7 +222,7 @@
"expansion": "default",
"source_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": "*",
Expand All @@ -147,7 +233,7 @@
"expansion": "default",
"source_protocol": "http",
"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": "*",
Expand All @@ -158,7 +244,7 @@
"expansion": "default",
"source_protocol": "http",
"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": "*",
Expand All @@ -169,7 +255,7 @@
"expansion": "override",
"source_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",
"origin": "same-origin",
"subresource": "*",
Expand All @@ -180,7 +266,7 @@
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"],
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "cross-origin",
"subresource": "*",
Expand All @@ -192,15 +278,15 @@
"name": "unsafe-url",
"title": "Referrer Policy is set to 'unsafe-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",
"test_expansion": [
{
"name": "generic",
"expansion": "default",
"source_protocol": "*",
"target_protocol": "*",
"delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"],
"delivery_method": ["http-rp", "meta-referrer", "meta-csp", "attr-referrer"],
"redirection": "*",
"origin": "*",
"subresource": "*",
Expand Down Expand Up @@ -329,8 +415,9 @@
null,
"no-referrer",
"no-referrer-when-downgrade",
"same-origin",
"origin",
"origin-when-crossorigin",
"origin-when-cross-origin",
"unsafe-url"
],

Expand All @@ -341,7 +428,7 @@
],

"delivery_method": [
"http-csp",
"http-rp",
"meta-referrer",
"meta-csp",
"attr-referrer",
Expand Down

0 comments on commit fd50eb1

Please sign in to comment.