browser/devtools/tilt/test/browser_tilt_gl07.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/tilt/test/browser_tilt_gl07.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +"use strict";
     1.7 +
     1.8 +let isWebGLAvailable;
     1.9 +
    1.10 +function onWebGLFail() {
    1.11 +  isWebGLAvailable = false;
    1.12 +}
    1.13 +
    1.14 +function onWebGLSuccess() {
    1.15 +  isWebGLAvailable = true;
    1.16 +}
    1.17 +
    1.18 +function test() {
    1.19 +  if (!isWebGLSupported()) {
    1.20 +    info("Skipping tilt_gl07 because WebGL isn't supported on this hardware.");
    1.21 +    return;
    1.22 +  }
    1.23 +
    1.24 +  let canvas = createCanvas();
    1.25 +
    1.26 +  let renderer = new TiltGL.Renderer(canvas, onWebGLFail, onWebGLSuccess);
    1.27 +  let gl = renderer.context;
    1.28 +
    1.29 +  if (!isWebGLAvailable) {
    1.30 +    return;
    1.31 +  }
    1.32 +
    1.33 +
    1.34 +  let p = new renderer.Program({
    1.35 +    vs: TiltGL.ColorShader.vs,
    1.36 +    fs: TiltGL.ColorShader.fs,
    1.37 +    attributes: ["vertexPosition"],
    1.38 +    uniforms: ["mvMatrix", "projMatrix", "fill"]
    1.39 +  });
    1.40 +
    1.41 +  ok(p instanceof TiltGL.Program,
    1.42 +    "The program object wasn't instantiated correctly.");
    1.43 +
    1.44 +  ok(p._ref,
    1.45 +    "The program WebGL object wasn't created properly.");
    1.46 +  isnot(p._id, -1,
    1.47 +    "The program id wasn't set properly.");
    1.48 +  ok(p._attributes,
    1.49 +    "The program attributes cache wasn't created properly.");
    1.50 +  ok(p._uniforms,
    1.51 +    "The program uniforms cache wasn't created properly.");
    1.52 +
    1.53 +  is(typeof p._attributes.vertexPosition, "number",
    1.54 +    "The vertexPosition attribute wasn't cached as it should.");
    1.55 +  is(typeof p._uniforms.mvMatrix, "object",
    1.56 +    "The mvMatrix uniform wasn't cached as it should.");
    1.57 +  is(typeof p._uniforms.projMatrix, "object",
    1.58 +    "The projMatrix uniform wasn't cached as it should.");
    1.59 +  is(typeof p._uniforms.fill, "object",
    1.60 +    "The fill uniform wasn't cached as it should.");
    1.61 +}

mercurial