From fd50eb17fd4cdf718b7da8f0a0564f599edb7a39 Mon Sep 17 00:00:00 2001 From: Aravind Gollakota Date: Thu, 7 Jul 2016 21:47:31 -0700 Subject: [PATCH] test: Update tests/wpt/mozilla/.../referrer-policy/ Only has changes to spec.src.json, generate.py etc., no actual tests generated yet. --- .../tests/mozilla/referrer-policy/README.md | 2 +- .../mozilla/referrer-policy/generic/common.js | 4 +- .../generic/referrer-policy-test-case.js | 2 +- .../referrer-policy/generic/tools/generate.py | 8 +- .../mozilla/referrer-policy/spec.src.json | 149 ++++++++++++++---- 5 files changed, 126 insertions(+), 39 deletions(-) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md index fc84ce8d1cba..9d139c8e71d8 100644 --- a/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md @@ -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", diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js index c4f6bbb8dad3..5442f82da0f2 100644 --- a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js @@ -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]; @@ -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]; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js index 8e011be374f3..bc81e3d4655a 100644 --- a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js @@ -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"} }; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py index cc5af2a75c6e..a7972aec95a5 100755 --- a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py @@ -93,13 +93,13 @@ def generate_selection(selection, spec, subresource_path, selection['meta_delivery_method'] = \ '' % spec - elif selection['delivery_method'] == 'http-csp': + elif selection['delivery_method'] == 'http-rp': selection['meta_delivery_method'] = \ - "" + "" 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': diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json index 1c793c3364bd..fb0b81054cf4 100644 --- a/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json @@ -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": "*", @@ -24,7 +57,7 @@ "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": [ { @@ -32,7 +65,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": "*", "subresource": "*", @@ -44,7 +77,7 @@ "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": [ { @@ -52,7 +85,7 @@ "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": "*", @@ -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": "*", @@ -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": "*", @@ -94,10 +127,10 @@ ] }, { - "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": [ { @@ -105,7 +138,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": "*", "subresource": "*", @@ -113,19 +146,72 @@ } ] }, + { + "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": "*", @@ -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": "*", @@ -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": "*", @@ -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": "*", @@ -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": "*", @@ -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": "*", @@ -192,7 +278,7 @@ "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": [ { @@ -200,7 +286,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": "*", "subresource": "*", @@ -329,8 +415,9 @@ null, "no-referrer", "no-referrer-when-downgrade", + "same-origin", "origin", - "origin-when-crossorigin", + "origin-when-cross-origin", "unsafe-url" ], @@ -341,7 +428,7 @@ ], "delivery_method": [ - "http-csp", + "http-rp", "meta-referrer", "meta-csp", "attr-referrer",