| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| var trueAttributes = { |
| alpha : true, |
| }; |
| |
| var falseAttributes = { |
| alpha : false, |
| }; |
| |
| function testAttributes(expectedAttributes, checkValue) { |
| |
| if (arguments.length != 1 && arguments.length != 2) |
| return; |
| |
| var canvas = document.createElement("canvas"); |
| var initialAttributes = {}; |
| var isUndefinedOrNull = arguments.length == 2 && |
| (checkValue == undefined || checkValue == null); |
| |
| if (isUndefinedOrNull) |
| for (key in expectedAttributes) |
| initialAttributes[key] = checkValue; |
| |
| var context = canvas.getContext("2d", initialAttributes); |
| |
| window.actualContextAttributes = context.getContextAttributes(); |
| |
| for (key in expectedAttributes) |
| assert_equals(eval("actualContextAttributes." + key), |
| expectedAttributes[key]); |
| } |
| |
| test(function(t) { |
| testAttributes(trueAttributes); |
| }, 'Test default value'); |
| |
| test(function(t) { |
| testAttributes(trueAttributes, undefined); |
| }, 'Test undfined value'); |
| |
| test(function(t) { |
| testAttributes(falseAttributes, null); |
| }, 'Test null value'); |
| </script> |
| </body> |