browser/devtools/tilt/test/browser_tilt_utils04.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_utils04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     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 +function test() {
     1.9 +  let dom = TiltUtils.DOM;
    1.10 +  ok(dom, "The TiltUtils.DOM wasn't found.");
    1.11 +
    1.12 +
    1.13 +  is(dom.initCanvas(), null,
    1.14 +    "The initCanvas() function shouldn't work if no parent node is set.");
    1.15 +
    1.16 +
    1.17 +  dom.parentNode = gBrowser.parentNode;
    1.18 +  ok(dom.parentNode,
    1.19 +    "The necessary parent node wasn't found.");
    1.20 +
    1.21 +
    1.22 +  let canvas = dom.initCanvas(null, {
    1.23 +    append: true,
    1.24 +    focusable: true,
    1.25 +    width: 123,
    1.26 +    height: 456,
    1.27 +    id: "tilt-test-canvas"
    1.28 +  });
    1.29 +
    1.30 +  is(canvas.width, 123,
    1.31 +    "The test canvas doesn't have the correct width set.");
    1.32 +  is(canvas.height, 456,
    1.33 +    "The test canvas doesn't have the correct height set.");
    1.34 +  is(canvas.getAttribute("tabindex"), 1,
    1.35 +    "The test canvas tab index wasn't set correctly.");
    1.36 +  is(canvas.getAttribute("id"), "tilt-test-canvas",
    1.37 +    "The test canvas doesn't have the correct id set.");
    1.38 +  ok(dom.parentNode.ownerDocument.getElementById(canvas.id),
    1.39 +    "A canvas should be appended to the parent node if specified.");
    1.40 +  canvas.parentNode.removeChild(canvas);
    1.41 +
    1.42 +  let canvas2 = dom.initCanvas(null, { id: "tilt-test-canvas2" });
    1.43 +
    1.44 +  is(canvas2.width, dom.parentNode.clientWidth,
    1.45 +    "The second test canvas doesn't have the implicit width set.");
    1.46 +  is(canvas2.height, dom.parentNode.clientHeight,
    1.47 +    "The second test canvas doesn't have the implicit height set.");
    1.48 +  is(canvas2.id, "tilt-test-canvas2",
    1.49 +    "The second test canvas doesn't have the correct id set.");
    1.50 +  is(dom.parentNode.ownerDocument.getElementById(canvas2.id), null,
    1.51 +    "A canvas shouldn't be appended to the parent node if not specified.");
    1.52 +
    1.53 +
    1.54 +  dom.parentNode = null;
    1.55 +  is(dom.parentNode, null,
    1.56 +    "The necessary parent node shouldn't be found anymore.");
    1.57 +}

mercurial