Backed out changeset 8fc3326bce7f (bug 1943032) for causing failures at browser_tab_g...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / limits / gl-line-width.html
blobe446c62a94049e47a9eca2019f0e861d9e6c36b8
1 <!--
2 Copyright (c) 2019 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 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>Verify that line width limits are enforced.</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"> </script>
15 </head>
16 <body>
17 <canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script>
21 "use strict";
22 description(document.title);
23 var wtu = WebGLTestUtils;
24 var gl = wtu.create3DContext("example");
26 // Query the line width range
27 var lineWidthRange = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
28 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
30 if (lineWidthRange[0] > 1 || lineWidthRange[1] < 1)
31 testFailed("Line width range must include width 1");
33 // Zero, negative, or NaN values should cause an error and leave the value unchanged.
34 var curLineWidth = gl.getParameter(gl.LINE_WIDTH);
35 gl.lineWidth(0);
36 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to zero");
37 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
39 gl.lineWidth(-1);
40 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to a negative value");
41 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
43 gl.lineWidth(NaN);
44 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Should not be able to set lineWidth to NaN");
45 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'curLineWidth'); // Previous value should be preserved
47 // Check that the line width can be set to the valid range.
48 gl.lineWidth(lineWidthRange[1]);
49 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the max supported value");
50 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]');
52 gl.lineWidth(lineWidthRange[0]);
53 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the min supported value");
54 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[0]');
56 // Checks that the line width can be set outside the supported range without error,
57 // and the unclamped value can be queried back.
58 // Yes, this is actually what the spec says should happen.
59 // See: https://www.khronos.org/opengles/sdk/docs/man3/html/glLineWidth.xhtml
60 gl.lineWidth(lineWidthRange[1]+1);
61 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be able to set lineWidth to the above max supported value");
62 shouldBe('gl.getParameter(gl.LINE_WIDTH)', 'lineWidthRange[1]+1');
64 var successfullyParsed = true;
66 </script>
67 <script src="../../js/js-test-post.js"></script>
69 </body>
70 </html>