Chromium Code Reviews| Index: LayoutTests/fast/canvas/script-tests/canvas-lost-gpu-context.js |
| diff --git a/LayoutTests/fast/canvas/script-tests/canvas-lost-gpu-context.js b/LayoutTests/fast/canvas/script-tests/canvas-lost-gpu-context.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..34a8724d41500bda62df6868d8206d1d96e46b8d |
| --- /dev/null |
| +++ b/LayoutTests/fast/canvas/script-tests/canvas-lost-gpu-context.js |
| @@ -0,0 +1,22 @@ |
| +description("Test the behavior of canvas recovery after a gpu context loss"); |
| + |
| +if (window.internals && window.testRunner) { |
| + window.testRunner.dumpAsText(); |
| + var ctx = document.createElement('canvas').getContext('2d'); |
| + document.body.appendChild(ctx.canvas); |
| + ctx.fillStyle = '#f00'; |
| + ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); |
| + // context loss is a no-op when not gpu-acelerated, which is fine for this test |
| + window.internals.loseSharedGraphicsContext3D(); |
|
Stephen White
2013/06/18 18:06:57
I wonder if we should do this four times, to test
|
| + //Verify that buffer automatically recovers to a usable state |
| + ctx.fillStyle = '#0f0'; |
| + ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); |
| + imageData = ctx.getImageData(0, 0, 1, 1); |
| + imgdata = imageData.data; |
| + shouldBe("imgdata[0]", "0"); |
| + shouldBe("imgdata[1]", "255"); |
| + shouldBe("imgdata[2]", "0"); |
| + shouldBe("imgdata[3]", "255"); |
| +} else { |
| + testFailed('This test requires window.internals and window.testRunner.'); |
| +} |