Skip to content

Commit c00878f

Browse files
committed
TST a test for WebGL support. Fixes scrapinghubGH-616.
1 parent e7253d2 commit c00878f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

splash/tests/test_execute.py

+21
Original file line numberDiff line numberDiff line change
@@ -3507,6 +3507,27 @@ def test_default_value(self):
35073507
self.assertEqual(resp.json(), {'enabled': defaults.PLUGINS_ENABLED})
35083508

35093509

3510+
class WebGLTest(BaseLuaRenderTest):
3511+
def test_webgl(self):
3512+
# WebGL detection code is from
3513+
# https://developer.mozilla.org/en-US/docs/Learn/WebGL/By_example/Detect_WebGL
3514+
resp = self.request_lua("""
3515+
function main(splash)
3516+
webgl_supported = splash:jsfunc([[
3517+
function () {
3518+
var canvas = document.createElement("canvas");
3519+
var gl = canvas.getContext("webgl")
3520+
|| canvas.getContext("experimental-webgl");
3521+
return (gl && gl instanceof WebGLRenderingContext);
3522+
}
3523+
]])
3524+
return webgl_supported()
3525+
end
3526+
""")
3527+
self.assertStatusCode(resp, 200)
3528+
self.assertEqual(resp.text, "True")
3529+
3530+
35103531
class MouseEventsTest(BaseLuaRenderTest):
35113532
def _assert_event_property(self, name, value, resp):
35123533
self.assertIn("{}:{}".format(name, value), resp.text)

0 commit comments

Comments
 (0)