| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <script> |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| function getPositionOfNode(id) |
| { |
| var n = document.getElementById(id); |
| var pos = {x: 0, y: 0}; |
| |
| while (n) { |
| pos.x += n.offsetLeft + n.clientLeft; |
| pos.y += n.offsetTop + n.clientTop; |
| n = n.offsetParent; |
| } |
| return pos; |
| } |
| |
| function doubleClickNode(id, offset) |
| { |
| var pos = getPositionOfNode(id); |
| eventSender.mouseMoveTo(pos.x + offset, pos.y + 2); |
| eventSender.mouseDown(); |
| eventSender.leapForward(1); |
| eventSender.mouseUp(); |
| eventSender.leapForward(100); |
| eventSender.mouseDown(); |
| eventSender.leapForward(1); |
| eventSender.mouseUp(); |
| } |
| |
| function doTest(testId, offset, expectedText) |
| { |
| // Simulate a double click. |
| doubleClickNode(testId, offset); |
| |
| // Get the text of the current selection. |
| var sel = window.getSelection(); |
| var actualText = sel.getRangeAt(0).toString(); |
| |
| if (expectedText == actualText) { |
| log("Passed for offset " + offset); |
| } else { |
| log("Failed for offset " + offset); |
| log(" Expected: " + expectedText); |
| log(" Actual: " + actualText); |
| } |
| |
| } |
| |
| function runTests() |
| { |
| if (window.testRunner) { |
| doTest("test1", 55, "オーストラリア"); |
| doTest("test1", 70, "オーストラリア"); |
| doTest("test1", 85, "オーストラリア"); |
| doTest("test1", 100, "オーストラリア"); |
| doTest("test1", 115, "オーストラリア"); |
| doTest("test1", 130, "オーストラリア"); |
| } |
| } |
| |
| function log(msg) |
| { |
| var l = document.getElementById('log'); |
| l.appendChild(document.createTextNode(msg)); |
| l.appendChild(document.createElement('br')); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTests()"> |
| <p> |
| This tests that double-clicking on Japanese text. |
| </p> |
| |
| <div> |
| <span id=test1>例えばオーストラリア</span> |
| </div> |
| |
| <pre id=log> |
| </pre> |
| |
| </body> |
| </html> |