Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on experimental document policies in tests #46291

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion document-policy/echo-policy-nested.html.headers
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Document-Policy: lossless-images-max-bpp=0.0
Document-Policy: sync-xhr=?0
8 changes: 4 additions & 4 deletions document-policy/required-policy/document-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ <h1>Test advertised required document policy</h1>
async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=2";
iframe.policy = "font-display-late-swap=?0";
iframe.policy = "force-load-at-top";
callbacks["2"] = t.step_func_done(result => {
assert_equals(result, "font-display-late-swap=?0");
assert_equals(result, "force-load-at-top");
});
document.body.appendChild(iframe);
}, "Child frame can have a required policy independent of the parent document.");

async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=3";
iframe.policy = "lossless-images-max-bpp=4";
iframe.policy = "sync-xhr";
callbacks["3"] = t.step_func_done(result => {
assert_equals(result, "lossless-images-max-bpp=4.0");
assert_equals(result, "sync-xhr");
});
document.body.appendChild(iframe);
}, "Child frame can have a required policy which is less strict than the parent document's policy.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Document-Policy: lossless-images-max-bpp=1.1
Document-Policy: sync-xhr=?0
4 changes: 2 additions & 2 deletions document-policy/required-policy/no-document-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ <h1>Test advertised required document policy</h1>
async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=2";
iframe.policy = "font-display-late-swap=?0";
iframe.policy = "force-load-at-top=?0";
callbacks["2"] = t.step_func_done(result => {
assert_equals(result, "font-display-late-swap=?0");
assert_equals(result, "force-load-at-top=?0");
});
document.body.appendChild(iframe);
}, "Child frame can have an explicit required policy.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ <h1>Test advertised required document policy</h1>

// Frame tree should be:
// Top:
// <iframe policy="lossless-images-max-bpp=1.1">
// <iframe policy="sync-xhr=?0">
// <iframe>
async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy-nested.html?id=2";
iframe.policy = "lossless-images-max-bpp=1.1";
iframe.policy = "sync-xhr=?0";
callbacks["2"] = t.step_func_done(result => {
assert_equals(result, "lossless-images-max-bpp=1.1");
assert_equals(result, "sync-xhr=?0");
});
document.body.appendChild(iframe);
}, "test nested required document policy when set by nested frame");

// Frame tree should be:
// Top:
// <iframe policy="lossless-images-max-bpp=1.1">
// <iframe policy="sync-xhr=?0">
// <iframe>
// <iframe>
async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy-nested.html?id=3&level=1";
iframe.policy = "lossless-images-max-bpp=1.1";
iframe.policy = "sync-xhr=?0";
callbacks["3"] = t.step_func_done(result => {
assert_equals(result, "lossless-images-max-bpp=1.1");
assert_equals(result, "sync-xhr=?0");
});
document.body.appendChild(iframe);
}, "test nested required document policy when set by intermediate nested frame");
Expand Down
28 changes: 17 additions & 11 deletions document-policy/required-policy/required-document-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,26 @@ <h1>Test advertised required document policy</h1>
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=1";
callbacks["1"] = t.step_func_done(result => {
assert_equals(result, "lossless-images-max-bpp=1.1");
assert_equals(result, "sync-xhr=?0");
});
document.body.appendChild(iframe);
}, "Child frame with no explicit policy should have the same required policy as its parent.");

async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=4";
iframe.policy = "force-load-at-top=?0";
callbacks["4"] = t.step_func_done(result => {
assert_equals(result, "force-load-at-top=?0, sync-xhr=?0");
});
document.body.appendChild(iframe);
}, "Any unrelated policy directives should combine with the parent's required policy.");

// The following scenarios are not currently testable, as there are no configuration points
// defined with numeric value types. They were previously run with this document having a
// header policy of "lossless-images-max-bpp=1.1".
// TODO: Reinstate these tests when such a configuration point is reintroduced.
/*
async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=2";
Expand All @@ -50,16 +65,7 @@ <h1>Test advertised required document policy</h1>
});
document.body.appendChild(iframe);
}, "Child frame may have a stricter policy than the parent.");

async_test(t => {
var iframe = document.createElement('iframe');
iframe.src = "/document-policy/echo-policy.py?id=4";
iframe.policy = "font-display-late-swap=?0";
callbacks["4"] = t.step_func_done(result => {
assert_equals(result, "font-display-late-swap=?0, lossless-images-max-bpp=1.1");
});
document.body.appendChild(iframe);
}, "Any unrelated policy directives should combine with the parent's required policy.");
*/
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Require-Document-Policy: lossless-images-max-bpp=1.1
Require-Document-Policy: sync-xhr=?0
7 changes: 6 additions & 1 deletion reporting/document-reporting-bypass-report-to.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
})
}, "document policy violation observed");
</script>
<script>document.write("This should be written into the document");</script>
<script>
// Attempt a synchronous XHR - this should succeed but cause a report to be sent.
const xhr = new XMLHttpRequest();
xhr.open("GET", document.location.href, false);
xhr.send();
</script>
<script>
const base_url = `${location.protocol}//${location.host}`;
const endpoint = `${base_url}/reporting/resources/report.py`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Reporting-Endpoints: group1="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=6c2131d0-1e9b-4ee8-a196-952f2ae4ae97"
Report-To: { "group": "group1", "max_age": 10886400, "endpoints": [{ "url": "/reporting/resources/report.py?reportID=caddb022-90ea-48e8-a675-4cebaf7e8388" }] }
Document-Policy-Report-Only: document-write=?0;report-to=group1
Document-Policy-Report-Only: sync-xhr=?0;report-to=group1
7 changes: 6 additions & 1 deletion reporting/document-reporting-named-endpoints.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
</script>
<img src='/reporting/resources/fail.png' onload='t.unreached_func("The image should not have loaded");'
onerror='t.done();'>
<script>document.write("This should be written into the document");</script>
<script>
// Attempt a synchronous XHR - this should succeed but cause a report to be sent.
const xhr = new XMLHttpRequest();
xhr.open("GET", document.location.href, false);
xhr.send();
</script>
<script>
const base_url = `${location.protocol}//${location.host}`;
const endpoint = `${base_url}/reporting/resources/report.py`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Reporting-Endpoints: group1="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=0d334af1-1c5c-4e59-9079-065131ff2a45"
Reporting-Endpoints: group2="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=09c1a265-5fc7-4c49-b35c-32078c2d0c19"
Content-Security-Policy: script-src 'self' 'unsafe-inline'; img-src 'none'; report-to group1
Document-Policy-Report-Only: document-write=?0;report-to=group2
Document-Policy-Report-Only: sync-xhr=?0;report-to=group2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
})
}, "document policy violation observed");
</script>
<script>document.write("This should be written into the document");</script>
<script>
// Attempt a synchronous XHR - this should succeed but cause a report to be sent.
const xhr = new XMLHttpRequest();
xhr.open("GET", document.location.href, false);
xhr.send();
</script>
<script>
const base_url = `${location.protocol}//${location.host}`;
const endpoint = `${base_url}/reporting/resources/report.py`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Reporting-Endpoints: group1="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=b523d7f5-28f0-4be6-9460-e163ee9b4ab8"
Reporting-Endpoints: group1="https://{{host}}:{{ports[https][0]}}/reporting/resources/report.py?reportID=03e4474d-768c-42f2-8e17-39aa95b309e3"
Document-Policy-Report-Only: document-write=?0;report-to=group1
Document-Policy-Report-Only: sync-xhr=?0;report-to=group1