diff --git a/crates/web-sys/tests/all/main.rs b/crates/web-sys/tests/all/main.rs index 577a7f303..3e8e39f84 100644 --- a/crates/web-sys/tests/all/main.rs +++ b/crates/web-sys/tests/all/main.rs @@ -2,3 +2,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder; use project_builder::project; mod event; +mod response; diff --git a/crates/web-sys/tests/all/response.rs b/crates/web-sys/tests/all/response.rs new file mode 100644 index 000000000..81fdf4cb7 --- /dev/null +++ b/crates/web-sys/tests/all/response.rs @@ -0,0 +1,37 @@ +use super::project; + +#[test] +fn response() { + project() + .add_local_dependency("web-sys", env!("CARGO_MANIFEST_DIR")) + .headless(true) + .file( + "src/lib.rs", + r#" + #![feature(proc_macro, wasm_custom_section)] + extern crate wasm_bindgen; + use wasm_bindgen::prelude::*; + extern crate web_sys; + + #[wasm_bindgen] + pub fn test_response(response: &web_sys::Response) { + assert!(!response.ok()); + assert!(!response.redirected()); + assert_eq!(response.status(), 501); + } + "#, + ) + .file( + "test.js", + r#" + import * as assert from "assert"; + import * as wasm from "./out"; + + export function test() { + let response = new Response(null, {status: 501}); + wasm.test_response(response); + } + "#, + ) + .test(); +} diff --git a/crates/web-sys/webidls/available/Response.webidl b/crates/web-sys/webidls/enabled/Response.webidl similarity index 100% rename from crates/web-sys/webidls/available/Response.webidl rename to crates/web-sys/webidls/enabled/Response.webidl