OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <title>SVGAnimatedEnumeration interface - utilizing the clipPathUnits property o
f SVGClipPathElement</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 SVGAnimatedEnumeration API - utilizing the clipPathUni
ts property of SVGClipPathElement. |
8 <div id="console"></div> | 8 |
9 <script src="script-tests/SVGAnimatedEnumeration.js"></script> | 9 var clipPathElement = document.createElementNS("http://www.w3.org/2000/svg", "
clipPath"); |
10 </body> | 10 |
11 </html> | 11 // Check initial clipPathUnits value. |
| 12 assert_true(clipPathElement.clipPathUnits instanceof SVGAnimatedEnumeration); |
| 13 assert_equals(typeof(clipPathElement.clipPathUnits.baseVal), "number"); |
| 14 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 15 |
| 16 // Check that enumerations are static, caching value in a local variable and m
odifying it, should have no effect. |
| 17 var enumRef = clipPathElement.clipPathUnits.baseVal; |
| 18 enumRef = SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; |
| 19 assert_equals(enumRef, SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); |
| 20 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 21 |
| 22 // Check assigning various valid and invalid values. |
| 23 assert_throws(new TypeError(), function() { clipPathElement.clipPathUnits.base
Val = 3; }); |
| 24 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 25 assert_throws(new TypeError(), function() { clipPathElement.clipPathUnits.base
Val = -1; }); |
| 26 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 27 |
| 28 // ECMA-262, 9.7, "ToUint16" |
| 29 clipPathElement.clipPathUnits.baseVal = '1'; |
| 30 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 31 |
| 32 // ECMA-262, 9.7, "ToUint16" |
| 33 assert_throws(new TypeError(), function() { clipPathElement.clipPathUnits.base
Val = 'aString'; }); |
| 34 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_USERSPACEONUSE); |
| 35 |
| 36 clipPathElement.clipPathUnits.baseVal = 2; |
| 37 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_OBJECTBOUNDINGBOX); |
| 38 assert_throws(new TypeError(), function() { clipPathElement.clipPathUnits.base
Val = clipPathElement; }); |
| 39 assert_equals(clipPathElement.clipPathUnits.baseVal, SVGUnitTypes.SVG_UNIT_TYP
E_OBJECTBOUNDINGBOX); |
| 40 }); |
| 41 </script> |
OLD | NEW |