diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html b/dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html new file mode 100644 index 0000000000..638d7a7099 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance/context/context-size-change.html @@ -0,0 +1,92 @@ +<!-- +Copyright (c) 2019 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"> +<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> + +<script> +"use strict"; + +// These declarations need to be global for "shouldBe" to see them +var gl; +var pixel = [0, 0, 0, 1]; +var canvas; + +function init() +{ + description('Verify that changing the size of an antialiased WebGL context does not cause it to stop working.'); + + runTest(); +} + +function getWebGL(canvasWidth, canvasHeight, contextAttribs) +{ + canvas = document.createElement("canvas"); + if (!canvas) + return null; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + + gl = WebGLTestUtils.create3DContext(canvas, contextAttribs); + if (!gl) + return null; + + return gl; +} + +function runTest() +{ + shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, antialias: true })"); + + // Clear to black. + gl.clearColor(0.0, 0.0, 0.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // Check that the pixel's R channel is 0. + var buf = new Uint8Array(1 * 1 * 4); + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); + pixel[0] = buf[0]; + shouldBeTrue("pixel[0] == 0"); + + // Change the size of the canvas. + canvas.width = 3; + canvas.height = 3; + + // Clear to black. + gl.clearColor(0.0, 0.0, 0.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // Clear the top-left pixel to white. + gl.enable(gl.SCISSOR_TEST); + gl.scissor(0, 0, 1, 1); + gl.clearColor(1.0, 1.0, 1.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // Check that the top-left pixel has R channel 255. + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); + pixel[0] = buf[0]; + shouldBeTrue("pixel[0] == 255"); + + // Check that the bottom-right pixel has R channel 0. + gl.readPixels(2, 2, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf); + pixel[0] = buf[0]; + shouldBeTrue("pixel[0] == 0"); + + finishTest(); +} + +</script> +</head> +<body onload="init()"> +<div id="description"></div> +<div id="console"></div> +</body> +</html> |