OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
3 Use of this source code is governed by a BSD-style license that can be | |
4 found in the LICENSE file. | |
5 --> | |
6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
7 "http://www.w3.org/TR/html4/loose.dtd"> | |
8 <html> | |
9 <head> | |
10 <title>WebGL Lost Context Wrapper Test</title> | |
11 <link rel="stylesheet" href="../tests/resources/js-test-style.css"/> | |
12 <script src="../tests/resources/js-test-pre.js"></script> | |
13 <script src="../tests/conformance/resources/webgl-test.js"> </script> | |
14 <script src="webgl-debug.js"> </script> | |
15 </head> | |
16 <body> | |
17 <canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></c
anvas> | |
18 <div id="description"></div> | |
19 <div id="console"></div> | |
20 <script> | |
21 debug("Tests the context lost simulator."); | |
22 debug(""); | |
23 var gl = create3DContext(document.getElementById("example")); | |
24 //gl = WebGLDebugUtils.makeDebugContext(gl); | |
25 //WebGLDebugUtils.resetToInitialState(gl); | |
26 gl = WebGLDebugUtils.makeLostContextSimulatingContext(gl); | |
27 gl.registerOnContextRestoredListener(afterContextRestored); | |
28 | |
29 assertMsg(gl, "Got 3d context."); | |
30 | |
31 var vertexObject = gl.createBuffer(); | |
32 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); | |
33 glErrorShouldBe(gl, gl.NO_ERROR, "no errors from setup"); | |
34 gl.loseContext(); | |
35 glErrorShouldBe(gl, gl.CONTEXT_LOST_WEBGL, "error should be lost context"); | |
36 shouldBeNull("gl.createBuffer()"); | |
37 gl.restoreContext(); | |
38 function afterContextRestored() { | |
39 glErrorShouldBe(gl, gl.NO_ERROR, "no errors after context restored"); | |
40 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); | |
41 glErrorShouldBe(gl, gl.INVALID_OPERATION, "invalid operation using a resource
from lost context"); | |
42 vertexObject = gl.createBuffer(); | |
43 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); | |
44 glErrorShouldBe(gl, gl.NO_ERROR, "okay to use new context"); | |
45 | |
46 successfullyParsed = true; | |
47 var epilogue = document.createElement("script"); | |
48 epilogue.onload = finish; | |
49 epilogue.src = "../tests/resources/js-test-post.js"; | |
50 document.body.appendChild(epilogue); | |
51 } | |
52 | |
53 function finish() { | |
54 if (window.nonKhronosFrameworkNotifyDone) { | |
55 window.nonKhronosFrameworkNotifyDone(); | |
56 } | |
57 } | |
58 | |
59 </script> | |
60 </body> | |
61 </html> | |
62 | |
OLD | NEW |