Skip to content

Commit 44e4706

Browse files
Camille Lamychromium-wpt-export-bot
authored andcommitted
COOP: emit report whenever there is another window in the bcg
This CL changes reporting of browsing context group switches for COOP. Prior to this CL, a report would only be generated if the frame had an opener at the start of navigation. Following this CL, the report is generated whenever there is another window in the browsing context group which is in line with the spec. Bug: 1148709 Change-Id: If2bf80365896a50692b4c02338a3fedf27348df7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2544504 Commit-Queue: Camille Lamy <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Auto-Submit: Camille Lamy <[email protected]> Cr-Commit-Position: refs/heads/master@{#831309}
1 parent 7726454 commit 44e4706

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<title>
2+
Reports a browsing context group switch when an opener with COOP navigates.
3+
</title>
4+
<meta name=timeout content=long>
5+
<script src=/resources/testharness.js></script>
6+
<script src=/resources/testharnessreport.js></script>
7+
<script src=/common/get-host-info.sub.js></script>
8+
<script src="/common/utils.js"></script>
9+
<script src="../resources/dispatcher.js"></script>
10+
<script>
11+
12+
const directory = "/html/cross-origin-opener-policy/reporting";
13+
const executor_path = directory + "/resources/executor.html?pipe=";
14+
const same_origin = get_host_info().HTTPS_ORIGIN;
15+
16+
let escapeComma = url => url.replace(/,/g, '\\,');
17+
18+
promise_test(async t => {
19+
// The test window.
20+
const this_window_token = token();
21+
22+
// The "opener" window.
23+
const opener_token = token();
24+
const opener_url = same_origin + executor_path + `&uuid=${opener_token}`;
25+
26+
// The "openee" window.
27+
const openee_token = token();
28+
const openee_url = same_origin + executor_path + `&uuid=${openee_token}`;
29+
30+
// The "final" url the opener will navigate to. It has COOP and a reporter.
31+
const final_report_token= token();
32+
const final_token = token();
33+
const final_reportTo = reportToHeaders(final_report_token);
34+
const final_url = same_origin + executor_path + final_reportTo.header +
35+
final_reportTo.coopSameOriginHeader +`&uuid=${final_token}`;
36+
37+
// 1. Create the opener window and ensure it doesn't have an opener.
38+
let opener_window_proxy = window.open(opener_url, '_blank', 'noopener');
39+
t.add_cleanup(() => send(opener_token, "window.close()"));
40+
41+
// 2. The opener opens a window.
42+
send(opener_token, `
43+
openee = window.open('${escapeComma(openee_url)}');
44+
send("${this_window_token}", "ACK 1");
45+
`);
46+
47+
// 3. Ensure the openee loads.
48+
send(openee_token, `
49+
send("${this_window_token}", "ACK 1");
50+
`);
51+
assert_equals("ACK 1", await receive(this_window_token));
52+
53+
// 4. The opener navigates.
54+
send(opener_token, `
55+
location.replace('${escapeComma(final_url)}');
56+
`);
57+
58+
// 5. Check a report was sent to the opener.
59+
let report =
60+
await receiveReport(final_report_token, "navigation-to-response")
61+
assert_equals(report.type, "coop");
62+
assert_equals(report.url, final_url.replace(/"/g, '%22'));
63+
assert_equals(report.body.disposition, "enforce");
64+
assert_equals(report.body.effectivePolicy, "same-origin");
65+
assert_equals(report.body.previousResponseURL, opener_url.replace(/"/g, '%22'));
66+
}, "navigation-report-from-opener-navigation");
67+
68+
</script>

0 commit comments

Comments
 (0)