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, such as embedding a child resource or loading a dedicated worker.

Value

A string that can have one of the following values:

The violation was caused by an <iframe> or other child browsing context attempting to load a new document.

"worker initialization"

The violation was caused by a page attempting to load a dedicated worker.

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

No specification found

No specification data found for api.COEPViolationReportBody.type.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility