| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <style> |
| 6 div { |
| 7 /* Must be a font that causes fallback for Arabic. |
| 8 'MS PGothic' for Windows, TakaoPGothic for Linux, Times for Mac. */ |
| 9 font-family: 'MS PGothic', TakaoPGothic, Times; |
| 10 } |
| 11 |
| 12 .PASS { |
| 13 background-color: lime; |
| 14 } |
| 15 |
| 16 .FAIL { |
| 17 background-color: red; |
| 18 } |
| 19 </style> |
| 20 <div id="container"> |
| 21 <div id="ltr">'ص</div> |
| 22 <div id="rtl" dir="rtl">'ص</div> |
| 23 </div> |
| 24 <script> |
| 25 Array.prototype.forEach.call(container.children, function (element) { |
| 26 test(function () { |
| 27 var textNode = element.firstChild; |
| 28 var width0 = getWidth(textNode, 0); |
| 29 var width1 = getWidth(textNode, 1); |
| 30 element.className = width0 < width1 ? "PASS" : "FAIL"; |
| 31 assert_less_than(width0, width1); |
| 32 }, element.id); |
| 33 }); |
| 34 |
| 35 function getWidth(node, offset) { |
| 36 var range = document.createRange(); |
| 37 range.setStart(node, offset); |
| 38 range.setEnd(node, offset + 1); |
| 39 var rect = range.getBoundingClientRect(); |
| 40 return rect.width; |
| 41 } |
| 42 |
| 43 if (window.testRunner) |
| 44 container.style.display = "none"; |
| 45 </script> |
| OLD | NEW |