browser/devtools/tilt/test/browser_tilt_gl08.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_gl08.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     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_gl08 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 t = new renderer.Texture({
    1.35 +    source: canvas,
    1.36 +    format: "RGB"
    1.37 +  });
    1.38 +
    1.39 +  ok(t instanceof TiltGL.Texture,
    1.40 +    "The texture object wasn't instantiated correctly.");
    1.41 +
    1.42 +  ok(t._ref,
    1.43 +    "The texture WebGL object wasn't created properly.");
    1.44 +  isnot(t._id, -1,
    1.45 +    "The texture id wasn't set properly.");
    1.46 +  isnot(t.width, -1,
    1.47 +    "The texture width wasn't set properly.");
    1.48 +  isnot(t.height, -1,
    1.49 +    "The texture height wasn't set properly.");
    1.50 +  ok(t.loaded,
    1.51 +    "The texture loaded flag wasn't set to true as it should.");
    1.52 +}

mercurial