Reporting.webidl (3730B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://w3c.github.io/reporting/#interface-reporting-observer 8 */ 9 10 interface nsISupports; 11 12 [Pref="dom.reporting.enabled", 13 Exposed=(Window,Worker)] 14 interface ReportBody { 15 [Default] object toJSON 16 (); 17 }; 18 19 [Pref="dom.reporting.enabled", 20 Exposed=(Window,Worker)] 21 interface Report { 22 [Default] object toJSON 23 (); 24 readonly attribute DOMString type; 25 readonly attribute DOMString url; 26 readonly attribute ReportBody? body; 27 }; 28 29 [Pref="dom.reporting.enabled", 30 Exposed=(Window,Worker)] 31 interface ReportingObserver { 32 [Throws] 33 constructor(ReportingObserverCallback callback, optional ReportingObserverOptions options = {}); 34 undefined observe(); 35 undefined disconnect(); 36 ReportList takeRecords(); 37 }; 38 39 callback ReportingObserverCallback = undefined (sequence<Report> reports, ReportingObserver observer); 40 41 dictionary ReportingObserverOptions { 42 sequence<DOMString> types; 43 boolean buffered = false; 44 }; 45 46 typedef sequence<Report> ReportList; 47 48 [Pref="dom.reporting.enabled", 49 Exposed=Window] 50 interface DeprecationReportBody : ReportBody { 51 [Default] object toJSON(); 52 53 readonly attribute DOMString id; 54 readonly attribute object? anticipatedRemoval; 55 readonly attribute DOMString message; 56 readonly attribute UTF8String? sourceFile; 57 readonly attribute unsigned long? lineNumber; 58 readonly attribute unsigned long? columnNumber; 59 }; 60 61 [Deprecated="DeprecatedTestingInterface", 62 Pref="dom.reporting.testing.enabled", 63 Exposed=(Window,DedicatedWorker)] 64 interface TestingDeprecatedInterface { 65 constructor(); 66 67 [Deprecated="DeprecatedTestingMethod"] 68 undefined deprecatedMethod(); 69 70 [Deprecated="DeprecatedTestingAttribute"] 71 readonly attribute boolean deprecatedAttribute; 72 }; 73 74 [Exposed=Window, Pref="dom.reporting.enabled"] 75 interface CSPViolationReportBody : ReportBody { 76 [Default] object toJSON(); 77 readonly attribute USVString documentURL; 78 readonly attribute USVString? referrer; 79 readonly attribute USVString? blockedURL; 80 readonly attribute DOMString effectiveDirective; 81 readonly attribute DOMString originalPolicy; 82 readonly attribute UTF8String? sourceFile; 83 readonly attribute DOMString? sample; 84 readonly attribute SecurityPolicyViolationEventDisposition disposition; 85 readonly attribute unsigned short statusCode; 86 readonly attribute unsigned long? lineNumber; 87 readonly attribute unsigned long? columnNumber; 88 }; 89 90 // Used internally to process the JSON 91 [GenerateInit] 92 dictionary ReportingHeaderValue { 93 sequence<ReportingItem> items; 94 }; 95 96 // Used internally to process the JSON 97 dictionary ReportingItem { 98 // This is a long. 99 any max_age; 100 // This is a sequence of ReportingEndpoint. 101 any endpoints; 102 // This is a string. If missing, the value is 'default'. 103 any group; 104 boolean include_subdomains = false; 105 }; 106 107 // Used internally to process the JSON 108 [GenerateInit] 109 dictionary ReportingEndpoint { 110 // This is a string. 111 any url; 112 // This is an unsigned long. 113 any priority; 114 // This is an unsigned long. 115 any weight; 116 }; 117 118 dictionary GenerateTestReportParameters 119 { 120 required DOMString message; 121 DOMString group = "default"; 122 }; 123 124 [ChromeOnly, Pref="dom.reporting.enabled", Exposed=Window] 125 namespace TestReportGenerator { 126 [Throws] 127 Promise<undefined> generateReport(GenerateTestReportParameters params); 128 }; 129 130 [LegacyNoInterfaceObject, Exposed=Window] 131 interface TestReportBody : ReportBody { 132 [Default] object toJSON(); 133 readonly attribute DOMString message; 134 };