@@ -4,6 +4,7 @@ use crate::avm1::activation::Activation;
4
4
use crate :: avm1:: error:: Error ;
5
5
use crate :: avm1:: function:: ExecutionReason ;
6
6
use crate :: avm1:: object:: xml_object:: XmlObject ;
7
+ use crate :: avm1:: property:: Attribute ;
7
8
use crate :: avm1:: property_decl:: { define_properties_on, Declaration } ;
8
9
use crate :: avm1:: { Object , TObject , Value } ;
9
10
use crate :: avm_warn;
@@ -21,6 +22,8 @@ const PROTO_DECLS: &[Declaration] = declare_properties! {
21
22
"status" => property( status) ;
22
23
"createElement" => method( create_element) ;
23
24
"createTextNode" => method( create_text_node) ;
25
+ "getBytesLoaded" => method( get_bytes_loaded) ;
26
+ "getBytesTotal" => method( get_bytes_total) ;
24
27
"parseXML" => method( parse_xml) ;
25
28
"load" => method( load) ;
26
29
"sendAndLoad" => method( send_and_load) ;
@@ -85,6 +88,24 @@ fn create_text_node<'gc>(
85
88
Ok ( Value :: Undefined )
86
89
}
87
90
91
+ fn get_bytes_loaded < ' gc > (
92
+ activation : & mut Activation < ' _ , ' gc > ,
93
+ this : Object < ' gc > ,
94
+ _args : & [ Value < ' gc > ] ,
95
+ ) -> Result < Value < ' gc > , Error < ' gc > > {
96
+ // Forwards to undocumented property on the object.
97
+ this. get ( "_bytesLoaded" , activation)
98
+ }
99
+
100
+ fn get_bytes_total < ' gc > (
101
+ activation : & mut Activation < ' _ , ' gc > ,
102
+ this : Object < ' gc > ,
103
+ _args : & [ Value < ' gc > ] ,
104
+ ) -> Result < Value < ' gc > , Error < ' gc > > {
105
+ // Forwards to undocumented property on the object.
106
+ this. get ( "_bytesTotal" , activation)
107
+ }
108
+
88
109
fn parse_xml < ' gc > (
89
110
activation : & mut Activation < ' _ , ' gc > ,
90
111
this : Object < ' gc > ,
@@ -272,7 +293,39 @@ fn spawn_xml_fetch<'gc>(
272
293
Request :: get ( url)
273
294
} ;
274
295
275
- this. set ( "loaded" , false . into ( ) , activation) ?;
296
+ // Create hidden properties on object.
297
+ if !this. has_property ( activation, "_bytesLoaded" . into ( ) ) {
298
+ this. define_value (
299
+ activation. context . gc_context ,
300
+ "_bytesLoaded" ,
301
+ 0 . into ( ) ,
302
+ Attribute :: DONT_DELETE | Attribute :: DONT_ENUM ,
303
+ ) ;
304
+ } else {
305
+ this. set ( "_bytesLoaded" , 0 . into ( ) , activation) ?;
306
+ }
307
+
308
+ if !this. has_property ( activation, "_bytesTotal" . into ( ) ) {
309
+ this. define_value (
310
+ activation. context . gc_context ,
311
+ "_bytesTotal" ,
312
+ Value :: Undefined ,
313
+ Attribute :: DONT_DELETE | Attribute :: DONT_ENUM ,
314
+ ) ;
315
+ } else {
316
+ this. set ( "_bytesTotal" , Value :: Undefined , activation) ?;
317
+ }
318
+
319
+ if !this. has_property ( activation, "loaded" . into ( ) ) {
320
+ this. define_value (
321
+ activation. context . gc_context ,
322
+ "loaded" ,
323
+ false . into ( ) ,
324
+ Attribute :: DONT_DELETE | Attribute :: DONT_ENUM ,
325
+ ) ;
326
+ } else {
327
+ this. set ( "loaded" , false . into ( ) , activation) ?;
328
+ }
276
329
277
330
let future = activation. context . load_manager . load_form_into_load_vars (
278
331
activation. context . player . clone ( ) ,
0 commit comments