-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WPT for permissions policy report-only mode
Change-Id: Ifb7aadc82992db73385676b92fc576cdcd1b7077 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4915362 Reviewed-by: Ari Chivukula <arichiv@chromium.org> Commit-Queue: Ian Clelland <iclelland@chromium.org> Cr-Commit-Position: refs/heads/main@{#1206551}
- Loading branch information
1 parent
2e73f41
commit 0a366a4
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
permissions-policy/reporting/report-only-and-enforce.https.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src='/resources/testdriver.js'></script> | ||
<script src='/resources/testdriver-vendor.js'></script> | ||
<script src='../../mediacapture-streams/permission-helper.js'></script> | ||
<script src='/reporting/resources/report-helper.js'></script> | ||
</head> | ||
<body> | ||
<script> | ||
const base_url = `${location.protocol}//${location.host}`; | ||
const endpoint = `${base_url}/reporting/resources/report.py`; | ||
const enforcing_id = '69c90b97-8b7c-4439-b5d2-ff03f237b2b2'; | ||
const report_only_id = '9d095a14-6b1c-40e1-be19-55a1fec97d11'; | ||
|
||
promise_test(async t => { | ||
await setMediaPermission("granted", ["camera","microphone"]); | ||
await promise_rejects_dom( | ||
t, "NotAllowedError", navigator.mediaDevices.getUserMedia({video: true}), | ||
"UserMedia camera access should not be allowed in this document."); | ||
while(true) { | ||
await wait(100); | ||
const reports = await pollReports(endpoint, enforcing_id); | ||
if (reports.length) { | ||
checkReportExists(reports, 'permissions-policy-violation', location.href); | ||
break; | ||
} | ||
} | ||
const report_only_reports = await pollReports(endpoint, report_only_id); | ||
assert_equals(report_only_reports.length, 0, "Report-only endpoint should not receive report."); | ||
}, "Enforcing policy receives reports when both enforcing and report-only policies are set."); | ||
</script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
permissions-policy/reporting/report-only-and-enforce.https.sub.html.sub.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Permissions-Policy: camera=();report-to=enforcing-endpoint | ||
Permissions-Policy-Report-Only: camera=();report-to=report-only-endpoint | ||
Reporting-Endpoints: enforcing-endpoint="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=69c90b97-8b7c-4439-b5d2-ff03f237b2b2", report-only-endpoint="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=9d095a14-6b1c-40e1-be19-55a1fec97d11" |
32 changes: 32 additions & 0 deletions
32
permissions-policy/reporting/report-only-single-endpoint.https.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src='/resources/testdriver.js'></script> | ||
<script src='/resources/testdriver-vendor.js'></script> | ||
<script src='../../mediacapture-streams/permission-helper.js'></script> | ||
<script src='/reporting/resources/report-helper.js'></script> | ||
</head> | ||
<body> | ||
<script> | ||
const base_url = `${location.protocol}//${location.host}`; | ||
const endpoint = `${base_url}/reporting/resources/report.py`; | ||
const id = 'c3841a1a-e750-4801-a50b-c4222d386515'; | ||
|
||
promise_test(async t => { | ||
await setMediaPermission("granted", ["camera","microphone"]); | ||
// This should not throw, as the enforcing policy does not block it. | ||
await navigator.mediaDevices.getUserMedia({video: true}); | ||
while(true) { | ||
await wait(100); | ||
const reports = await pollReports(endpoint, id); | ||
if (reports.length) { | ||
checkReportExists(reports, 'permissions-policy-violation', location.href); | ||
break; | ||
} | ||
} | ||
}, "Reporting-Endpoints defined endpoint received reports in report-only mode."); | ||
</script> | ||
</body> | ||
</html> |
2 changes: 2 additions & 0 deletions
2
permissions-policy/reporting/report-only-single-endpoint.https.sub.html.sub.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Permissions-Policy-Report-Only: camera=();report-to=camera-endpoint | ||
Reporting-Endpoints: camera-endpoint="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=c3841a1a-e750-4801-a50b-c4222d386515" |