Skip to content

Commit 1097daa

Browse files
committed
Get slice tests running in CI
1 parent 6684987 commit 1097daa

File tree

2 files changed

+41
-72
lines changed

2 files changed

+41
-72
lines changed

crates/web-sys/tests/wasm/element.js

-15
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,6 @@ export function new_title() {
151151
return document.createElement("title");
152152
}
153153

154-
export function new_webgl_rendering_context() {
155-
const canvas = document.createElement('canvas');
156-
return canvas.getContext('webgl');
157-
}
158-
159-
export function new_webgl2_rendering_context() {
160-
const canvas = document.createElement('canvas');
161-
return canvas.getContext('webgl2');
162-
}
163-
164-
export function new_websocket () {
165-
const websocket = new WebSocket("");
166-
return websocket;
167-
}
168-
169154
export function new_xpath_result() {
170155
let xmlDoc = new DOMParser().parseFromString("<root><value>tomato</value></root>", "application/xml");
171156
let xpathResult = xmlDoc.evaluate("/root//value", xmlDoc, null, XPathResult.ANY_TYPE, null);

crates/web-sys/tests/wasm/whitelisted_immutable_slices.rs

+41-57
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,64 @@
1010
//!
1111
//! @see https://github.com/rustwasm/wasm-bindgen/issues/1005
1212
13-
use wasm_bindgen::prelude::*;
1413
use web_sys::{WebGl2RenderingContext, WebGlRenderingContext, WebSocket};
15-
use wasm_bindgen_test::*;
14+
use wasm_bindgen::{JsValue, JsCast};
1615

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.
3117
fn test_webgl_rendering_context_immutable_slices() {
32-
let gl = new_webgl_rendering_context();
18+
let gl: WebGlRenderingContext = JsValue::null().unchecked_into().unwrap();
3319

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.]);
3824

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.]);
4329

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.]);
4733

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]);
7157
}
7258

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.
7560
fn test_webgl2_rendering_context_immutable_slices() {
76-
let gl = new_webgl2_rendering_context();
61+
let gl: WebGl2RenderingContext = JsValue::null().unchecked_into().unwrap();
7762

7863
gl.tex_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
7964
gl.tex_sub_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
8065
gl.compressed_tex_image_3d_with_u8_array(0, 0, 0, 0, 0, 0, 0, &[1]);
8166
}
8267

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.
8569
fn test_websocket_immutable_slices() {
86-
let ws = new_websocket();
70+
let ws: WebSocket = JsValue::null().unchecked_into().unwrap();
8771
ws.send_with_u8_array(&[0]);
8872
}
8973

0 commit comments

Comments
 (0)