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