Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/context-lost-restored.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <link rel="stylesheet" href="../resources/js-test-style.css"/>
4 <script src="../resources/js-test-pre.js"></script>
5 <script src="resources/webgl-test.js"></script>
6 <script src="resources/webgl-test-utils.js"></script>
7 <script>
8 var wtu = WebGLTestUtils;
9 var canvas;
10 var gl;
11 var shouldGenerateGLError;
12 var extension_name = "WEBKIT_lose_context";
13 var extension;
14 var bufferObjects;
15 var program;
16 var texture;
17 var texColor = [255, 10, 20, 255];
18
19 function init()
20 {
21 if (window.initNonKhronosFramework) {
22 window.initNonKhronosFramework(true);
23 }
24
25 description("Tests behavior under a restored context");
26
27 canvas = document.getElementById("canvas");
28 canvas.addEventListener("webglcontextlost", testLostContext, false);
29 canvas.addEventListener("webglcontextrestored", testRestoredContext, false);
30
31 gl = wtu.create3DContext(canvas);
32 shouldGenerateGLError = wtu.shouldGenerateGLError;
33
34 extension = gl.getExtension(extension_name);
35 if (!extension) {
36 debug(extension_name + " extension not found.");
37 finish();
38 return;
39 }
40
41 testOriginalContext();
42 extension.loseContext();
43 }
44
45 function testRendering()
46 {
47 gl.clearColor(0, 0, 0, 255);
48 gl.colorMask(1, 1, 1, 0);
49 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
50
51 program = wtu.setupSimpleTextureProgram(gl);
52 bufferObjects = wtu.setupUnitQuad(gl);
53 texture = wtu.createColoredTexture(gl, canvas.width, canvas.height, texColor );
54
55 gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
56 wtu.drawQuad(gl, [0, 0, 0, 255]);
57
58 var compare = texColor.slice(0, 3);
59 wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, compare, "shouldB e " + compare);
60
61 shouldBe("gl.getError()", "gl.NO_ERROR");
62 }
63
64 function testOriginalContext()
65 {
66 debug("Test valid context");
67 shouldBeFalse("gl.isContextLost()");
68 shouldBe("gl.getError()", "gl.NO_ERROR");
69 testRendering();
70 debug("");
71 }
72
73 function testLostContext()
74 {
75 debug("Test lost context");
76 shouldBeTrue("gl.isContextLost()");
77 shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
78 shouldBe("gl.getError()", "gl.NO_ERROR");
79 debug("");
80 }
81
82 function testResources(expected)
83 {
84 var tests = [
85 "gl.bindTexture(gl.TEXTURE_2D, texture)",
86 "gl.useProgram(program)",
87 "gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0])",
88 ];
89
90 for (var i = 0; i < tests.length; ++i)
91 shouldGenerateGLError(gl, expected, tests[i]);
92 }
93
94 function testRestoredContext()
95 {
96 debug("Test restored context");
97 shouldBeFalse("gl.isContextLost()");
98 shouldBe("gl.getError()", "gl.NO_ERROR");
99
100 // Validate that using old resources fails.
101 testResources(gl.INVALID_OPERATION);
102
103 testRendering();
104
105 // Validate new resources created in testRendering().
106 testResources(gl.NO_ERROR);
107 debug("");
108
109 finish();
110 }
111
112 function finish() {
113 successfullyParsed = true;
114 var epilogue = document.createElement("script");
115 epilogue.onload = function() {
116 if (window.nonKhronosFrameworkNotifyDone)
117 window.nonKhronosFrameworkNotifyDone();
118 };
119 epilogue.src = "../resources/js-test-post.js";
120 document.body.appendChild(epilogue);
121 }
122
123 </script>
124 </head>
125 <body onload="init()">
126 <div id="description"></div>
127 <div id="console"></div>
128 <canvas id="canvas" width="1px" height="1px"></canvas>
129 </body>
130 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698