mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-26 06:51:07 +00:00
This information is embedded within the algorithm for constructing interfaces and their prototypes in the section for ECMAScript glue in the WebIDL spec... This really *should* make the `wasm_bindgen_backend::ast::ImportType::extends` member from a `Vec<Ident>` into a `Vec<syn::Path>` so that we could use `js_sys::Object` in the extends field, but that is a huge pain because then the `ImportedTypes` trait needs to be changed, and all of its implementers, etc...
35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use futures::future::Future;
|
|
use js_sys::{Object, Promise};
|
|
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen::JsCast;
|
|
use wasm_bindgen_futures::JsFuture;
|
|
use wasm_bindgen_test::*;
|
|
use web_sys::Event;
|
|
|
|
#[wasm_bindgen(module = "./tests/wasm/event.js")]
|
|
extern {
|
|
fn new_event() -> Promise;
|
|
}
|
|
|
|
#[wasm_bindgen_test(async)]
|
|
fn event() -> impl Future<Item = (), Error = JsValue> {
|
|
JsFuture::from(new_event())
|
|
.map(Event::from)
|
|
.map(|event| {
|
|
// All DOM interfaces should inherit from `Object`.
|
|
assert!(event.is_instance_of::<Object>());
|
|
let _: &Object = event.as_ref();
|
|
|
|
// These should match `new Event`.
|
|
assert!(event.bubbles());
|
|
assert!(event.cancelable());
|
|
assert!(event.composed());
|
|
|
|
// The default behavior not initially prevented, but after
|
|
// we call `prevent_default` it better be.
|
|
assert!(!event.default_prevented());
|
|
event.prevent_default();
|
|
assert!(event.default_prevented());
|
|
})
|
|
}
|