|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 "use strict"; |
|
4 |
|
5 function test() { |
|
6 let dom = TiltUtils.DOM; |
|
7 ok(dom, "The TiltUtils.DOM wasn't found."); |
|
8 |
|
9 |
|
10 is(dom.initCanvas(), null, |
|
11 "The initCanvas() function shouldn't work if no parent node is set."); |
|
12 |
|
13 |
|
14 dom.parentNode = gBrowser.parentNode; |
|
15 ok(dom.parentNode, |
|
16 "The necessary parent node wasn't found."); |
|
17 |
|
18 |
|
19 let canvas = dom.initCanvas(null, { |
|
20 append: true, |
|
21 focusable: true, |
|
22 width: 123, |
|
23 height: 456, |
|
24 id: "tilt-test-canvas" |
|
25 }); |
|
26 |
|
27 is(canvas.width, 123, |
|
28 "The test canvas doesn't have the correct width set."); |
|
29 is(canvas.height, 456, |
|
30 "The test canvas doesn't have the correct height set."); |
|
31 is(canvas.getAttribute("tabindex"), 1, |
|
32 "The test canvas tab index wasn't set correctly."); |
|
33 is(canvas.getAttribute("id"), "tilt-test-canvas", |
|
34 "The test canvas doesn't have the correct id set."); |
|
35 ok(dom.parentNode.ownerDocument.getElementById(canvas.id), |
|
36 "A canvas should be appended to the parent node if specified."); |
|
37 canvas.parentNode.removeChild(canvas); |
|
38 |
|
39 let canvas2 = dom.initCanvas(null, { id: "tilt-test-canvas2" }); |
|
40 |
|
41 is(canvas2.width, dom.parentNode.clientWidth, |
|
42 "The second test canvas doesn't have the implicit width set."); |
|
43 is(canvas2.height, dom.parentNode.clientHeight, |
|
44 "The second test canvas doesn't have the implicit height set."); |
|
45 is(canvas2.id, "tilt-test-canvas2", |
|
46 "The second test canvas doesn't have the correct id set."); |
|
47 is(dom.parentNode.ownerDocument.getElementById(canvas2.id), null, |
|
48 "A canvas shouldn't be appended to the parent node if not specified."); |
|
49 |
|
50 |
|
51 dom.parentNode = null; |
|
52 is(dom.parentNode, null, |
|
53 "The necessary parent node shouldn't be found anymore."); |
|
54 } |