Index: content/test/data/gpu/pixel_webgl_context_restore.html |
diff --git a/content/test/data/gpu/pixel_webgl.html b/content/test/data/gpu/pixel_webgl_context_restore.html |
similarity index 81% |
copy from content/test/data/gpu/pixel_webgl.html |
copy to content/test/data/gpu/pixel_webgl_context_restore.html |
index b82fa81e55d69c4afd1618aacc43fd0316e6274c..0bb4ed641bb55bc2450824b7ea878d5f96d6fc62 100644 |
--- a/content/test/data/gpu/pixel_webgl.html |
+++ b/content/test/data/gpu/pixel_webgl_context_restore.html |
@@ -8,7 +8,7 @@ that the baseline images are regenerated on the next run. |
<html> |
<head> |
-<title>WebGL Test: Green Triangle over Black Background</title> |
+<title>WebGL Test: Yellow Triangle over Black Background with context loss and restore</title> |
<style type="text/css"> |
.nomargin { |
margin: 0px auto; |
@@ -27,20 +27,39 @@ void main(void) |
precision mediump float; |
void main(void) |
{ |
- gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); |
+ gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); |
} |
</script> |
<script> |
var g_swapsBeforeAck = 15; |
var gl; |
+var lose_context_ext; |
function main() |
{ |
var canvas = document.getElementById("c"); |
gl = initGL(canvas); |
+ |
+ canvas.addEventListener("webglcontextlost", function(ev) { |
+ ev.preventDefault(); |
+ }, false); |
+ canvas.addEventListener("webglcontextrestored", function(ev) { |
+ if (setup(gl)) { |
+ drawSomeFrames(); |
+ } else { |
+ domAutomationController.setAutomationId(1); |
+ domAutomationController.send("FAILURE"); |
+ } |
+ }, false); |
+ |
if (gl && setup(gl)) { |
- drawSomeFrames(); |
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
+ |
+ lose_context_ext.loseContext(); |
+ setTimeout(function() { |
+ lose_context_ext.restoreContext(); |
+ }, 3000); |
} else { |
domAutomationController.setAutomationId(1); |
domAutomationController.send("FAILURE"); |
@@ -77,6 +96,9 @@ function setupShader(gl, source, type) { |
var shader = gl.createShader(type); |
gl.shaderSource(shader, source); |
gl.compileShader(shader); |
+ lose_context_ext = gl.getExtension("WEBGL_lose_context"); |
+ if (!lose_context_ext) |
+ return null; |
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) |
return null; |
return shader; |