tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gl-line-width.html (2794B)


      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 -->
      6 
      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");
     25 
     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.");
     29 
     30 if (lineWidthRange[0] > 1 || lineWidthRange[1] < 1)
     31  testFailed("Line width range must include width 1");
     32 
     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
     38 
     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
     42 
     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
     46 
     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]');
     51 
     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]');
     55 
     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');
     63 
     64 var successfullyParsed = true;
     65 
     66 </script>
     67 <script src="../../js/js-test-post.js"></script>
     68 
     69 </body>
     70 </html>