network-event.js (5286B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 Arg, 9 Option, 10 RetVal, 11 generateActorSpec, 12 types, 13 } = require("resource://devtools/shared/protocol.js"); 14 15 types.addDictType("netevent.headers-cookies", { 16 name: "string", 17 value: "longstring", 18 }); 19 20 types.addDictType("netevent.headers", { 21 headers: "array:netevent.headers-cookies", 22 headersSize: "number", 23 rawHeaders: "nullable:longstring", 24 }); 25 26 types.addDictType("netevent.cookies", { 27 cookies: "array:netevent.headers-cookies", 28 }); 29 30 types.addDictType("netevent.postdata.text", { 31 text: "longstring", 32 }); 33 34 types.addDictType("netevent.postdata", { 35 postData: "netevent.postdata.text", 36 postDataDiscarded: "boolean", 37 }); 38 39 types.addDictType("netevent.cache", { 40 content: "json", 41 }); 42 43 types.addDictType("netevent.content.content", { 44 text: "longstring", 45 }); 46 47 types.addDictType("netevent.content", { 48 content: "netevent.content.content", 49 contentDiscarded: "boolean", 50 }); 51 52 types.addDictType("netevent.timings.data", { 53 blocked: "number", 54 dns: "number", 55 ssl: "number", 56 connect: "number", 57 send: "number", 58 wait: "number", 59 receive: "number", 60 }); 61 62 types.addDictType("netevent.timings", { 63 timings: "netevent.timings.data", 64 totalTime: "number", 65 offsets: "netevent.timings.data", 66 serverTimings: "array:netevent.timings.serverTiming", 67 }); 68 69 types.addDictType("netevent.timings.serverTiming", { 70 name: "string", 71 description: "string", 72 duration: "number", 73 }); 74 75 // See NetworkHelper.parseCertificateInfo for more details 76 types.addDictType("netevent.cert", { 77 subject: "json", 78 issuer: "json", 79 validity: "json", 80 fingerprint: "json", 81 }); 82 83 types.addDictType("netevent.secinfo", { 84 state: "string", 85 weaknessReasons: "array:string", 86 cipherSuite: "string", 87 keaGroupName: "string", 88 signatureSchemeName: "string", 89 protocolVersion: "string", 90 cert: "nullable:netevent.cert", 91 certificateTransparency: "number", 92 hsts: "boolean", 93 hpkp: "boolean", 94 errorMessage: "nullable:string", 95 usedEch: "boolean", 96 usedDelegatedCredentials: "boolean", 97 usedOcsp: "boolean", 98 usedPrivateDns: "boolean", 99 }); 100 101 const networkEventSpec = generateActorSpec({ 102 typeName: "netEvent", 103 104 events: { 105 // All these events end up emitting a `networkEventUpdate` RDP message 106 // `updateType` attribute allows to identify which kind of event is emitted. 107 // We use individual event at protocol.js level to workaround performance issue 108 // with `Option` types. (See bug 1449162) 109 "network-event-update:headers": { 110 type: "networkEventUpdate", 111 updateType: Arg(0, "string"), 112 113 headers: Option(1, "number"), 114 headersSize: Option(1, "number"), 115 }, 116 117 "network-event-update:cookies": { 118 type: "networkEventUpdate", 119 updateType: Arg(0, "string"), 120 121 cookies: Option(1, "number"), 122 }, 123 124 "network-event-update:post-data": { 125 type: "networkEventUpdate", 126 updateType: Arg(0, "string"), 127 128 dataSize: Option(1, "number"), 129 }, 130 131 "network-event-update:response-start": { 132 type: "networkEventUpdate", 133 updateType: Arg(0, "string"), 134 135 response: Option(1, "json"), 136 }, 137 138 "network-event-update:security-info": { 139 type: "networkEventUpdate", 140 updateType: Arg(0, "string"), 141 142 state: Option(1, "string"), 143 isRacing: Option(1, "boolean"), 144 }, 145 146 "network-event-update:response-content": { 147 type: "networkEventUpdate", 148 updateType: Arg(0, "string"), 149 150 mimeType: Option(1, "string"), 151 contentSize: Option(1, "number"), 152 encoding: Option(1, "string"), 153 transferredSize: Option(1, "number"), 154 blockedReason: Option(1, "number"), 155 extension: Option(1, "json"), 156 }, 157 158 "network-event-update:event-timings": { 159 type: "networkEventUpdate", 160 updateType: Arg(0, "string"), 161 162 totalTime: Option(1, "number"), 163 }, 164 165 "network-event-update:response-cache": { 166 type: "networkEventUpdate", 167 updateType: Arg(0, "string"), 168 }, 169 }, 170 171 methods: { 172 release: { 173 // This makes protocol.js call destroy method 174 release: true, 175 }, 176 getRequestHeaders: { 177 request: {}, 178 response: RetVal("json"), 179 }, 180 getRequestCookies: { 181 request: {}, 182 response: RetVal("json"), 183 }, 184 getRequestPostData: { 185 request: {}, 186 response: RetVal("json"), 187 }, 188 getEarlyHintsResponseHeaders: { 189 request: {}, 190 response: RetVal("json"), 191 }, 192 getResponseHeaders: { 193 request: {}, 194 response: RetVal("json"), 195 }, 196 getResponseCookies: { 197 request: {}, 198 response: RetVal("json"), 199 }, 200 getResponseCache: { 201 request: {}, 202 response: RetVal("json"), 203 }, 204 getResponseContent: { 205 request: {}, 206 response: RetVal("json"), 207 }, 208 getEventTimings: { 209 request: {}, 210 response: RetVal("json"), 211 }, 212 getSecurityInfo: { 213 request: {}, 214 response: RetVal("json"), 215 }, 216 getStackTrace: { 217 request: {}, 218 // stacktrace is an "array:string", but not always. 219 response: RetVal("json"), 220 }, 221 }, 222 }); 223 224 exports.networkEventSpec = networkEventSpec;