1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
content / test / data / gpu / gpu_process_crash.html [blame]
<html>
<head>
<script type="text/javascript">
function onLoad() {
window.domAutomationController.reset = function() {
window.domAutomationController._loaded = false;
window.domAutomationController._succeeded = false;
window.domAutomationController._finished = false;
window.requestAnimationFrame(draw);
};
window.domAutomationController.send("LOADED");
}
function draw() {
// Render some WebGL into a fresh canvas to ensure the GPU process
// was created.
var canvas = document.createElement("canvas");
canvas.width = 32;
canvas.height = 32;
gl = canvas.getContext("webgl");
if (!gl) {
console.log("Failed to fetch WebGL context");
window.domAutomationController.send("FAILED");
return;
}
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
var pixels = new Uint8Array(4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
var tolerance = 1;
if (Math.abs(pixels[0] - 255) > tolerance ||
Math.abs(pixels[1] - 0) > tolerance ||
Math.abs(pixels[2] - 0) > tolerance ||
Math.abs(pixels[3] - 255) > tolerance) {
console.log("Expected (255, 0, 0, 255), got (" +
pixels[0] + ", " +
pixels[1] + ", " +
pixels[2] + ", " +
pixels[3] + ")");
window.domAutomationController.send("FAILED");
return;
}
window.domAutomationController.send("SUCCESS");
}
</script>
</head>
<body onload="onLoad()">
GPU process crash test running.
</body>
</html>