michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: let dom = TiltUtils.DOM; michael@0: ok(dom, "The TiltUtils.DOM wasn't found."); michael@0: michael@0: michael@0: is(dom.initCanvas(), null, michael@0: "The initCanvas() function shouldn't work if no parent node is set."); michael@0: michael@0: michael@0: dom.parentNode = gBrowser.parentNode; michael@0: ok(dom.parentNode, michael@0: "The necessary parent node wasn't found."); michael@0: michael@0: michael@0: let canvas = dom.initCanvas(null, { michael@0: append: true, michael@0: focusable: true, michael@0: width: 123, michael@0: height: 456, michael@0: id: "tilt-test-canvas" michael@0: }); michael@0: michael@0: is(canvas.width, 123, michael@0: "The test canvas doesn't have the correct width set."); michael@0: is(canvas.height, 456, michael@0: "The test canvas doesn't have the correct height set."); michael@0: is(canvas.getAttribute("tabindex"), 1, michael@0: "The test canvas tab index wasn't set correctly."); michael@0: is(canvas.getAttribute("id"), "tilt-test-canvas", michael@0: "The test canvas doesn't have the correct id set."); michael@0: ok(dom.parentNode.ownerDocument.getElementById(canvas.id), michael@0: "A canvas should be appended to the parent node if specified."); michael@0: canvas.parentNode.removeChild(canvas); michael@0: michael@0: let canvas2 = dom.initCanvas(null, { id: "tilt-test-canvas2" }); michael@0: michael@0: is(canvas2.width, dom.parentNode.clientWidth, michael@0: "The second test canvas doesn't have the implicit width set."); michael@0: is(canvas2.height, dom.parentNode.clientHeight, michael@0: "The second test canvas doesn't have the implicit height set."); michael@0: is(canvas2.id, "tilt-test-canvas2", michael@0: "The second test canvas doesn't have the correct id set."); michael@0: is(dom.parentNode.ownerDocument.getElementById(canvas2.id), null, michael@0: "A canvas shouldn't be appended to the parent node if not specified."); michael@0: michael@0: michael@0: dom.parentNode = null; michael@0: is(dom.parentNode, null, michael@0: "The necessary parent node shouldn't be found anymore."); michael@0: }