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

Side by Side Diff: conformance/context-lost-restored.html

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

Powered by Google App Engine
This is Rietveld 408576698