Commit ee0c101e authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[COOP] access reporting toward the opener.

We have tests with:
- (opener <-> openee) with COOP on the openee.

This patches adds:
- (opener <-> openee) with COOP on the opener.

Along the way, reduce the size of the previous set of tests, make them
independent of the other reports.

Bug: 1090273
Change-Id: I2af9e6f520cec745a875e4b048d02b7c6e6573b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255470
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarPâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780799}
parent fea89df3
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL w => w.blur() assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.blur() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.close() assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.close() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.closed assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.closed assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.focus() assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.focus() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.frames assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.frames assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w[0] assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w[0] assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w[0] = "" assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w[0] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.length assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.length assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.location assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.location assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.location = "#" assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.location = "#" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w["test"] assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w["test"] assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w["test"] = "" assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w["test"] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.opener assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.opener assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.opener = "" assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.opener = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.postMessage("") assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.postMessage("") assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.postMessage("", "") assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.postMessage("", "") assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.self assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.self assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.top assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.top assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.window assert_not_equals: Receive navigation-to-document report got disallowed value "timeout" FAIL w => w.window assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -58,33 +58,21 @@ operation.forEach(([property, op]) => { ...@@ -58,33 +58,21 @@ operation.forEach(([property, op]) => {
let reply = await receive(callback_token); let reply = await receive(callback_token);
assert_equals(reply, "Ready"); assert_equals(reply, "Ready");
// 2. Skip the first report about the opener breakage. // 2. Try to access the openee. A report is sent, because of COOP-RO+COEP.
let report_1 = await receive(report_token);
assert_not_equals(report_1, "timeout",
"Receive navigation-to-document report");
report_1 = JSON.parse(report_1);
assert_equals(report_1.length, 1);
assert_equals(report_1[0].type, "coop");
assert_equals(report_1[0].body["violation-type"], "navigation-to-document");
assert_equals(report_1[0].body["disposition"], "reporting");
// 3. Try to access the openee. A report is sent, because of COOP-RO+COEP.
try {op(openee)} catch(e) {} try {op(openee)} catch(e) {}
// 4. A COOP access reports must be sent as a result of (3). // 3. Check a report is sent to the openee.
let report_2 = await receive(report_token); let report = await receiveReport(report_token, "access-to-coop-page")
assert_not_equals(report_2, "timeout", "Receive access report"); assert_not_equals(report, "timeout", "Report not received");
report_2 = JSON.parse(report_2); assert_equals(report.type, "coop");
assert_equals(report_2.length, 1); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report_2[0].type, "coop"); assert_equals(report.body["violation-type"], "access-to-coop-page");
assert_equals(report_2[0].url, openee_url.replace(/"/g, '%22')); assert_equals(report.body["disposition"], "reporting");
assert_equals(report_2[0].body["violation-type"], "access-to-coop-page"); assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report_2[0].body["disposition"], "reporting"); assert_equals(report.body["property"], property);
assert_equals(report_2[0].body["effective-policy"], "same-origin-plus-coep"); assert_equals(report.body["source-file"], undefined);
assert_equals(report_2[0].body["property"], property); assert_equals(report.body["lineno"], undefined);
assert_equals(report_2[0].body["source-file"], undefined); assert_equals(report.body["colno"], undefined);
assert_equals(report_2[0].body["lineno"], undefined);
assert_equals(report_2[0].body["colno"], undefined);
// TODO(arthursonzogni): Add check for report > body > blocked-window-url // TODO(arthursonzogni): Add check for report > body > blocked-window-url
}, `${op}`); }, `${op}`);
}); });
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL w => w.blur() assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.blur() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.close() assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.close() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.closed assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.closed assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.focus() assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.focus() assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.frames assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.frames assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w[0] assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w[0] assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w[0] = "" assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w[0] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.length assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.length assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.location assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.location assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.location = "#" assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.location = "#" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w["test"] assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w["test"] assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w["test"] = "" assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w["test"] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.opener assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.opener assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.opener = "" assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.opener = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.postMessage("") assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.postMessage("") assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.postMessage("", "") assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.postMessage("", "") assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.self assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.self assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.top assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.top assert_not_equals: Report not received got disallowed value "timeout"
FAIL w => w.window assert_not_equals: Receive access report got disallowed value "timeout" FAIL w => w.window assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -58,33 +58,21 @@ operation.forEach(([property, op]) => { ...@@ -58,33 +58,21 @@ operation.forEach(([property, op]) => {
let reply = await receive(callback_token); let reply = await receive(callback_token);
assert_equals(reply, "Ready"); assert_equals(reply, "Ready");
// 2. Skip the first report about the opener breakage. // 2. Try to access the openee. This shouldn't work because of COOP+COEP.
let report_1 = await receive(report_token);
assert_not_equals(report_1, "timeout",
"Receive navigation-to-document report");
report_1 = JSON.parse(report_1);
assert_equals(report_1.length, 1);
assert_equals(report_1[0].type, "coop");
assert_equals(report_1[0].body["violation-type"], "navigation-to-document");
assert_equals(report_1[0].body["disposition"], "enforce");
// 3. Try to access the openee. This shouldn't work because of COOP+COEP.
try {op(openee)} catch(e) {} try {op(openee)} catch(e) {}
// 4. A COOP access reports must be sent as a result of (3). // 3. Check a report is sent to the openee.
let report_2 = await receive(report_token); let report = await receiveReport(report_token, "access-to-coop-page")
assert_not_equals(report_2, "timeout", "Receive access report"); assert_not_equals(report, "timeout", "Report not received");
report_2 = JSON.parse(report_2); assert_equals(report.type, "coop");
assert_equals(report_2.length, 1); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report_2[0].type, "coop"); assert_equals(report.body["violation-type"], "access-to-coop-page");
assert_equals(report_2[0].url, openee_url.replace(/"/g, '%22')); assert_equals(report.body["disposition"], "enforce");
assert_equals(report_2[0].body["violation-type"], "access-to-coop-page"); assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report_2[0].body["disposition"], "enforce"); assert_equals(report.body["property"], property);
assert_equals(report_2[0].body["effective-policy"], "same-origin-plus-coep"); assert_equals(report.body["source-file"], undefined);
assert_equals(report_2[0].body["property"], property); assert_equals(report.body["lineno"], undefined);
assert_equals(report_2[0].body["source-file"], undefined); assert_equals(report.body["colno"], undefined);
assert_equals(report_2[0].body["lineno"], undefined);
assert_equals(report_2[0].body["colno"], undefined);
// TODO(arthursonzogni): Add check for report > body > blocked-window-url // TODO(arthursonzogni): Add check for report > body > blocked-window-url
}, `${op}`); }, `${op}`);
......
This is a testharness.js-based test.
FAIL Opener (COOP-RO+COEP) access cross origin openee assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion.
<title>
COOP reports are to the opener when the opener used COOP-RO+COEP and then it
tries to access a cross-origin openee.
</title>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/get-host-info.sub.js></script>
<script src="/common/utils.js"></script>
<script src="./resources/dispatcher.js"></script>
<script>
const directory = "/html/cross-origin-opener-policy/access-reporting";
const executor_path = directory + "/resources/executor.html?pipe=";
const same_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const coep_header = '|header(Cross-Origin-Embedder-Policy,require-corp)';
promise_test(async t => {
// The test window.
const this_window_token = token();
// The "opener" window. This has COOP and a reporter.
const opener_report_token= token();
const opener_token = token();
const opener_reportTo = reportToHeaders(opener_report_token);
const opener_url = same_origin + executor_path + opener_reportTo.header +
opener_reportTo.coopReportOnlySameOriginHeader + coep_header +
`&uuid=${opener_token}`;
// The "openee" window. This is cross origin with the "opener".
const openee_report_token= token();
const openee_token = token();
const openee_url = same_origin + executor_path + `&uuid=${openee_token}`;
// 1. Create the opener window.
let opener_window_proxy = window.open(opener_url);
t.add_cleanup(() => send(opener_token, "window.close()"));
// 2. The opener opens it openee.
send(opener_token, `
let openee = window.open("${openee_url}");
send("${this_window_token}", "ACK 1");
`);
assert_equals("ACK 1", await receive(this_window_token));
t.add_cleanup(() => send(openee_token, "window.close()"));
// 3. Ensure the openee's document to be loaded.
send(openee_token, `
send("${this_window_token}", "ACK 2");
`);
assert_equals("ACK 2", await receive(this_window_token));
// 4. The opener tries to access its openee.
send(opener_token, `
try {openee.blur()} catch(e) {}
`);
// 5. Check a report sent to the opener.
let report = await receiveReport(opener_report_token, "access-from-coop-page")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body["violation-type"], "access-from-coop-page");
assert_equals(report.body["disposition"], "reporting");
assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report.body["property"], "blur");
assert_equals(report.body["source-file"], undefined);
assert_equals(report.body["lineno"], undefined);
assert_equals(report.body["colno"], undefined);
// TODO(arthursonzogni): Check the window-blocked-url.
}, "Opener (COOP-RO+COEP) access cross origin openee");
</script>
This is a testharness.js-based test.
FAIL Opener (COOP+COEP) access cross origin openee assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion.
<title>
COOP reports are to the opener when the opener used COOP+COEP and then it
tries to access a cross-origin openee.
</title>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/get-host-info.sub.js></script>
<script src="/common/utils.js"></script>
<script src="./resources/dispatcher.js"></script>
<script>
const directory = "/html/cross-origin-opener-policy/access-reporting";
const executor_path = directory + "/resources/executor.html?pipe=";
const same_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const coep_header = '|header(Cross-Origin-Embedder-Policy,require-corp)';
promise_test(async t => {
// The test window.
const this_window_token = token();
// The "opener" window. This has COOP and a reporter.
const opener_report_token= token();
const opener_token = token();
const opener_reportTo = reportToHeaders(opener_report_token);
const opener_url = same_origin + executor_path + opener_reportTo.header +
opener_reportTo.coopSameOriginHeader + coep_header +
`&uuid=${opener_token}`;
// The "openee" window. This is cross origin with the "opener".
const openee_report_token= token();
const openee_token = token();
const openee_url = same_origin + executor_path + `&uuid=${openee_token}`;
// 1. Create the opener window.
let opener_window_proxy = window.open(opener_url);
t.add_cleanup(() => send(opener_token, "window.close()"));
// 2. The opener opens it openee.
send(opener_token, `
let openee = window.open("${openee_url}");
send("${this_window_token}", "ACK 1");
`);
assert_equals("ACK 1", await receive(this_window_token));
t.add_cleanup(() => send(openee_token, "window.close()"));
// 3. Ensure the openee's document to be loaded.
send(openee_token, `
send("${this_window_token}", "ACK 2");
`);
assert_equals("ACK 2", await receive(this_window_token));
// 4. The opener tries to access its openee.
send(opener_token, `
try {openee.blur()} catch(e) {}
`);
// 5. Check a report sent to the opener.
let report = await receiveReport(opener_report_token, "access-from-coop-page")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body["violation-type"], "access-from-coop-page");
assert_equals(report.body["disposition"], "enforce");
assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report.body["property"], "blur");
assert_equals(report.body["source-file"], undefined);
assert_equals(report.body["lineno"], undefined);
assert_equals(report.body["colno"], undefined);
// TODO(arthursonzogni): Check the window-blocked-url.
}, "Opener (COOP+COEP) access cross origin openee");
</script>
...@@ -64,26 +64,20 @@ operation.forEach(([property, op]) => { ...@@ -64,26 +64,20 @@ operation.forEach(([property, op]) => {
// 3. Try to access the opener. A report is sent, because of COOP-RO+COEP. // 3. Try to access the opener. A report is sent, because of COOP-RO+COEP.
send(executor_token, ` send(executor_token, `
try {${op}} catch(e) {} try {${op}} catch(e) {}
send("${callback_token}", "Done");
`); `);
let reply = await receive(callback_token);
assert_equals(reply, "Done");
// 4. A COOP access reports must be sent as a result of (3). // 3. Check a report is sent to the openee.
let report_2 = await receive(report_token); let report = await receiveReport(report_token, "access-from-coop-page")
assert_not_equals(report_2, "timeout", "Receive access report"); assert_not_equals(report, "timeout", "Report not received");
report_2 = JSON.parse(report_2); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report_2.length, 1); assert_equals(report.body["violation-type"], "access-from-coop-page");
assert_equals(report_2[0].type, "coop"); assert_equals(report.body["disposition"], "reporting");
assert_equals(report_2[0].url, openee_url.replace(/"/g, '%22')); assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report_2[0].body["violation-type"], "access-from-coop-page"); assert_equals(report.body["property"], property);
assert_equals(report_2[0].body["disposition"], "reporting"); assert_equals(report.body["source-file"], undefined);
assert_equals(report_2[0].body["effective-policy"], "same-origin-plus-coep"); assert_equals(report.body["lineno"], undefined);
assert_equals(report_2[0].body["property"], property); assert_equals(report.body["colno"], undefined);
assert_equals(report_2[0].body["source-file"], undefined);
assert_equals(report_2[0].body["lineno"], undefined);
assert_equals(report_2[0].body["colno"], undefined);
}, `${op})`); }, `${op})`);
}); });
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL opener.blur() assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.blur() assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.close() assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.close() assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.closed assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.closed assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.focus() assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.focus() assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.frames assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.frames assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener[0] assert_not_equals: Received access report got disallowed value "timeout" FAIL opener[0] assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener[0] = "" assert_not_equals: Received access report got disallowed value "timeout" FAIL opener[0] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.length assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.length assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.location assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.location assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.location = "#" assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.location = "#" assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener["test"] assert_not_equals: Received access report got disallowed value "timeout" FAIL opener["test"] assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener["test"] = "" assert_not_equals: Received access report got disallowed value "timeout" FAIL opener["test"] = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.opener assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.opener assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.opener = "" assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.opener = "" assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.postMessage("") assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.postMessage("") assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.postMessage("", "") assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.postMessage("", "") assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.self assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.self assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.top assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.top assert_not_equals: Report not received got disallowed value "timeout"
FAIL opener.window assert_not_equals: Received access report got disallowed value "timeout" FAIL opener.window assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -51,39 +51,23 @@ operation.forEach(([property, op]) => { ...@@ -51,39 +51,23 @@ operation.forEach(([property, op]) => {
const openee = window.open(openee_url); const openee = window.open(openee_url);
t.add_cleanup(() => send(executor_token, "window.close()")); t.add_cleanup(() => send(executor_token, "window.close()"));
// 1. Skip the first report about the opener breakage. // 2. Try to access the opener. A report is sent, because of COOP+COEP.
let report_1 = await receive(report_token);
assert_not_equals(report_1, "timeout",
"Receive navigation-to-document report");
report_1 = JSON.parse(report_1);
assert_equals(report_1.length, 1);
assert_equals(report_1[0].type, "coop");
assert_equals(report_1[0].body["violation-type"], "navigation-to-document");
assert_equals(report_1[0].body["disposition"], "enforce");
// 3. Try to access the opener. A report is sent, because of COOP+COEP.
send(executor_token, ` send(executor_token, `
try {${op}} catch(e) {} try {${op}} catch(e) {}
send("${callback_token}", "Done");
`); `);
let reply = await receive(callback_token);
assert_equals(reply, "Done");
// 4. A COOP access reports must be sent as a result of (3).
let report_2 = await receive(report_token);
assert_not_equals(report_2, "timeout", "Received access report");
report_2 = JSON.parse(report_2);
assert_equals(report_2.length, 1); // 3. Check a report is sent to the openee.
assert_equals(report_2[0].type, "coop"); let report = await receiveReport(report_token, "access-from-coop-page")
assert_equals(report_2[0].url, openee_url.replace(/"/g, '%22')); assert_not_equals(report, "timeout", "Report not received");
assert_equals(report_2[0].body["violation-type"], "access-from-coop-page"); assert_equals(report.type, "coop");
assert_equals(report_2[0].body["disposition"], "enforce"); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report_2[0].body["effective-policy"], "same-origin-plus-coep"); assert_equals(report.body["violation-type"], "access-from-coop-page");
assert_equals(report_2[0].body["property"], property); assert_equals(report.body["disposition"], "enforce");
assert_equals(report_2[0].body["source-file"], undefined); assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report_2[0].body["lineno"], undefined); assert_equals(report.body["property"], property);
assert_equals(report_2[0].body["colno"], undefined); assert_equals(report.body["source-file"], undefined);
assert_equals(report.body["lineno"], undefined);
assert_equals(report.body["colno"], undefined);
}, `${op}`); }, `${op}`);
}); });
......
This is a testharness.js-based test.
FAIL Opener (COOP-RO+COEP) accessed by cross origin openee assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion.
<title>
COOP reports are to the opener when the opener used COOP-RO+COEP and then its
cross-origin openee tries to access it.
</title>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/get-host-info.sub.js></script>
<script src="/common/utils.js"></script>
<script src="./resources/dispatcher.js"></script>
<script>
const directory = "/html/cross-origin-opener-policy/access-reporting";
const executor_path = directory + "/resources/executor.html?pipe=";
const same_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const coep_header = '|header(Cross-Origin-Embedder-Policy,require-corp)';
promise_test(async t => {
// The test window.
const this_window_token = token();
// The "opener" window. This has COOP and a reporter.
const opener_report_token= token();
const opener_token = token();
const opener_reportTo = reportToHeaders(opener_report_token);
const opener_url = same_origin + executor_path + opener_reportTo.header +
opener_reportTo.coopReportOnlySameOriginHeader + coep_header +
`&uuid=${opener_token}`;
// The "openee" window. This is cross origin with the "opener".
const openee_report_token= token();
const openee_token = token();
const openee_url = same_origin + executor_path + `&uuid=${openee_token}`;
// 1. Create the opener window.
let opener_window_proxy = window.open(opener_url);
t.add_cleanup(() => send(opener_token, "window.close()"));
// 2. The opener opens its openee.
send(opener_token, `
let openee = window.open("${openee_url}");
send("${this_window_token}", "ACK 1");
`);
assert_equals("ACK 1", await receive(this_window_token));
t.add_cleanup(() => send(openee_token, "window.close()"));
// 3. The openee tries to access its opener.
send(openee_token, `
try {opener.blur()} catch(e) {}
send("${this_window_token}", "ACK 3");
`);
assert_equals("ACK 3", await receive(this_window_token));
// 4. Check a report sent to the opener.
let report = await receiveReport(opener_report_token, "access-to-coop-page")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body["violation-type"], "access-to-coop-page");
assert_equals(report.body["disposition"], "reporting");
assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report.body["property"], "blur");
assert_equals(report.body["source-file"], undefined);
assert_equals(report.body["lineno"], undefined);
assert_equals(report.body["colno"], undefined);
// TODO(arthursonzogni): Check the window-blocked-url.
}, "Opener (COOP-RO+COEP) accessed by cross origin openee");
</script>
This is a testharness.js-based test.
FAIL Opener (COOP+COEP) accessed by cross origin openee assert_not_equals: Report not received got disallowed value "timeout"
Harness: the test ran to completion.
<title>
COOP reports are to the opener when the opener used COOP+COEP and then its
cross-origin openee tries to access it.
</title>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/common/get-host-info.sub.js></script>
<script src="/common/utils.js"></script>
<script src="./resources/dispatcher.js"></script>
<script>
const directory = "/html/cross-origin-opener-policy/access-reporting";
const executor_path = directory + "/resources/executor.html?pipe=";
const same_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const coep_header = '|header(Cross-Origin-Embedder-Policy,require-corp)';
promise_test(async t => {
// The test window.
const this_window_token = token();
// The "opener" window. This has COOP and a reporter.
const opener_report_token= token();
const opener_token = token();
const opener_reportTo = reportToHeaders(opener_report_token);
const opener_url = same_origin + executor_path + opener_reportTo.header +
opener_reportTo.coopSameOriginHeader + coep_header +
`&uuid=${opener_token}`;
// The "openee" window. This is cross origin with the "opener".
const openee_report_token= token();
const openee_token = token();
const openee_url = same_origin + executor_path + `&uuid=${openee_token}`;
// 1. Create the opener window.
let opener_window_proxy = window.open(opener_url);
t.add_cleanup(() => send(opener_token, "window.close()"));
// 2. The opener opens its openee.
send(opener_token, `
let openee = window.open("${openee_url}");
send("${this_window_token}", "ACK 1");
`);
assert_equals("ACK 1", await receive(this_window_token));
t.add_cleanup(() => send(openee_token, "window.close()"));
// 3. The openee tries to access its opener.
send(openee_token, `
try {opener.blur()} catch(e) {}
`);
// 4. Check a report is sent to the opener.
let report = await receiveReport(opener_report_token, "access-to-coop-page")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body["violation-type"], "access-to-coop-page");
assert_equals(report.body["disposition"], "enforce");
assert_equals(report.body["effective-policy"], "same-origin-plus-coep");
assert_equals(report.body["property"], "blur");
assert_equals(report.body["source-file"], undefined);
assert_equals(report.body["lineno"], undefined);
assert_equals(report.body["colno"], undefined);
// TODO(arthursonzogni): Check the window-blocked-url.
}, "Opener (COOP+COEP) accessed by cross origin openee");
</script>
...@@ -30,6 +30,20 @@ const receive = async function(uuid) { ...@@ -30,6 +30,20 @@ const receive = async function(uuid) {
return "timeout"; return "timeout";
} }
const receiveReport = async function(uuid, type) {
while(true) {
let reports = await receive(uuid);
if (reports == "timeout")
return "timeout";
reports = JSON.parse(reports);
for(report of reports) {
if (report?.["body"]?.["violation-type"] == type)
return report;
}
}
}
// Build a set of headers to tests the reporting API. This defines a set of // Build a set of headers to tests the reporting API. This defines a set of
// matching 'Report-To', 'Cross-Origin-Opener-Policy' and // matching 'Report-To', 'Cross-Origin-Opener-Policy' and
// 'Cross-Origin-Opener-Policy-Report-Only' headers. // 'Cross-Origin-Opener-Policy-Report-Only' headers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment