|
10 | 10 | //!
|
11 | 11 | //! @see https://github.com/rustwasm/wasm-bindgen/issues/1005
|
12 | 12 |
|
13 |
| -use wasm_bindgen::prelude::*; |
14 | 13 | use web_sys::{WebGl2RenderingContext, WebGlRenderingContext, WebSocket};
|
15 |
| -use wasm_bindgen_test::*; |
| 14 | +use wasm_bindgen::{JsValue, JsCast}; |
16 | 15 |
|
17 |
| -wasm_bindgen_test_configure!(run_in_browser); |
18 |
| - |
19 |
| -#[wasm_bindgen(module = "/tests/wasm/element.js")] |
20 |
| -extern "C" { |
21 |
| - fn new_webgl_rendering_context() -> WebGlRenderingContext; |
22 |
| - fn new_webgl2_rendering_context() -> WebGl2RenderingContext; |
23 |
| - fn new_websocket() -> WebSocket; |
24 |
| -// TODO: Add a function to create another type to test here. |
25 |
| -// These functions come from element.js |
26 |
| -} |
27 |
| - |
28 |
| -// Ensure that our whitelisted WebGlRenderingContext methods work |
29 |
| -// GECKODRIVER=geckodriver cargo test -p web-sys --target wasm32-unknown-unknown --all-features test_webgl_rendering_context_immutable_slices |
30 |
| -#[wasm_bindgen_test] |
| 16 | +// Ensure that our whitelisted WebGlRenderingContext methods compile with immutable slices. |
31 | 17 | fn test_webgl_rendering_context_immutable_slices() {
|
32 |
| - let gl = new_webgl_rendering_context(); |
| 18 | + let gl: WebGlRenderingContext = JsValue::null().unchecked_into().unwrap(); |
33 | 19 |
|
34 |
| - gl.vertex_attrib1fv_with_f32_array(0, &[1.]); |
35 |
| - gl.vertex_attrib2fv_with_f32_array(0, &[1.]); |
36 |
| - gl.vertex_attrib3fv_with_f32_array(0, &[1.]); |
37 |
| - gl.vertex_attrib4fv_with_f32_array(0, &[1.]); |
| 20 | + gl.vertex_attrib1fv_with_f32_array(0, &[1.]); |
| 21 | + gl.vertex_attrib2fv_with_f32_array(0, &[1.]); |
| 22 | + gl.vertex_attrib3fv_with_f32_array(0, &[1.]); |
| 23 | + gl.vertex_attrib4fv_with_f32_array(0, &[1.]); |
38 | 24 |
|
39 |
| - gl.uniform1fv_with_f32_array(None, &[1.]); |
40 |
| - gl.uniform2fv_with_f32_array(None, &[1.]); |
41 |
| - gl.uniform3fv_with_f32_array(None, &[1.]); |
42 |
| - gl.uniform4fv_with_f32_array(None, &[1.]); |
| 25 | + gl.uniform1fv_with_f32_array(None, &[1.]); |
| 26 | + gl.uniform2fv_with_f32_array(None, &[1.]); |
| 27 | + gl.uniform3fv_with_f32_array(None, &[1.]); |
| 28 | + gl.uniform4fv_with_f32_array(None, &[1.]); |
43 | 29 |
|
44 |
| - gl.uniform_matrix2fv_with_f32_array(None, false, &[1.]); |
45 |
| - gl.uniform_matrix3fv_with_f32_array(None, false, &[1.]); |
46 |
| - gl.uniform_matrix4fv_with_f32_array(None, false, &[1.]); |
| 30 | + gl.uniform_matrix2fv_with_f32_array(None, false, &[1.]); |
| 31 | + gl.uniform_matrix3fv_with_f32_array(None, false, &[1.]); |
| 32 | + gl.uniform_matrix4fv_with_f32_array(None, false, &[1.]); |
47 | 33 |
|
48 |
| - gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_u8_array( |
49 |
| - 0, |
50 |
| - 0, |
51 |
| - 0, |
52 |
| - 0, |
53 |
| - 0, |
54 |
| - 0, |
55 |
| - 0, |
56 |
| - 0, |
57 |
| - Some(&[1]), |
58 |
| - ); |
59 |
| - gl.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_u8_array( |
60 |
| - 0, |
61 |
| - 0, |
62 |
| - 0, |
63 |
| - 0, |
64 |
| - 0, |
65 |
| - 0, |
66 |
| - 0, |
67 |
| - 0, |
68 |
| - Some(&[1]), |
69 |
| - ); |
70 |
| - gl.compressed_tex_image_2d_with_u8_array(0, 0, 0, 0, 0, 0, &[1]); |
| 34 | + gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_u8_array( |
| 35 | + 0, |
| 36 | + 0, |
| 37 | + 0, |
| 38 | + 0, |
| 39 | + 0, |
| 40 | + 0, |
| 41 | + 0, |
| 42 | + 0, |
| 43 | + Some(&[1]), |
| 44 | + ); |
| 45 | + gl.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_u8_array( |
| 46 | + 0, |
| 47 | + 0, |
| 48 | + 0, |
| 49 | + 0, |
| 50 | + 0, |
| 51 | + 0, |
| 52 | + 0, |
| 53 | + 0, |
| 54 | + Some(&[1]), |
| 55 | + ); |
| 56 | + gl.compressed_tex_image_2d_with_u8_array(0, 0, 0, 0, 0, 0, &[1]); |
71 | 57 | }
|
72 | 58 |
|
73 |
| -// GECKODRIVER=geckodriver cargo test -p web-sys --target wasm32-unknown-unknown --all-features test_webgl2_rendering_context_immutable_slices |
74 |
| -#[wasm_bindgen_test] |
| 59 | +// Ensure that our whitelisted WebGl2RenderingContext methods compile with immutable slices. |
75 | 60 | fn test_webgl2_rendering_context_immutable_slices() {
|
76 |
| - let gl = new_webgl2_rendering_context(); |
| 61 | + let gl: WebGl2RenderingContext = JsValue::null().unchecked_into().unwrap(); |
77 | 62 |
|
78 | 63 | gl.tex_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
|
79 | 64 | gl.tex_sub_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
|
80 | 65 | gl.compressed_tex_image_3d_with_u8_array(0, 0, 0, 0, 0, 0, 0, &[1]);
|
81 | 66 | }
|
82 | 67 |
|
83 |
| -// GECKODRIVER=geckodriver cargo test -p web-sys --target wasm32-unknown-unknown --all-features test_websocket_immutable_slices |
84 |
| -#[wasm_bindgen_test] |
| 68 | +// Ensure that our whitelisted WebSocket methods compile with immutable slices. |
85 | 69 | fn test_websocket_immutable_slices() {
|
86 |
| - let ws = new_websocket(); |
| 70 | + let ws: WebSocket = JsValue::null().unchecked_into().unwrap(); |
87 | 71 | ws.send_with_u8_array(&[0]);
|
88 | 72 | }
|
89 | 73 |
|
|
0 commit comments