| <!DOCTYPE html> |
| <title>SVGTextContentElement.getSubStringLength</title> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <div id=log></div> |
| <div> |
| <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> |
| <text x="10" y="20">W3C نشاط</text> |
| <text x="10 50" y="40">AB</text> |
| </svg> |
| </div> |
| <script> |
| test(function() { |
| var text = document.querySelector('text'); |
| assert_equals(text.getNumberOfChars(), 8); |
| var lenFirst4 = text.getSubStringLength(0, 4); |
| var lenLast4 = text.getSubStringLength(4, 4); |
| var lenAll = text.getSubStringLength(0, 8); |
| assert_approx_equals(lenFirst4 + lenLast4, lenAll, 0.01, 'Sum of the parts equal the total.'); |
| }, document.title+', BiDi.'); |
| test(function() { |
| var text = document.querySelector('text + text'); |
| assert_equals(text.getNumberOfChars(), 2); |
| var lenFirst = text.getSubStringLength(0, 1); |
| var lenLast = text.getSubStringLength(1, 1); |
| var lenAll = text.getSubStringLength(0, 2); |
| assert_approx_equals(lenFirst + lenLast, lenAll, 0.01, 'Sum of the parts equal the total.'); |
| }, document.title+', multiple text-chunks.'); |
| </script> |