COEPViolationReportBody: type property

Note: This feature is available in Web Workers.

The type read-only property of the COEPViolationReportBody dictionary returns a value that indicates the cause of the violation.

Note that

Value

A string that can have one of the following values:

"corp"

The violation was triggered by a document with Cross-Origin-Embedder-Policy set to require-corp attempting to load a cross-origin sub-resource that does not explicitly allow itself to be embedded (by setting an appropriate Cross-Origin-Resource-Policy).

An <iframe> in a document that has either COEP require-corp or credentialless directives loads a document that:

  • Has neither COEP require-corp or credentialless directive .
  • Is cross-origin with the embedding document, and does not have a CORP header that allows embedding in the parent.
"worker initialization"

A dedicated worker created by a document with either the COEP require-corp or credentialless directives tries to load a worker script with neither of these set.

Examples

Get the type of a COEP violation report

In this example we create a new ReportingObserver to observe COEP violation reports, then log the value of type to the console.

js
const options = {
  types: ["coep"],
  buffered: true,
};

const observer = new ReportingObserver((reports, observer) => {
  const firstReport = reports[0];
  console.log(firstReport.type); // coep
  console.log(firstReport.body.type); // navigation or worker initialization
}, options);

Specifications

Specification
HTML
# embedder-policy-checks
HTML
# coep

Browser compatibility