Make the slice argument of texImage2D and related functions immutable

This also adds immutable slice whitelisting for Uint8Array, ArrayBufferView, and BufferSource, and removes Uint8ArrayMut.
This commit is contained in:
Nathan Stoddard
2019-03-08 15:12:41 -08:00
parent 8db85dddde
commit 03fa00d201
6 changed files with 109 additions and 33 deletions

View File

@ -156,6 +156,11 @@ export function new_webgl_rendering_context() {
return canvas.getContext('webgl');
}
export function new_webgl2_rendering_context() {
const canvas = document.createElement('canvas');
return canvas.getContext('webgl2');
}
export function new_xpath_result() {
let xmlDoc = new DOMParser().parseFromString("<root><value>tomato</value></root>", "application/xml");
let xpathResult = xmlDoc.evaluate("/root//value", xmlDoc, null, XPathResult.ANY_TYPE, null);

View File

@ -12,11 +12,12 @@
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::WebGlRenderingContext;
use web_sys::{WebGlRenderingContext, WebGl2RenderingContext};
#[wasm_bindgen(module = "/tests/wasm/element.js")]
extern "C" {
fn new_webgl_rendering_context() -> WebGlRenderingContext;
fn new_webgl2_rendering_context() -> WebGl2RenderingContext;
// TODO: Add a function to create another type to test here.
// These functions come from element.js
}
@ -49,8 +50,41 @@ extern "C" {
// gl.uniform_matrix2fv_with_f32_array(None, false, &[1.]);
// gl.uniform_matrix3fv_with_f32_array(None, false, &[1.]);
// gl.uniform_matrix4fv_with_f32_array(None, false, &[1.]);
//}
//
// gl.tex_image_2d_with_i32_and_i32_and_i32_and_format_and_type_and_opt_u8_array(
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// Some(&[1]),
// );
// gl.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_u8_array(
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// Some(&[1]),
// );
// gl.compressed_tex_image_2d_with_u8_array(0, 0, 0, 0, 0, 0, &[1]);
// }
//
//#[wasm_bindgen_test]
//fn test_webgl2_rendering_context_immutable_slices() {
// let gl = new_webgl2_rendering_context();
// gl.tex_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
// gl.tex_sub_image_3d_with_opt_u8_array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Some(&[1]));
// gl.compressed_tex_image_3d_with_u8_array(0, 0, 0, 0, 0, 0, 0, &[1]);
//}
//
// TODO:
//#[wasm_bindgen_test]
//fn test_another_types_immutable_slices_here() {