OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <title>SVGAnimatedNumber interface - utilizing the surfaceScale property of SVGF
ESpecularLightingElement</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 SVGAnimatedNumber API - utilizing the surfaceScale pro
perty of SVGFESpecularLightingElement. |
8 <div id="console"></div> | 8 |
9 <script src="script-tests/SVGAnimatedNumber.js"></script> | 9 var feSpecularLightingElement = document.createElementNS("http://www.w3.org/20
00/svg", "feSpecularLighting"); |
10 </body> | 10 |
11 </html> | 11 // Check initial surfaceScale value. |
| 12 assert_true(feSpecularLightingElement.surfaceScale instanceof SVGAnimatedNumbe
r); |
| 13 assert_equals(typeof(feSpecularLightingElement.surfaceScale.baseVal), "number"
); |
| 14 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 1); |
| 15 |
| 16 // Check that integers are static, caching value in a local variable and modif
ying it, should have no effect. |
| 17 var numRef = feSpecularLightingElement.surfaceScale.baseVal; |
| 18 numRef = 100; |
| 19 assert_equals(numRef, 100); |
| 20 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 1); |
| 21 |
| 22 // Check assigning various valid and invalid values. |
| 23 feSpecularLightingElement.surfaceScale.baseVal = -1; // Negative values are al
lowed from SVG DOM, but should lead to an error when rendering (disable the filt
er) |
| 24 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, -1); |
| 25 feSpecularLightingElement.surfaceScale.baseVal = 300; |
| 26 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 300); |
| 27 |
| 28 // ECMA-262, 9.3, "ToNumber" |
| 29 assert_throws(new TypeError(), function() { feSpecularLightingElement.surfaceS
cale.baseVal = 'aString'; }); |
| 30 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 300); |
| 31 feSpecularLightingElement.surfaceScale.baseVal = 0; |
| 32 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 0); |
| 33 assert_throws(new TypeError(), function() { feSpecularLightingElement.surfaceS
cale.baseVal = NaN; }); |
| 34 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 0); |
| 35 assert_throws(new TypeError(), function() { feSpecularLightingElement.surfaceS
cale.baseVal = Infinity; }); |
| 36 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 0); |
| 37 assert_throws(new TypeError(), function() { feSpecularLightingElement.surfaceS
cale.baseVal = feSpecularLightingElement; }); |
| 38 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 0); |
| 39 feSpecularLightingElement.surfaceScale.baseVal = 300; |
| 40 assert_equals(feSpecularLightingElement.surfaceScale.baseVal, 300); |
| 41 }); |
| 42 </script> |
OLD | NEW |