OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <title>Use of SVGAnimatedEnumeration within SVGFilterElement</title> |
3 <head> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 </head> | 5 <script> |
6 <body> | 6 test(function() { |
7 <p id="description"></p> | 7 // This test checks the use of SVGAnimatedEnumeration within SVGFilterElement. |
8 <div id="console"></div> | 8 |
9 <script src="script-tests/SVGAnimatedEnumeration-SVGFilterElement.js"></script> | 9 var filterElement = document.createElementNS("http://www.w3.org/2000/svg", "fi
lter"); |
10 </body> | 10 filterElement.setAttribute("filterUnits", "userSpaceOnUse"); |
11 </html> | 11 filterElement.setAttribute("primitiveUnits", "userSpaceOnUse"); |
| 12 |
| 13 // filterUnits |
| 14 // Check initial 'filterUnits' value. |
| 15 assert_true(filterElement.filterUnits instanceof SVGAnimatedEnumeration); |
| 16 assert_equals(typeof(filterElement.filterUnits.baseVal), "number"); |
| 17 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_US
ERSPACEONUSE); |
| 18 |
| 19 // Switch to 'objectBoundingBox'. |
| 20 filterElement.filterUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGB
OX; |
| 21 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OB
JECTBOUNDINGBOX); |
| 22 assert_equals(filterElement.getAttribute('filterUnits'), "objectBoundingBox"); |
| 23 |
| 24 // Try setting invalid values. |
| 25 assert_throws(new TypeError(), function() { filterElement.filterUnits.baseVal
= 3; }); |
| 26 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OB
JECTBOUNDINGBOX); |
| 27 assert_equals(filterElement.getAttribute('filterUnits'), "objectBoundingBox"); |
| 28 |
| 29 assert_throws(new TypeError(), function() { filterElement.filterUnits.baseVal
= -1; }); |
| 30 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OB
JECTBOUNDINGBOX); |
| 31 assert_equals(filterElement.getAttribute('filterUnits'), "objectBoundingBox"); |
| 32 |
| 33 assert_throws(new TypeError(), function() { filterElement.filterUnits.baseVal
= 0; }); |
| 34 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_OB
JECTBOUNDINGBOX); |
| 35 assert_equals(filterElement.getAttribute('filterUnits'), "objectBoundingBox"); |
| 36 |
| 37 // Switch to 'userSpaceOnUse'. |
| 38 filterElement.filterUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE; |
| 39 assert_equals(filterElement.filterUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE_US
ERSPACEONUSE); |
| 40 assert_equals(filterElement.getAttribute('filterUnits'), "userSpaceOnUse"); |
| 41 |
| 42 // primitiveUnits |
| 43 // Check initial 'primitiveUnits' value. |
| 44 assert_true(filterElement.primitiveUnits instanceof SVGAnimatedEnumeration); |
| 45 assert_equals(typeof(filterElement.primitiveUnits.baseVal), "number"); |
| 46 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_USERSPACEONUSE); |
| 47 |
| 48 // Switch to 'objectBoundingBox'. |
| 49 filterElement.primitiveUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDI
NGBOX; |
| 50 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_OBJECTBOUNDINGBOX); |
| 51 assert_equals(filterElement.getAttribute('primitiveUnits'), "objectBoundingBox
"); |
| 52 |
| 53 // Try setting invalid values. |
| 54 assert_throws(new TypeError(), function() { filterElement.primitiveUnits.baseV
al = 3; }); |
| 55 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_OBJECTBOUNDINGBOX); |
| 56 assert_equals(filterElement.getAttribute('primitiveUnits'), "objectBoundingBox
"); |
| 57 |
| 58 assert_throws(new TypeError(), function() { filterElement.primitiveUnits.baseV
al = -1; }); |
| 59 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_OBJECTBOUNDINGBOX); |
| 60 assert_equals(filterElement.getAttribute('primitiveUnits'), "objectBoundingBox
"); |
| 61 |
| 62 assert_throws(new TypeError(), function() { filterElement.primitiveUnits.baseV
al = 0; }); |
| 63 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_OBJECTBOUNDINGBOX); |
| 64 assert_equals(filterElement.getAttribute('primitiveUnits'), "objectBoundingBox
"); |
| 65 |
| 66 // Switch to 'userSpaceOnUse'. |
| 67 filterElement.primitiveUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONU
SE; |
| 68 assert_equals(filterElement.primitiveUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYPE
_USERSPACEONUSE); |
| 69 assert_equals(filterElement.getAttribute('primitiveUnits'), "userSpaceOnUse"); |
| 70 }); |
| 71 </script> |
OLD | NEW |