Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / wasm / bufferdata-16gb-wasm-memory.html
blob0dd21bf64fb4ca1abcbe159f93820c3914242793
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>bufferData test to Wasm Memory 16GB 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 bufferData can be called on WebAssembly Memory of 16GB in size.");
23 debug("");
24 let wtu = WebGLTestUtils;
25 let gl = wtu.create3DContext("canvas", undefined, 2);
27 const PAGE = 65536;
28 const SIZE = 16 * 1024 * 1024 * 1024;
29 let view = new Uint8Array(new WebAssembly.Memory({ index: 'i64', initial: SIZE / PAGE }).buffer);
30 let expectedData = new Uint8Array([1, 2, 3, 4]);
31 const length = expectedData.length;
32 const offset = SIZE - length;
33 view.set(expectedData, offset);
35 let buf = gl.createBuffer();
36 gl.bindBuffer(gl.ARRAY_BUFFER, buf);
37 gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW, offset, length);
38 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
40 let actualData = new Uint8Array(length);
41 gl.getBufferSubData(gl.ARRAY_BUFFER, 0, actualData);
42 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
43 for (let i = 0; i < length; i++) {
44 shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
47 var successfullyParsed = true;
48 </script>
49 <script src="../../js/js-test-post.js"></script>
50 </body>
51 </html>