Web Inspector: REGRESSION (r238602): Elements: deleting the last child of a collapsed...
[WebKit-https.git] / LayoutTests / webgl / webgl2-primitive-restart-expected.html
1 <!DOCTYPE html>
2 <html lang="en">
3
4 <head>
5     <title>WebGL 2 Samples - draw_primitive_restart</title>
6     <meta charset="utf-8">
7     <link rel="stylesheet" href="2.0.0/resources/webgl_test_files/resources/js-test-style.css">
8     <script src="2.0.0/resources/webgl_test_files/js/js-test-pre.js"></script>
9     <script src="2.0.0/resources/webgl_test_files/js/webgl-test-utils.js"></script>
10 </head>
11
12 <body>
13     <div id="info">WebGL 2 Samples - draw_primitive_restart</div>
14     <div id="console"></div>
15
16     <script id="vs" type="x-shader/x-vertex">#version 300 es
17         precision highp float;
18         precision highp int;
19
20         layout(location = 0) in vec2 pos;
21
22         void main()
23         {
24             gl_Position = vec4(pos, 0.0, 1.0);
25         }
26     </script>
27
28     <script id="fs" type="x-shader/x-fragment">#version 300 es
29         precision highp float;
30         precision highp int;
31
32         out vec4 color;
33
34         void main()
35         {
36             color = vec4(1.0, 0.5, 0.0, 1.0);
37         }
38     </script>
39
40     <script>
41     (function () {
42         'use strict';
43         var wtu = WebGLTestUtils;
44
45         // -- Init Canvas
46         var canvas = document.createElement('canvas');
47         canvas.width = 200;
48         canvas.height = canvas.width;
49         document.body.appendChild(canvas);
50
51         // -- Init WebGL Context
52         var gl = canvas.getContext('webgl2', { antialias: false });
53         var isWebGL2 = !!gl;
54         if (!isWebGL2) {
55             testFailed("WebGL 2 context does not exist");
56             return;
57         }
58
59         testPassed("WebGL 2 context exists");
60
61         // -- Init Program
62         var program = wtu.setupProgram(gl, ["vs", "fs"]);
63         gl.useProgram(program);
64
65         // -- Init Buffer
66         var vertices = new Float32Array([
67             -1.0, -1.0,
68             -1.0,  1.0,
69              1.0, -1.0,
70              1.0,  1.0
71         ]);
72
73         var vertexPosBuffer = gl.createBuffer();
74         gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
75         gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
76         gl.bindBuffer(gl.ARRAY_BUFFER, null);
77
78         var num_vertices = 6;
79         var indices = new Uint16Array([
80             0, 1, 2, 2, 3, 1
81         ]);
82
83         var vertexElementBuffer = gl.createBuffer();
84         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexElementBuffer);
85         gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
86         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
87
88         // -- Init Vertex Array
89         var vertexArray = gl.createVertexArray();
90         gl.bindVertexArray(vertexArray);
91
92         var vertexPosLocation = 0;
93         gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
94         gl.enableVertexAttribArray(vertexPosLocation);
95         gl.vertexAttribPointer(vertexPosLocation, 2, gl.FLOAT, false, 0, 0);
96         gl.bindBuffer(gl.ARRAY_BUFFER, null);
97         
98         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vertexElementBuffer);
99
100         gl.bindVertexArray(null);
101
102         // -- Render
103         gl.clearColor(0.0, 0.0, 0.0, 1.0);
104         gl.clear(gl.COLOR_BUFFER_BIT);
105
106         gl.bindVertexArray(vertexArray);
107
108         gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
109
110         // -- Delete WebGL resources
111         gl.deleteBuffer(vertexPosBuffer);
112         gl.deleteBuffer(vertexElementBuffer);
113         gl.deleteProgram(program);
114         gl.deleteVertexArray(vertexArray);
115     })();
116     </script>
117 </body>
118 </html>