Skip to content

update coop docs, particularly with -report-only#42051

Draft
steve-a-walsh wants to merge 3 commits intomdn:mainfrom
doxo:update-coop-docs
Draft

update coop docs, particularly with -report-only#42051
steve-a-walsh wants to merge 3 commits intomdn:mainfrom
doxo:update-coop-docs

Conversation

@steve-a-walsh
Copy link

@steve-a-walsh steve-a-walsh commented Nov 21, 2025

Description

This PR adds comprehensive documentation for the Cross-Origin-Opener-Policy-Report-Only header and the report-to parameter, which were previously missing from the MDN documentation. The update includes a new reporting section explaining how to set up and use COOP violation reporting, enhanced syntax documentation showing both header variants, and practical examples demonstrating how to test policies using the report-only variant.

Motivation

The MDN documentation for Cross-Origin-Opener-Policy was missing critical information that developers need to effectively implement and monitor COOP policies:

  1. Missing Cross-Origin-Opener-Policy-Report-Only header: This header is part of the official specification and is commonly used in production codebases to test policies before enforcement, but was completely absent from MDN documentation.

  2. Missing report-to parameter: The specification supports a report-to parameter for both COOP headers (similar to CSP), allowing developers to monitor policy violations. This functionality is already being used in real-world implementations but was undocumented.

  3. No reporting guidance: Developers had no documentation on how to set up reporting endpoints, what reports contain, or when they are generated.

These gaps made it difficult for developers to:

  • Test COOP policies safely before enforcement
  • Monitor policy violations in production
  • Understand the complete COOP feature set as specified in the WHATWG HTML specification

The updates align the MDN documentation with the official specification (WHATWG HTML Living Standard, section 7.1.3) and provide developers with the complete information needed to implement COOP effectively.

Additional details

  • Specification reference: WHATWG HTML Living Standard - Cross-Origin Opener Policies
    • Section 7.1.3.1: The headers (defines both COOP and COOP-Report-Only)
    • Section 7.1.3.3: Reporting (explains reporting functionality)
  • Related MDN pages:
    • {{HTTPHeader("Reporting-Endpoints")}} - Required for setting up reporting endpoints
    • Reporting API - The underlying API used for COOP reports
  • Real-world usage: The report-to parameter and Cross-Origin-Opener-Policy-Report-Only header are already in use in production codebases (e.g., for monitoring policy violations before enforcement)

Related issues and pull requests

Relates to #39880
Fixes #39432

@github-actions github-actions bot added Content:HTTP HTTP docs size/m [PR only] 51-500 LoC changed labels Nov 21, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

mdn-linter

[mdn-linter] reported by reviewdog 🐶


[mdn-linter] reported by reviewdog 🐶

- **`Cross-Origin-Opener-Policy`**: Enforces the policy and controls browsing context group behavior.


[mdn-linter] reported by reviewdog 🐶

- `Cross-Origin-Opener-Policy` controls the actual behavior


[mdn-linter] reported by reviewdog 🐶

- The actual policy is `unsafe-none` (permissive)

The behavior depends on the policies of both the new document and its opener, and whether the new document is opened following a navigation or using {{domxref("Window.open()")}}.

There are two variants of this header:
- **`Cross-Origin-Opener-Policy`**: Enforces the policy and controls browsing context group behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
- **`Cross-Origin-Opener-Policy`**: Enforces the policy and controls browsing context group behavior.
- **`Cross-Origin-Opener-Policy`**: Enforces the policy and controls browsing context group behavior.

The `Cross-Origin-Opener-Policy-Report-Only` header monitors the policy without enforcing it. When a browsing context group switch would occur that violates the policy specified in `Cross-Origin-Opener-Policy-Report-Only`, the browser sends a report to the specified endpoint (if `report-to` is provided) but still allows the navigation or window opening to proceed according to the actual policy enforcement.

Both headers can be present simultaneously:
- `Cross-Origin-Opener-Policy` controls the actual behavior
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
- `Cross-Origin-Opener-Policy` controls the actual behavior
- `Cross-Origin-Opener-Policy` controls the actual behavior

```

In this example:
- The actual policy is `unsafe-none` (permissive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
- The actual policy is `unsafe-none` (permissive)
- The actual policy is `unsafe-none` (permissive)

@wbamberg
Copy link
Collaborator

wbamberg commented Nov 21, 2025

Thanks for your PR! I know it's still in draft, but a couple of quick comments that might be helpful.

  • if you have an editor that can install extensions, and you install the markdownlint and prettier extensions to make them auto-format on save (or just install the tools and run them manually before you commit) then you'll avoid a lot of these [mdn-linter] comments in the PR.
  • since Cross-Origin-Opener-Policy and Cross-Origin-Opener-Policy-Report-Only are two different headers, they need two different pages. See for example Content-Security-Policy and Content-Security-Policy-Report-Only.

@Josh-Cena
Copy link
Member

Also this in its proper form will fix #39432

@hamishwillee
Copy link
Collaborator

See also #39880 where I made a good start on this. I've been stalled for a while on #39880 (comment)

Usually violations that do reporting use the reporting API https://developer.mozilla.org/en-US/docs/Web/API/Reporting_API which has both a JavaScript side and an HTTP endpoint side. Normally you document the report format methodically in the reporting API part and then reference it from the HTTP header side.
This was the first case I ran into where reporting only had HTTP reporting defined, and it wasn't and still isn't clear if the API part exists

Given response time/bandwidth probably worth documenting this HTTP side much as you have done and and we can add the reporting API and "fix this up" later.

@steve-a-walsh
Copy link
Author

Thanks for your PR! I know it's still in draft, but a couple of quick comments that might be helpful.

  • if you have an editor that can install extensions, and you install the markdownlint and prettier extensions to make them auto-format on save (or just install the tools and run them manually before you commit) then you'll avoid a lot of these [mdn-linter] comments in the PR.
  • since Cross-Origin-Opener-Policy and Cross-Origin-Opener-Policy-Report-Only are two different headers, they need two different pages. See for example Content-Security-Policy and Content-Security-Policy-Report-Only.

Thanks for the advice. I will make this adjustment based on how the CSP and CSP-RO pages relate to one-another. Sorry for the delays given the Thanksgiving holiday.

@steve-a-walsh
Copy link
Author

See also #39880 where I made a good start on this. I've been stalled for a while on #39880 (comment)

Usually violations that do reporting use the reporting API https://developer.mozilla.org/en-US/docs/Web/API/Reporting_API which has both a JavaScript side and an HTTP endpoint side. Normally you document the report format methodically in the reporting API part and then reference it from the HTTP header side. This was the first case I ran into where reporting only had HTTP reporting defined, and it wasn't and still isn't clear if the API part exists

Given response time/bandwidth probably worth documenting this HTTP side much as you have done and and we can add the reporting API and "fix this up" later.

This is great, thanks! It would be beneficial to incrementally improve the docs here so at least more/better documentation is available to the developing public.

@hamishwillee hamishwillee mentioned this pull request Jan 6, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:HTTP HTTP docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document Cross-Origin-Opener-Policy-Report-Only HTTP header

4 participants