Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / wasm / buffersubdata-4gb-wasm-memory.html
blob2834a6901b9f64f37c6788c9c51799891755f1be
1 <!--
2 Copyright (c) 2024 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <title>bufferSubData test to Wasm Memory 4GB in size.</title>
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
12 <script src="../../js/js-test-pre.js"></script>
13 <script src="../../js/webgl-test-utils.js"> </script>
14 </head>
15 <body>
16 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
17 <div id="description"></div>
18 <div id="console"></div>
19 <script>
20 "use strict";
21 description(document.title);
22 debug("Tests that bufferSubData can be called on WebAssembly Memory of 4GB in size.");
23 debug("");
24 let wtu = WebGLTestUtils;
25 let gl = wtu.create3DContext("canvas", undefined, 2);
27 const PAGE = 65536;
28 const SIZE = 4 * 1024 * 1024 * 1024 - PAGE;
29 let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer);
30 let expectedData = new Uint8Array([1, 2]);
31 const length = expectedData.length;
32 let srcOffset = SIZE - length;
33 view.set(expectedData, srcOffset);
34 const dstByteOffset = 4;
36 let buf = gl.createBuffer();
37 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
38 gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
39 gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
40 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
42 let actualData = new Uint8Array(length);
43 gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
44 for (let i = 0; i < length; i++) {
45 shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
48 var successfullyParsed = true;
49 </script>
50 <script src="../../js/js-test-post.js"></script>
51 </body>
52 </html>