|
3 | 3 | const{ |
4 | 4 | Error, |
5 | 5 | ErrorPrototype, |
| 6 | + NumberIsFinite, |
| 7 | + NumberIsNaN, |
6 | 8 | ObjectDefineProperties, |
7 | 9 | ObjectDefineProperty, |
8 | 10 | ObjectSetPrototypeOf, |
| 11 | + RangeError, |
9 | 12 | SafeMap, |
10 | 13 | SafeSet, |
11 | 14 | SafeWeakMap, |
@@ -203,3 +206,91 @@ for (const { 0: name, 1: codeName, 2: value } of [ |
203 | 206 | } |
204 | 207 |
|
205 | 208 | exports.DOMException=DOMException; |
| 209 | + |
| 210 | +// https://webidl.spec.whatwg.org/#quotaexceedederror |
| 211 | +classQuotaExceededErrorextendsDOMException{ |
| 212 | + #quota; |
| 213 | + #requested; |
| 214 | + |
| 215 | +constructor(message='',options={__proto__: null}){ |
| 216 | +super(message,'QuotaExceededError'); |
| 217 | +this[transfer_mode_private_symbol]=kCloneable; |
| 218 | + |
| 219 | +letquota=null; |
| 220 | +letrequested=null; |
| 221 | + |
| 222 | +if(options!==null&&options!==undefined){ |
| 223 | +if('quota'inoptions){ |
| 224 | +quota=+options.quota; |
| 225 | +if(!NumberIsFinite(quota)){ |
| 226 | +// eslint-disable-next-line no-restricted-syntax |
| 227 | +thrownewTypeError( |
| 228 | +`Cannot convert options.quota to a double: the value is ${NumberIsNaN(quota) ? 'NaN' : 'Infinity'}`, |
| 229 | +); |
| 230 | +} |
| 231 | +if(quota<0){ |
| 232 | +// eslint-disable-next-line no-restricted-syntax |
| 233 | +thrownewRangeError('options.quota must not be negative'); |
| 234 | +} |
| 235 | +} |
| 236 | + |
| 237 | +if('requested'inoptions){ |
| 238 | +requested=+options.requested; |
| 239 | +if(!NumberIsFinite(requested)){ |
| 240 | +// eslint-disable-next-line no-restricted-syntax |
| 241 | +thrownewTypeError( |
| 242 | +`Cannot convert options.requested to a double: the value is ${NumberIsNaN(requested) ? 'NaN' : 'Infinity'}`, |
| 243 | +); |
| 244 | +} |
| 245 | +if(requested<0){ |
| 246 | +// eslint-disable-next-line no-restricted-syntax |
| 247 | +thrownewRangeError('options.requested must not be negative'); |
| 248 | +} |
| 249 | +} |
| 250 | +} |
| 251 | + |
| 252 | +if(quota!==null&&requested!==null&&requested<quota){ |
| 253 | +// eslint-disable-next-line no-restricted-syntax |
| 254 | +thrownewRangeError('options.requested must not be less than options.quota'); |
| 255 | +} |
| 256 | + |
| 257 | +this.#quota =quota; |
| 258 | +this.#requested =requested; |
| 259 | +} |
| 260 | + |
| 261 | +[messaging_clone_symbol](){ |
| 262 | +constdomExceptionClone=DOMExceptionPrototype[messaging_clone_symbol].call(this); |
| 263 | +domExceptionClone.data.quota=this.#quota; |
| 264 | +domExceptionClone.data.requested=this.#requested; |
| 265 | +domExceptionClone.deserializeInfo='internal/worker/clone_dom_exception:QuotaExceededError'; |
| 266 | +returndomExceptionClone; |
| 267 | +} |
| 268 | + |
| 269 | +[messaging_deserialize_symbol](data){ |
| 270 | +DOMExceptionPrototype[messaging_deserialize_symbol].call(this,data); |
| 271 | +this.#quota =data.quota; |
| 272 | +this.#requested =data.requested; |
| 273 | +} |
| 274 | + |
| 275 | +getquota(){ |
| 276 | +if(!(#quota inthis)){ |
| 277 | +throwInvalidThisError(TypeError,'QuotaExceededError'); |
| 278 | +} |
| 279 | +returnthis.#quota; |
| 280 | +} |
| 281 | + |
| 282 | +getrequested(){ |
| 283 | +if(!(#requested inthis)){ |
| 284 | +throwInvalidThisError(TypeError,'QuotaExceededError'); |
| 285 | +} |
| 286 | +returnthis.#requested; |
| 287 | +} |
| 288 | +} |
| 289 | + |
| 290 | +ObjectDefineProperties(QuotaExceededError.prototype,{ |
| 291 | +[SymbolToStringTag]: {__proto__: null,configurable: true,value: 'QuotaExceededError'}, |
| 292 | +quota: {__proto__: null,enumerable: true,configurable: true}, |
| 293 | +requested: {__proto__: null,enumerable: true,configurable: true}, |
| 294 | +}); |
| 295 | + |
| 296 | +exports.QuotaExceededError=QuotaExceededError; |
0 commit comments