test_webgl_debug_renderer_info.html (2113B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=666446 5 --> 6 <head> 7 <title>Test that WEBGL_debug_renderer_info works in chrome code</title> 8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 13 <script> 14 15 const UNMASKED_VENDOR_WEBGL = 0x9245; 16 const UNMASKED_RENDERER_WEBGL = 0x9246; 17 18 function isNonEmptyString(s) { 19 return s && (typeof s) == "string"; 20 } 21 22 var canvas = document.createElement("canvas"); 23 var gl = canvas.getContext("experimental-webgl"); 24 ok(!gl.getError(), "getError on newly created WebGL context should return NO_ERROR"); 25 26 ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM, 27 "Should not be able to query UNMASKED_VENDOR_WEBGL without having enabled the WEBGL_debug_renderer_info extension"); 28 ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM, 29 "Should not be able to query UNMASKED_RENDERER_WEBGL without having enabled the WEBGL_debug_renderer_info extension"); 30 31 var exts = gl.getSupportedExtensions(); 32 ok(exts.includes("WEBGL_debug_renderer_info"), 33 "WEBGL_debug_renderer_info should be listed by getSupportedExtensions in chrome contexts"); 34 var ext = gl.getExtension("WEBGL_debug_renderer_info"); 35 ok(ext, 36 "WEBGL_debug_renderer_info should be available through getExtension in chrome contexts"); 37 38 ok(ext.UNMASKED_VENDOR_WEBGL == UNMASKED_VENDOR_WEBGL, 39 "UNMASKED_VENDOR_WEBGL has the correct value"); 40 ok(ext.UNMASKED_RENDERER_WEBGL == UNMASKED_RENDERER_WEBGL, 41 "UNMASKED_RENDERER_WEBGL has the correct value"); 42 43 ok(isNonEmptyString(gl.getParameter(UNMASKED_VENDOR_WEBGL)) && gl.getError() == gl.NO_ERROR, 44 "Should be able to query UNMASKED_VENDOR_WEBGL in chrome context with WEBGL_debug_renderer_info enabled"); 45 ok(isNonEmptyString(gl.getParameter(UNMASKED_RENDERER_WEBGL)) && gl.getError() == gl.NO_ERROR, 46 "Should be able to query UNMASKED_RENDERER_WEBGL in chrome context with WEBGL_debug_renderer_info enabled"); 47 48 </script> 49 </body> 50 </html>