diff --git a/crates/web-sys/tests/all/main.rs b/crates/web-sys/tests/all/main.rs index a2d3adb1f..5f1873b64 100644 --- a/crates/web-sys/tests/all/main.rs +++ b/crates/web-sys/tests/all/main.rs @@ -80,6 +80,7 @@ mod history; web_sys::HtmlMenuElement, web_sys::HtmlSlotElement, */ +mod xpath_result; fn websys_project() -> Project { project() diff --git a/crates/web-sys/tests/all/xpath_result.rs b/crates/web-sys/tests/all/xpath_result.rs new file mode 100644 index 000000000..0fb3b9b68 --- /dev/null +++ b/crates/web-sys/tests/all/xpath_result.rs @@ -0,0 +1,36 @@ +use super::websys_project; + +#[test] +fn xpath_result() { + websys_project() + .file( + "src/lib.rs", + r#" + #![feature(use_extern_macros)] + extern crate wasm_bindgen; + use wasm_bindgen::prelude::*; + extern crate web_sys; + + #[wasm_bindgen] + pub fn test_xpath_result(xpath_result: &web_sys::XPathResult) { + assert_eq!(xpath_result.result_type(), web_sys::XPathResult::UNORDERED_NODE_ITERATOR_TYPE); + assert_eq!(xpath_result.invalid_iterator_state(), false); + assert_eq!(xpath_result.iterate_next().unwrap().unwrap().text_content().unwrap(), "tomato"); + } + "#, + ) + .file( + "test.js", + r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + let xmlDoc = new DOMParser().parseFromString("tomato", "application/xml"); + let xpathResult = xmlDoc.evaluate("/root//value", xmlDoc, null, XPathResult.ANY_TYPE, null); + wasm.test_xpath_result(xpathResult); + } + "#, + ) + .test(); +} diff --git a/crates/web-sys/webidls/available/XPathResult.webidl b/crates/web-sys/webidls/enabled/XPathResult.webidl similarity index 100% rename from crates/web-sys/webidls/available/XPathResult.webidl rename to crates/web-sys/webidls/enabled/XPathResult.webidl