Commit 73f92c2b authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

[COOP] access reporting: Fix WPT flakes.

The WPT testharness.js is defining:
```
WindowTestEnvironment.prototype._forEach_windows = function(callback) {
// Iterate over the windows [self ... top, opener]. The callback is
// passed two objects, the first one is the window object itself, the
// second one is a boolean indicating whether or not it's on the same
// origin as the (...)
```

This causes some postMessage to be sent cross-window. They are detected
by the Cross-Origin-Opener-Policy-Report-Only.

In general, we must ensure that testharness.js isn't used together with
access checks. This patch removes the ones for all the tests depending
on test-access-property.js

Bug: 1090273
Change-Id: I9f13406783d4f5a1d28205b6492ab1b3318c50b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436743Reviewed-by: default avatarPâris Meuleman <pmeuleman@chromium.org>
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811734}
parent 4f717f7e
......@@ -6399,10 +6399,7 @@ crbug.com/1066579 http/tests/devtools/har-importer.js [ Pass Failure ]
crbug.com/1069714 [ Mac10.13 ] external/wpt/webrtc/RTCRtpSender-replaceTrack.https.html [ Pass Failure Timeout ]
# COOP access reporting:
crbug.com/1090273 external/wpt/html/cross-origin-opener-policy/reporting/access-reporting/property-frames.https.html [ Timeout ]
crbug.com/1090273 external/wpt/html/cross-origin-opener-policy/reporting/access-reporting/property-opener-set.https.html [ Timeout ]
crbug.com/1090273 external/wpt/html/cross-origin-opener-policy/reporting/access-reporting/property-self.https.html [ Timeout ]
crbug.com/1090273 external/wpt/html/cross-origin-opener-policy/reporting/access-reporting/property-window.https.html [ Timeout ]
# Sheriff 2020-04-17
crbug.com/1071909 external/wpt/html/cross-origin-opener-policy/popup-coop-by-sw.https.html [ Pass Timeout ]
......
......@@ -2,39 +2,52 @@ const directory = "/html/cross-origin-opener-policy/reporting";
const executor_path = directory + "/resources/executor.html?pipe=";
const coep_header = '|header(Cross-Origin-Embedder-Policy,require-corp)';
const same_origin = get_host_info().HTTPS_ORIGIN;
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
const origin = [
["cross-origin", get_host_info().HTTPS_REMOTE_ORIGIN ] ,
["same-site" , get_host_info().HTTPS_ORIGIN ] ,
["same-origin" , same_origin ],
["cross-origin", cross_origin],
];
let escapeComma = url => url.replace(/,/g, '\\,');
let testAccessProperty = (property, op, message) => {
origin.forEach(([origin_name, origin]) => {
promise_test(async t => {
const report_token = token();
const openee_token = token();
const opener_token = token(); // The current test window.
const this_window_token = token();
// The opener window:
const opener_token = token();
const opener_url = get_host_info().HTTP_ORIGIN + executor_path +
`&uuid=${opener_token}`;
const reportTo = reportToHeaders(report_token);
const openee_url = origin + executor_path + reportTo.header +
reportTo.coopReportOnlySameOriginHeader + coep_header +
// The openee window:
const openee_token = token();
const openee_report_token = token();
const openee_report_to = reportToHeaders(openee_report_token);
const openee_url = origin + executor_path + openee_report_to.header +
openee_report_to.coopReportOnlySameOriginHeader + coep_header +
`&uuid=${openee_token}`;
const openee = window.open(openee_url);
t.add_cleanup(() => send(openee_token, "window.close()"))
// 1. Make sure the new document to be loaded.
send(openee_token, `send("${opener_token}", "Ready");`);
assert_equals(await receive(opener_token), "Ready");
// TODO(arthursozogni): Figure out why 2 round-trip is sometimes
// necessary to ensure the CoopAccessMonitor are installed.
send(openee_token, `send("${opener_token}", "Ready");`);
assert_equals(await receive(opener_token), "Ready");
t.add_cleanup(() => {
send(opener_token, "window.close()")
send(openee_token, "window.close()")
});
// Open the two windows. Wait for them to be loaded.
window.open(opener_url);
send(opener_token, `
window.openee = window.open('${escapeComma(openee_url)}');
`);
send(openee_token, `send("${this_window_token}", "Ready");`);
assert_equals(await receive(this_window_token), "Ready");
// 2. Try to access the openee. This shouldn't work because of COOP+COEP.
try {op(openee)} catch(e) {}
// 2. Try to access the openee.
send(opener_token, `(${op})(openee);`);
// 3. Check a reports is sent to the opener.
let report = await receiveReport(report_token,
"access-to-coop-page-from-opener");
let report = await receiveReport(openee_report_token,
"access-to-coop-page-from-opener");
assert_equals(report.body.property, property);
}, `${origin_name} > ${op}`);
......
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