|
Line 0
a/LayoutTests/fast/canvas/webgl/high-performance-context.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>High performance WebGL context test</title> |
| 6 |
<script src="../../../resources/js-test.js"></script> |
| 7 |
<script src="resources/webgl-test.js"> </script> |
| 8 |
<script src="resources/webgl-test-utils.js"> </script> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div id="description"></div> |
| 12 |
<div id="console"></div> |
| 13 |
<script> |
| 14 |
description("Tests that a high-performance contexts do not fail."); |
| 15 |
if (window.testRunner) { |
| 16 |
testRunner.dumpAsText(); |
| 17 |
testRunner.waitUntilDone(); |
| 18 |
} |
| 19 |
var wtu = WebGLTestUtils; |
| 20 |
var canvas = document.createElement('canvas'); |
| 21 |
canvas.addEventListener("webglcontextchanged", () => { |
| 22 |
testRunner.notifyDone(); |
| 23 |
}, false); |
| 24 |
var gl = wtu.create3DContext(canvas, { powerPreference: "high-performance" }); |
| 25 |
shouldBe("gl.getContextAttributes().powerPreference", '"high-performance"'); |
| 26 |
canvas.width = 200; |
| 27 |
canvas.height = 200; |
| 28 |
gl.viewport(0, 0, 0, 0); |
| 29 |
var program = wtu.setupTexturedQuad(gl); |
| 30 |
shouldBeTrue("program != null"); |
| 31 |
var tex = gl.createTexture(); |
| 32 |
gl.bindTexture(gl.TEXTURE_2D, tex); |
| 33 |
var pixel = new Uint8Array([0, 255, 0, 255]); |
| 34 |
gl.texImage2D( |
| 35 |
gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel); |
| 36 |
wtu.drawQuad(gl); |
| 37 |
|
| 38 |
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup."); |
| 39 |
</script> |
| 40 |
</body> |
| 41 |
</html> |