<html> <head> <script src="../../../resources/js-test.js"></script> <script src="resources/webgl-test.js"></script> <script src="resources/webgl-test-utils.js"> </script> </head> <body> <div id="description"></div> <div id="console"></div> <script> description("Checks that painting WebGL contents doesn't pollute the context's viewport state."); var wtu = WebGLTestUtils; if (window.testRunner) { testRunner.dumpAsText(); testRunner.waitUntilDone(); } var canvas; var context; function draw() { var viewport = context.getParameter(context.VIEWPORT); if (!areArraysEqual(viewport, [20, 20, 10, 10])) { testFailed(viewport + " should be [20, 20, 10, 10]. Was " + viewport); } else { testPassed("Viewport not corrupted."); } if (window.testRunner) testRunner.notifyDone(); } window.onload = function() { if (window.initNonKhronosFramework) { window.initNonKhronosFramework(false); } canvas = document.getElementById("webgl-canvas"); canvas.width = 50; canvas.height = 50; context = create3DContext(canvas); context.viewport(20, 20, 10, 10); context.clearColor(255, 0, 0, 255); context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT); // We need to ensure that the compositor has run before the drawing // takes place. Setting a timeout of zero causes the compositor to run before // the draw call. Using requestAnimationFrame caused the test to time-out. setTimeout(draw, 0); } </script> <canvas id="webgl-canvas" width="32px" height="32px"></canvas> </body> </html>