3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"resources/webgl-test.js"></script>
7 <div id=
"description"></div>
8 <div id=
"console"></div>
11 description("Test bufferData/bufferSubData with ArrayBuffer input");
13 debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=41884">https://bugs.webkit.org/show_bug.cgi?id=41884</a> : <code>Implement bufferData and bufferSubData with ArrayBuffer as input</code>');
16 window
.internals
.settings
.setWebGLErrorsToConsoleEnabled(false);
18 var gl
= create3DContext();
19 shouldBeNonNull("gl");
21 var array
= new ArrayBuffer(128);
22 shouldBeNonNull("array");
24 var buf
= gl
.createBuffer();
27 gl
.bufferData(gl
.ARRAY_BUFFER
, array
, gl
.STATIC_DRAW
);
28 glErrorShouldBe(gl
, gl
.INVALID_OPERATION
);
30 gl
.bindBuffer(gl
.ARRAY_BUFFER
, buf
);
31 glErrorShouldBe(gl
, gl
.NO_ERROR
);
33 gl
.bufferData(gl
.ARRAY_BUFFER
, -10, gl
.STATIC_DRAW
);
34 glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
36 // This should not crash, but the selection of the overload is ambiguous per Web IDL.
37 gl
.bufferData(gl
.ARRAY_BUFFER
, null, gl
.STATIC_DRAW
);
40 gl
.bufferData(gl
.ARRAY_BUFFER
, array
, gl
.STATIC_DRAW
);
41 glErrorShouldBe(gl
, gl
.NO_ERROR
);
43 array
= new ArrayBuffer(64);
45 gl
.bufferSubData(gl
.ARRAY_BUFFER
, -10, array
);
46 glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
48 gl
.bufferSubData(gl
.ARRAY_BUFFER
, -10, new Float32Array(8));
49 glErrorShouldBe(gl
, gl
.INVALID_VALUE
);
51 gl
.bufferSubData(gl
.ARRAY_BUFFER
, 10, array
);
52 glErrorShouldBe(gl
, gl
.NO_ERROR
);
54 gl
.bufferSubData(gl
.ARRAY_BUFFER
, 10, null);
55 glErrorShouldBe(gl
, gl
.NO_ERROR
);