Commit 74e4b2fc authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[COOP] access reporting: Use infinite timeout for receive.

Some browsers do not implement COOP reporting. As a result, no reports
are received after a 2.5s timeout.

Waiting 2.5s many time can reach the global timeout. Sometime, this
flakes in between FAIL and TIMEOUT.

This patch makes the timeout to be infinite by default to get consistent
failure.

Bug: 1090273
Change-Id: I081b9c8e944fc50b391753ce0948392b88d3fd0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2428976Reviewed-by: default avatarPâris Meuleman <pmeuleman@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810604}
parent 315e9703
...@@ -63,7 +63,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -63,7 +63,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 5. Check a report sent to the opener. // 5. Check a report sent to the opener.
let report = let report =
await receiveReport(opener_report_token, "access-from-coop-page-to-openee") await receiveReport(opener_report_token, "access-from-coop-page-to-openee")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -64,7 +64,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -64,7 +64,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 5. Check a report sent to the opener. // 5. Check a report sent to the opener.
let report = let report =
await receiveReport(opener_report_token, "access-from-coop-page-to-openee") await receiveReport(opener_report_token, "access-from-coop-page-to-openee")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -40,7 +40,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -40,7 +40,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 2. Check a report is sent to the openee. // 2. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-from-coop-page-to-opener") await receiveReport(report_token, "access-from-coop-page-to-opener")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -41,7 +41,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -41,7 +41,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 2. Check a report is sent to the openee. // 2. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-from-coop-page-to-opener") await receiveReport(report_token, "access-from-coop-page-to-opener")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -75,7 +75,6 @@ promise_test(async t => { ...@@ -75,7 +75,6 @@ promise_test(async t => {
// 6. Check a report is sent to the openee. // 6. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-from-coop-page-to-other") await receiveReport(report_token, "access-from-coop-page-to-other")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -76,7 +76,6 @@ promise_test(async t => { ...@@ -76,7 +76,6 @@ promise_test(async t => {
// 6. Check a report is sent to the openee. // 6. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-from-coop-page-to-other") await receiveReport(report_token, "access-from-coop-page-to-other")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -57,7 +57,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -57,7 +57,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 4. Check a report sent to the opener. // 4. Check a report sent to the opener.
let report = let report =
await receiveReport(opener_report_token, "access-to-coop-page-from-openee") await receiveReport(opener_report_token, "access-to-coop-page-from-openee")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -58,7 +58,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -58,7 +58,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 4. Check a report sent to the opener. // 4. Check a report sent to the opener.
let report = let report =
await receiveReport(opener_report_token, "access-to-coop-page-from-openee") await receiveReport(opener_report_token, "access-to-coop-page-from-openee")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, opener_url.replace(/"/g, '%22')); assert_equals(report.url, opener_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -47,7 +47,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -47,7 +47,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 3. Check a report is sent to the openee. // 3. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-to-coop-page-from-opener") await receiveReport(report_token, "access-to-coop-page-from-opener")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -48,7 +48,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => { ...@@ -48,7 +48,6 @@ let runTest = (openee_redirect, name) => promise_test(async t => {
// 3. Check a report is sent to the openee. // 3. Check a report is sent to the openee.
let report = let report =
await receiveReport(report_token, "access-to-coop-page-from-opener") await receiveReport(report_token, "access-to-coop-page-from-opener")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -63,7 +63,6 @@ promise_test(async t => { ...@@ -63,7 +63,6 @@ promise_test(async t => {
// 4. Check a report sent to the openee. // 4. Check a report sent to the openee.
let report = let report =
await receiveReport(openee_report_token, "access-to-coop-page-from-other") await receiveReport(openee_report_token, "access-to-coop-page-from-other")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -64,7 +64,6 @@ promise_test(async t => { ...@@ -64,7 +64,6 @@ promise_test(async t => {
// 4. Check a report sent to the openee. // 4. Check a report sent to the openee.
let report = let report =
await receiveReport(openee_report_token, "access-to-coop-page-from-other") await receiveReport(openee_report_token, "access-to-coop-page-from-other")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.url, openee_url.replace(/"/g, '%22')); assert_equals(report.url, openee_url.replace(/"/g, '%22'));
assert_equals(report.body.disposition, "reporting"); assert_equals(report.body.disposition, "reporting");
......
...@@ -58,7 +58,6 @@ origin.forEach(([origin_name, origin]) => { ...@@ -58,7 +58,6 @@ origin.forEach(([origin_name, origin]) => {
// 3. Check a reports is sent to the opener. // 3. Check a reports is sent to the opener.
let report = await receiveReport(report_token, "access-to-coop-page") let report = await receiveReport(report_token, "access-to-coop-page")
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.body.property, property); assert_equals(report.body.property, property);
}, `${origin_name} > ${op}`); }, `${origin_name} > ${op}`);
......
...@@ -83,9 +83,6 @@ promise_test(async test => { ...@@ -83,9 +83,6 @@ promise_test(async test => {
let report_openee = let report_openee =
await receiveReport(openee_report_token, "access-to-coop-page-from-opener") await receiveReport(openee_report_token, "access-to-coop-page-from-opener")
assert_not_equals(report_openee, "timeout", "Report openee not received");
assert_not_equals(report_opener, "timeout", "Report opener not received");
assert_generic_coop_report(report_openee); assert_generic_coop_report(report_openee);
assert_generic_coop_report(report_opener); assert_generic_coop_report(report_opener);
...@@ -109,9 +106,6 @@ promise_test(async test => { ...@@ -109,9 +106,6 @@ promise_test(async test => {
let report_openee = let report_openee =
await receiveReport(openee_report_token, "access-from-coop-page-to-opener") await receiveReport(openee_report_token, "access-from-coop-page-to-opener")
assert_not_equals(report_openee, "timeout", "Report openee not received");
assert_not_equals(report_opener, "timeout", "Report opener not received");
assert_generic_coop_report(report_openee); assert_generic_coop_report(report_openee);
assert_generic_coop_report(report_opener); assert_generic_coop_report(report_opener);
......
...@@ -186,7 +186,6 @@ promise_test(async t => { ...@@ -186,7 +186,6 @@ promise_test(async t => {
send(opener_iframe_token, `tryAccess(openee);`); send(opener_iframe_token, `tryAccess(openee);`);
let reports = await receive(this_window_token); let reports = await receive(this_window_token);
assert_not_equals(reports, "timeout", "No report received.");
reports = JSON.parse(reports); reports = JSON.parse(reports);
assert_equals(reports.length, 1, "No report received."); assert_equals(reports.length, 1, "No report received.");
assert_equals(reports[0].type, "coop-access-violation"); assert_equals(reports[0].type, "coop-access-violation");
...@@ -248,7 +247,7 @@ promise_test(async t => { ...@@ -248,7 +247,7 @@ promise_test(async t => {
// from the main document aren't notified. // from the main document aren't notified.
send(opener_iframe_token, `tryAccess(openee);`); send(opener_iframe_token, `tryAccess(openee);`);
let reports = await receive(this_window_token); let reports = await receive(this_window_token, 2000);
assert_equals(reports, "timeout", "Unexpected report received."); assert_equals(reports, "timeout", "Unexpected report received.");
}, "Access from cross-site iframe") }, "Access from cross-site iframe")
......
...@@ -101,7 +101,6 @@ function redirect_test( popup_origin ) { ...@@ -101,7 +101,6 @@ function redirect_test( popup_origin ) {
let report = await receiveReport( let report = await receiveReport(
opener_report_token, opener_report_token,
"navigation-to-response"); "navigation-to-response");
assert_not_equals(report, "timeout", "Report not received");
assert_equals(report.type, "coop"); assert_equals(report.type, "coop");
assert_equals(report.body.disposition, "enforce"); assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.effectivePolicy, "same-origin-allow-popups"); assert_equals(report.body.effectivePolicy, "same-origin-allow-popups");
......
...@@ -17,8 +17,8 @@ const send = function(uuid, message) { ...@@ -17,8 +17,8 @@ const send = function(uuid, message) {
}); });
} }
const receive = async function(uuid) { const receive = async function(uuid, maybe_timeout) {
const timeout = 2500; const timeout = maybe_timeout || Infinity;
const retry_delay = 100; const retry_delay = 100;
for(let i = 0; i * retry_delay < timeout; ++i) { for(let i = 0; i * retry_delay < timeout; ++i) {
let response = await fetch(dispatcher_url + `?uuid=${uuid}`); let response = await fetch(dispatcher_url + `?uuid=${uuid}`);
......
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