ReportingObserver Class

Observes the reports generated by a document or a worker (https://w3c.github.io/reporting/#reportingobserver), e.g. the violations of its content security policies that have a report-to directive. Its callback is invoked from a task with the reports queued since the previous call.

public sealed class ReportingObserver

Constructors

NameDescription
ReportingObserver(GlobalScope, ReportingObserverCallback, ReportingObserverOptions?)Creates an observer of the reports of a global object.
ReportingObserver(ReportingObserverCallback, ReportingObserverOptions?)Creates an observer of the reports of the current global object (https://w3c.github.io/reporting/#dom-reportingobserver-reportingobserver).

ReportingObserver overloads

ReportingObserver(GlobalScope, ReportingObserverCallback, ReportingObserverOptions?)

ReportingObserver.cs

Creates an observer of the reports of a global object.

public ReportingObserver(GlobalScope global, ReportingObserverCallback callback, ReportingObserverOptions? options = null)
Parameters
global GlobalScope
The window or the worker whose reports are observed.
callback ReportingObserverCallback
The callback invoked with the observed reports.
options ReportingObserverOptions?
The observed types, and whether the reports generated before are observed.

ReportingObserver(ReportingObserverCallback, ReportingObserverOptions?)

ReportingObserver.cs

Creates an observer of the reports of the current global object (https://w3c.github.io/reporting/#dom-reportingobserver-reportingobserver).

public ReportingObserver(ReportingObserverCallback callback, ReportingObserverOptions? options = null)
Parameters
callback ReportingObserverCallback
The callback invoked with the observed reports.
options ReportingObserverOptions?
The observed types, and whether the reports generated before are observed.
See also

Methods

NameDescription
Disconnect()Stops observing the reports (https://w3c.github.io/reporting/#dom-reportingobserver-disconnect). The reports already queued are still delivered by the queued task.
Observe()Starts observing the reports of the global object (https://w3c.github.io/reporting/#dom-reportingobserver-observe): with the buffered option, the reports of the report buffer are delivered too (once).
TakeRecords()Returns the reports of the report queue and empties it (https://w3c.github.io/reporting/#dom-reportingobserver-takerecords).

Stops observing the reports (https://w3c.github.io/reporting/#dom-reportingobserver-disconnect). The reports already queued are still delivered by the queued task.

public void Disconnect()

Starts observing the reports of the global object (https://w3c.github.io/reporting/#dom-reportingobserver-observe): with the buffered option, the reports of the report buffer are delivered too (once).

public void Observe()

Returns the reports of the report queue and empties it (https://w3c.github.io/reporting/#dom-reportingobserver-takerecords).

public IReadOnlyList<Report> TakeRecords()