dom/canvas/test/webgl-conf/checkout/conformance2/wasm/buffersubdata-4gb-wasm-memory.html
author Serban Stanca <sstanca@mozilla.com>
Mon, 14 Jul 2025 00:37:50 +0300 (10 hours ago)
changeset 796395 57c30f1adca5fb5ccd4a9a09192c41e207e28d88
parent 733882 f84653591dd8f1b955c0215059e19d6b82a52016
permissions -rw-r--r--
Revert "Bug 1950748 part 3: Don't return a caret inside an editor when no editor is focused. r=morgan" as requested for causing accessibility crashes (bug 1977012). This reverts commit aaf970807d281c28c1e937491719d996cb11648a. This reverts commit f5f2e3cf4d34c2430372ba790d77620837d56b75. This reverts commit 5565c5899c32c0b0f5446561a21c5b6499fd44c6.
<!--
Copyright (c) 2024 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>bufferSubData test to Wasm Memory 4GB in size.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description(document.title);
debug("Tests that bufferSubData can be called on WebAssembly Memory of 4GB in size.");
debug("");
let wtu = WebGLTestUtils;
let gl = wtu.create3DContext("canvas", undefined, 2);

const PAGE = 65536;
const SIZE = 4 * 1024 * 1024 * 1024 - PAGE;
let view = new Uint8Array(new WebAssembly.Memory({ initial: SIZE / PAGE }).buffer);
let expectedData = new Uint8Array([1, 2]);
const length = expectedData.length;
let srcOffset = SIZE - length;
view.set(expectedData, srcOffset);
const dstByteOffset = 4;

let buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, 8, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, dstByteOffset, view, srcOffset, length);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);

let actualData = new Uint8Array(length);
gl.getBufferSubData(gl.ARRAY_BUFFER, dstByteOffset, actualData);
for (let i = 0; i < length; i++) {
  shouldBe(`actualData[${i}]`, `expectedData[${i}]`);
}

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
</body>
</html>