File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2866,6 +2866,20 @@ pub mod WebAssembly {
2866
2866
#[ wasm_bindgen( js_namespace = WebAssembly ) ]
2867
2867
pub fn compile ( buffer_source : & JsValue ) -> Promise ;
2868
2868
2869
+ /// The `WebAssembly.instantiate()` function allows you to compile and
2870
+ /// instantiate WebAssembly code.
2871
+ ///
2872
+ /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
2873
+ #[ wasm_bindgen( js_namespace = WebAssembly , js_name = instantiate) ]
2874
+ pub fn instantiate_buffer ( buffer : & [ u8 ] , imports : & Object ) -> Promise ;
2875
+
2876
+ /// The `WebAssembly.instantiate()` function allows you to compile and
2877
+ /// instantiate WebAssembly code.
2878
+ ///
2879
+ /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate)
2880
+ #[ wasm_bindgen( js_namespace = WebAssembly , js_name = instantiate) ]
2881
+ pub fn instantiate_module ( module : & Module , imports : & Object ) -> Promise ;
2882
+
2869
2883
/// The `WebAssembly.validate()` function validates a given typed
2870
2884
/// array of WebAssembly binary code, returning whether the bytes
2871
2885
/// form a valid wasm module (`true`) or not (`false`).
Original file line number Diff line number Diff line change @@ -172,6 +172,17 @@ fn webassembly_instance() {
172
172
assert ! ( Reflect :: has( exports. as_ref( ) , & "exported_func" . into( ) ) ) ;
173
173
}
174
174
175
+ #[ wasm_bindgen_test( async ) ]
176
+ fn instantiate_module ( ) -> impl Future < Item = ( ) , Error = JsValue > {
177
+ let module = WebAssembly :: Module :: new ( & get_valid_wasm ( ) ) . unwrap ( ) ;
178
+ let imports = get_imports ( ) ;
179
+ let p = WebAssembly :: instantiate_module ( & module, & imports) ;
180
+ JsFuture :: from ( p)
181
+ . map ( |inst| {
182
+ assert ! ( inst. is_instance_of:: <WebAssembly :: Instance >( ) ) ;
183
+ } )
184
+ }
185
+
175
186
#[ wasm_bindgen_test]
176
187
fn memory_works ( ) {
177
188
let obj = Object :: new ( ) ;
You can’t perform that action at this time.
0 commit comments