11cb0ef41Sopenharmony_ci'use strict' 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst { webidl } = require('../fetch/webidl') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst kState = Symbol('ProgressEvent state') 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci/** 81cb0ef41Sopenharmony_ci * @see https://xhr.spec.whatwg.org/#progressevent 91cb0ef41Sopenharmony_ci */ 101cb0ef41Sopenharmony_ciclass ProgressEvent extends Event { 111cb0ef41Sopenharmony_ci constructor (type, eventInitDict = {}) { 121cb0ef41Sopenharmony_ci type = webidl.converters.DOMString(type) 131cb0ef41Sopenharmony_ci eventInitDict = webidl.converters.ProgressEventInit(eventInitDict ?? {}) 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci super(type, eventInitDict) 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci this[kState] = { 181cb0ef41Sopenharmony_ci lengthComputable: eventInitDict.lengthComputable, 191cb0ef41Sopenharmony_ci loaded: eventInitDict.loaded, 201cb0ef41Sopenharmony_ci total: eventInitDict.total 211cb0ef41Sopenharmony_ci } 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci get lengthComputable () { 251cb0ef41Sopenharmony_ci webidl.brandCheck(this, ProgressEvent) 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci return this[kState].lengthComputable 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci get loaded () { 311cb0ef41Sopenharmony_ci webidl.brandCheck(this, ProgressEvent) 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci return this[kState].loaded 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci get total () { 371cb0ef41Sopenharmony_ci webidl.brandCheck(this, ProgressEvent) 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci return this[kState].total 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci} 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ciwebidl.converters.ProgressEventInit = webidl.dictionaryConverter([ 441cb0ef41Sopenharmony_ci { 451cb0ef41Sopenharmony_ci key: 'lengthComputable', 461cb0ef41Sopenharmony_ci converter: webidl.converters.boolean, 471cb0ef41Sopenharmony_ci defaultValue: false 481cb0ef41Sopenharmony_ci }, 491cb0ef41Sopenharmony_ci { 501cb0ef41Sopenharmony_ci key: 'loaded', 511cb0ef41Sopenharmony_ci converter: webidl.converters['unsigned long long'], 521cb0ef41Sopenharmony_ci defaultValue: 0 531cb0ef41Sopenharmony_ci }, 541cb0ef41Sopenharmony_ci { 551cb0ef41Sopenharmony_ci key: 'total', 561cb0ef41Sopenharmony_ci converter: webidl.converters['unsigned long long'], 571cb0ef41Sopenharmony_ci defaultValue: 0 581cb0ef41Sopenharmony_ci }, 591cb0ef41Sopenharmony_ci { 601cb0ef41Sopenharmony_ci key: 'bubbles', 611cb0ef41Sopenharmony_ci converter: webidl.converters.boolean, 621cb0ef41Sopenharmony_ci defaultValue: false 631cb0ef41Sopenharmony_ci }, 641cb0ef41Sopenharmony_ci { 651cb0ef41Sopenharmony_ci key: 'cancelable', 661cb0ef41Sopenharmony_ci converter: webidl.converters.boolean, 671cb0ef41Sopenharmony_ci defaultValue: false 681cb0ef41Sopenharmony_ci }, 691cb0ef41Sopenharmony_ci { 701cb0ef41Sopenharmony_ci key: 'composed', 711cb0ef41Sopenharmony_ci converter: webidl.converters.boolean, 721cb0ef41Sopenharmony_ci defaultValue: false 731cb0ef41Sopenharmony_ci } 741cb0ef41Sopenharmony_ci]) 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_cimodule.exports = { 771cb0ef41Sopenharmony_ci ProgressEvent 781cb0ef41Sopenharmony_ci} 79