@@ -13,6 +13,10 @@ extern "C" {
13
13
type DefinePropertyAttrs ;
14
14
#[ wasm_bindgen( method, setter, structural) ]
15
15
fn set_value ( this : & DefinePropertyAttrs , val : & JsValue ) ;
16
+
17
+ type PropertyDescriptor ;
18
+ #[ wasm_bindgen( method, getter, structural) ]
19
+ fn value ( this : & PropertyDescriptor ) -> JsValue ;
16
20
}
17
21
18
22
#[ wasm_bindgen( module = "tests/wasm/Object.js" ) ]
@@ -101,6 +105,23 @@ fn define_properties() {
101
105
assert ! ( foo. has_own_property( & "car" . into( ) ) ) ;
102
106
}
103
107
108
+ #[ wasm_bindgen_test]
109
+ fn get_own_property_descriptor ( ) {
110
+ let foo = foo_42 ( ) ;
111
+ let desc = Object :: get_own_property_descriptor ( & foo, & "foo" . into ( ) ) ;
112
+ assert_eq ! ( PropertyDescriptor :: from( desc) . value( ) , 42 ) ;
113
+ let desc = Object :: get_own_property_descriptor ( & foo, & "bar" . into ( ) ) ;
114
+ assert ! ( PropertyDescriptor :: from( desc) . value( ) . is_undefined( ) ) ;
115
+ }
116
+
117
+ #[ wasm_bindgen_test]
118
+ fn get_own_property_descriptors ( ) {
119
+ let foo = foo_42 ( ) ;
120
+ let descriptors = Object :: get_own_property_descriptors ( & foo) ;
121
+ let foo_desc = Reflect :: get ( & descriptors, & "foo" . into ( ) ) ;
122
+ assert_eq ! ( PropertyDescriptor :: from( foo_desc) . value( ) , 42 ) ;
123
+ }
124
+
104
125
#[ wasm_bindgen_test]
105
126
fn has_own_property ( ) {
106
127
assert ! ( foo_42( ) . has_own_property( & "foo" . into( ) ) ) ;
0 commit comments