Skip to content

Commit

Permalink
Worker: Add referrer policy tests for shared workers
Browse files Browse the repository at this point in the history
I manually changed only following files:

 - external/wpt/referrer-policy/generic/common.js
 - external/wpt/referrer-policy/generic/referrer-policy-test-case.js
 - external/wpt/referrer-policy/generic/subresource/shared-worker.py
 - external/wpt/referrer-policy/generic/template/shared-worker.js.template
 - external/wpt/referrer-policy/spec.src.json
 - TestExpectations

Others were auto-generated.

Bug: 835717, 906959
Change-Id: Ib0a84710fe94ba0893d9609bb708a3f5e8fd4091
  • Loading branch information
nhiroki authored and chromium-wpt-export-bot committed Nov 27, 2018
1 parent 4606e75 commit a8f5e87
Show file tree
Hide file tree
Showing 58 changed files with 1,541 additions and 4 deletions.
8 changes: 8 additions & 0 deletions referrer-policy/generic/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ function queryModuleWorkerTopLevel(url, callback) {
};
}

function querySharedWorker(url, callback) {
var worker = new SharedWorker(url);
worker.port.onmessage = function(event) {
var server_data = event.data;
callback(wrapResult(url, server_data), url);
};
}

function queryFetch(url, callback) {
fetch(url).then(function(response) {
response.json().then(function(server_data) {
Expand Down
1 change: 1 addition & 0 deletions referrer-policy/generic/referrer-policy-test-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) {
"script-tag": queryScript,
"worker-request": queryWorker,
"module-worker": queryModuleWorkerTopLevel,
"shared-worker": querySharedWorker,
"xhr-request": queryXhr
};

Expand Down
12 changes: 12 additions & 0 deletions referrer-policy/generic/subresource/shared-worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os, sys, json
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import subresource

def generate_payload(server_data):
return subresource.get_template("shared-worker.js.template") % server_data

def main(request, response):
subresource.respond(request,
response,
payload_generator = generate_payload,
content_type = "application/javascript")
5 changes: 5 additions & 0 deletions referrer-policy/generic/template/shared-worker.js.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
onconnect = function(e) {
e.ports[0].postMessage({
"headers": %(headers)s
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade'</title>
<meta name="description" content="Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.">
<!-- No meta: Referrer policy delivered via HTTP headers. -->
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade">
<meta name="assert" content="The referrer URL is stripped-referrer when a
document served over http requires an http
sub-resource via shared-worker using the http-rp
delivery method with keep-origin-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer-when-downgrade",
"delivery_method": "http-rp",
"redirection": "keep-origin-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "stripped-referrer"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Referrer-Policy: no-referrer-when-downgrade
Access-Control-Allow-Origin: *
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade'</title>
<meta name="description" content="Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.">
<!-- No meta: Referrer policy delivered via HTTP headers. -->
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade">
<meta name="assert" content="The referrer URL is stripped-referrer when a
document served over http requires an http
sub-resource via shared-worker using the http-rp
delivery method with no-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer-when-downgrade",
"delivery_method": "http-rp",
"redirection": "no-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "stripped-referrer"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Referrer-Policy: no-referrer-when-downgrade
Access-Control-Allow-Origin: *
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade'</title>
<meta name="description" content="Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.">
<meta name="referrer" content="no-referrer-when-downgrade">
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade">
<meta name="assert" content="The referrer URL is stripped-referrer when a
document served over http requires an http
sub-resource via shared-worker using the meta-referrer
delivery method with keep-origin-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer-when-downgrade",
"delivery_method": "meta-referrer",
"redirection": "keep-origin-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "stripped-referrer"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade'</title>
<meta name="description" content="Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.">
<meta name="referrer" content="no-referrer-when-downgrade">
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade">
<meta name="assert" content="The referrer URL is stripped-referrer when a
document served over http requires an http
sub-resource via shared-worker using the meta-referrer
delivery method with no-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer-when-downgrade",
"delivery_method": "meta-referrer",
"redirection": "no-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "stripped-referrer"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer'</title>
<meta name="description" content="Check that sub-resource never gets the referrer URL.">
<!-- No meta: Referrer policy delivered via HTTP headers. -->
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">
<meta name="assert" content="The referrer URL is omitted when a
document served over http requires an http
sub-resource via shared-worker using the http-rp
delivery method with keep-origin-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer",
"delivery_method": "http-rp",
"redirection": "keep-origin-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "omitted"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Referrer-Policy: no-referrer
Access-Control-Allow-Origin: *
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer'</title>
<meta name="description" content="Check that sub-resource never gets the referrer URL.">
<!-- No meta: Referrer policy delivered via HTTP headers. -->
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">
<meta name="assert" content="The referrer URL is omitted when a
document served over http requires an http
sub-resource via shared-worker using the http-rp
delivery method with no-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer",
"delivery_method": "http-rp",
"redirection": "no-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "omitted"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Referrer-Policy: no-referrer
Access-Control-Allow-Origin: *
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer'</title>
<meta name="description" content="Check that sub-resource never gets the referrer URL.">
<meta name="referrer" content="no-referrer">
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">
<meta name="assert" content="The referrer URL is omitted when a
document served over http requires an http
sub-resource via shared-worker using the meta-referrer
delivery method with keep-origin-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer",
"delivery_method": "meta-referrer",
"redirection": "keep-origin-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "omitted"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! Generated by referrer-policy/generic/tools/generate.py using referrer-policy/generic/template/test.release.html.template. -->
<html>
<head>
<title>Referrer-Policy: Referrer Policy is set to 'no-referrer'</title>
<meta name="description" content="Check that sub-resource never gets the referrer URL.">
<meta name="referrer" content="no-referrer">
<link rel="author" title="Kristijan Burnik" href="[email protected]">
<link rel="help" href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer">
<meta name="assert" content="The referrer URL is omitted when a
document served over http requires an http
sub-resource via shared-worker using the meta-referrer
delivery method with no-redirect and when
the target request is same-origin.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- TODO(kristijanburnik): Minify and merge both: -->
<script src="/referrer-policy/generic/common.js"></script>
<script src="/referrer-policy/generic/referrer-policy-test-case.js?pipe=sub"></script>
</head>
<body>
<script>
ReferrerPolicyTestCase(
{
"referrer_policy": "no-referrer",
"delivery_method": "meta-referrer",
"redirection": "no-redirect",
"origin": "same-origin",
"source_protocol": "http",
"target_protocol": "http",
"subresource": "shared-worker",
"subresource_path": "/referrer-policy/generic/subresource/shared-worker.py",
"referrer_url": "omitted"
},
document.querySelector("meta[name=assert]").content,
new SanityChecker()
).start();
</script>
<div id="log"></div>
</body>
</html>
Loading

0 comments on commit a8f5e87

Please sign in to comment.