OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 var checkAttributes = { | 7 var trueAttributes = { |
8 alpha : true, | 8 alpha : true, |
9 }; | 9 }; |
10 | 10 |
| 11 var falseAttributes = { |
| 12 alpha : false, |
| 13 }; |
| 14 |
11 function testAttributes(expectedAttributes, checkValue) { | 15 function testAttributes(expectedAttributes, checkValue) { |
12 | 16 |
13 if (arguments.length != 1 && arguments.length != 2) | 17 if (arguments.length != 1 && arguments.length != 2) |
14 return; | 18 return; |
15 | 19 |
16 var canvas = document.createElement("canvas"); | 20 var canvas = document.createElement("canvas"); |
17 var initialAttributes = {}; | 21 var initialAttributes = {}; |
18 var isUndefinedOrNull = arguments.length == 2 && | 22 var isUndefinedOrNull = arguments.length == 2 && |
19 (checkValue == undefined || checkValue == null); | 23 (checkValue == undefined || checkValue == null); |
20 | 24 |
21 if (isUndefinedOrNull) | 25 if (isUndefinedOrNull) |
22 for (key in expectedAttributes) | 26 for (key in expectedAttributes) |
23 initialAttributes[key] = checkValue; | 27 initialAttributes[key] = checkValue; |
24 | 28 |
25 var context = canvas.getContext("2d", initialAttributes); | 29 var context = canvas.getContext("2d", initialAttributes); |
26 | 30 |
27 window.actualContextAttributes = context.getContextAttributes(); | 31 window.actualContextAttributes = context.getContextAttributes(); |
28 | 32 |
29 for (key in expectedAttributes) | 33 for (key in expectedAttributes) |
30 shouldBe("actualContextAttributes." + key, | 34 shouldBe("actualContextAttributes." + key, |
31 expectedAttributes[key].toString()); | 35 expectedAttributes[key].toString()); |
32 } | 36 } |
33 | 37 |
34 </script> | 38 </script> |
35 </head> | 39 </head> |
36 <body> | 40 <body> |
37 <script> | 41 <script> |
38 | 42 |
39 debug("Testing default value:"); | 43 debug("Testing default value:"); |
40 testAttributes(checkAttributes); | 44 testAttributes(trueAttributes); |
41 debug("") | 45 debug("") |
42 | 46 |
43 debug("Testing undefined value:"); | 47 debug("Testing undefined value:"); |
44 testAttributes(checkAttributes, undefined); | 48 testAttributes(trueAttributes, undefined); |
45 debug("") | 49 debug("") |
46 | 50 |
47 debug("Testing null value:"); | 51 debug("Testing null value:"); |
48 testAttributes(checkAttributes, null); | 52 testAttributes(falseAttributes, null); |
49 debug("") | 53 debug("") |
50 | 54 |
51 </script> | 55 </script> |
52 </body> | 56 </body> |
OLD | NEW |