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

Side by Side Diff: chrome/test/data/gpu/webgl.html

Issue 10984040: Enable gpu crash tests in content (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: expose the symbol of kSkipGpuDataLoading to avoid compile errors Created 8 years, 1 month 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 | « no previous file | chrome/test/gpu/gpu_crash_browsertest.cc » ('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 <html>
2 <head>
3 <script type="text/javascript">
4 var canvas;
5 var w, h;
6 var gl;
7 var extension;
8
9 function testHorizontalBands() {
10 gl.enable(gl.SCISSOR_TEST);
11
12 gl.clearColor(1, 0, 0, 1);
13 gl.scissor(0, 0, w, h/2);
14 gl.clear(gl.COLOR_BUFFER_BIT);
15
16 gl.clearColor(0, 1, 0, 1);
17 gl.scissor(0, h/2, w, h/2);
18 gl.clear(gl.COLOR_BUFFER_BIT);
19
20 gl.disable(gl.SCISSOR_TEST);
21
22 var size = w * h * 4;
23 var array = new Uint8Array(size);
24 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, array);
25
26 return array[0] == 255 && array[1] == 0 &&
27 array[size - 4] == 0 && array[size - 3] == 255;
28 }
29
30 function testContextLost(e) {
31 e.preventDefault();
32 setTimeout(function() {
33 extension.restoreContext();
34 }, 0);
35 }
36
37 function testContextRestored() {
38 gl = canvas.getContext("experimental-webgl");
39 if (!gl || gl.isContextLost()) {
40 document.title = "FAILED: could not get recovered context";
41 return;
42 }
43 gl.clearColor(0, 0, 1, 1);
44 gl.clear(gl.COLOR_BUFFER_BIT);
45
46 var a = new Uint8Array(w * h * 4);
47 gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a);
48
49 window.domAutomationController.setAutomationId(1);
50 if (a[0] == 0 && a[1] == 0 && a[2] == 255)
51 window.domAutomationController.send("SUCCESS");
52 else
53 window.domAutomationController.send("FAILED");
54 }
55
56 function contextLostTest(kind)
57 {
58 switch (kind) {
59 case "WEBGL_lose_context": {
60 extension = gl.getExtension("WEBKIT_WEBGL_lose_context") ||
61 gl.getExtension("WEBGL_lose_context");
62 extension.loseContext();
63 break;
64 }
65 case "kill":
66 // nothing -- the browser test navigates to about:gpucrash and kills
67 // the GPU process.
68 break;
69 }
70 }
71
72 function onLoad() {
73 canvas = document.getElementById("canvas1");
74 w = canvas.width;
75 h = canvas.height;
76 if (!canvas) {
77 document.title = "FAILED: canvas element not found";
78 return;
79 }
80 canvas.addEventListener("webglcontextlost", testContextLost, false);
81 canvas.addEventListener("webglcontextrestored", testContextRestored, false);
82
83 gl = canvas.getContext("experimental-webgl");
84 if (!gl) {
85 document.title = "FAILED: could not get webgl context for canvas";
86 return;
87 }
88
89 if (!testHorizontalBands()) {
90 document.title = "FAILED: did not render correctly";
91 return;
92 }
93
94 var query = /query=(.*)/.exec(window.location.href);
95 if (query) {
96 contextLostTest(query[1]);
97 } else {
98 var renderer = gl.getParameter(gl.RENDERER);
99 document.title = "SUCCESS: " + renderer;
100 }
101 }
102 </script>
103 </head>
104 <body onload="onLoad()">
105 <canvas id="canvas1" width="16px" height="32px">
106 </canvas>
107 </body>
108 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/gpu/gpu_crash_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698