js-sys: Add bindings to URIError

This commit is contained in:
Nick Fitzgerald 2018-08-10 13:37:34 -07:00
parent 4148d3b4ac
commit a58c2584b3
3 changed files with 34 additions and 0 deletions

View File

@ -2706,6 +2706,25 @@ extern "C" {
pub fn byte_offset(this: &Uint32Array) -> u32;
}
// URIError
#[wasm_bindgen]
extern {
/// The URIError object represents an error when a global URI handling
/// function was used in a wrong way.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
#[wasm_bindgen(extends = Error, js_name = URIError)]
#[derive(Clone, Debug)]
pub type UriError;
/// The URIError object represents an error when a global URI handling
/// function was used in a wrong way.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
#[wasm_bindgen(constructor, js_class = "URIError")]
pub fn new(message: &str) -> UriError;
}
// WeakMap
#[wasm_bindgen]
extern "C" {

View File

@ -0,0 +1,14 @@
use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use wasm_bindgen::JsCast;
use js_sys::*;
#[wasm_bindgen_test]
fn uri_error() {
let error = UriError::new("msg");
assert!(error.is_instance_of::<UriError>());
assert!(error.is_instance_of::<Error>());
let base: &Error = error.as_ref();
assert_eq!(JsValue::from(base.message()), "msg");
}

View File

@ -33,6 +33,7 @@ pub mod Set;
pub mod SetIterator;
pub mod Symbol;
pub mod TypedArray;
pub mod UriError;
pub mod WeakMap;
pub mod WeakSet;
pub mod WebAssembly;