WebGL Support Test

This page simply tests whether JavaScript code is able to obtain one of the following contexts from a <canvas> element:

Testing…

Testing code:

/*global $ */
$(function () {
    var $p = $("#test-result"), supported, ctx;

    supported = function () {
        var e = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"],
            result, context, i;

        for (i = 0; i < e.length; i += 1) {
            try {
                context = $("<canvas>").get(0).getContext(e[i]);
                if (context) {
                    result = {
                        name: e[i],
                        context: context
                    };
                }
            } catch (error) {}

            if (context) {
                break;
            }
        }

        return result;
    };

    ctx = supported();

    if (ctx) {
        $p.text('Your browser supports WebGL using the "' + ctx.name +
            '" context :D').addClass("supported");
    } else {
        $p.text("Could not get a WebGL context. Your browser does not appear" +
            " to support WebGL :(").addClass("not-supported");
    }
});