2 <script src=
"../../resources/js-test.js"></script>
6 <li>Double click at
"hello" or
"world".
</li>
7 <li>You see selection where you double clicked.
</li>
9 <div id=
"sample" contenteditable
>hello world
</div>
12 description('Double click to select word should work with DOM modification by click event handler.');
13 var sample
= document
.getElementById('sample');
14 var selection
= getSelection();
15 sample
.addEventListener('click', function() {
16 if (!selection
.rangeCount
)
18 selection
.getRangeAt(0).insertNode(document
.createElement('span'));
20 if (window
.eventSender
) {
21 eventSender
.mouseMoveTo(sample
.offsetLeft
+ 10, sample
.offsetTop
+ 1);
22 eventSender
.mouseDown();
23 eventSender
.mouseUp();
24 eventSender
.mouseDown();
25 eventSender
.mouseUp();
26 // To make this platform independent, we use |trim()| for checking selected
27 // word, e.g. Windows selects word with a trailing space, but Mac selects
29 shouldBeEqualToString('selection.toString().trim()', 'hello');
30 document
.getElementById('container').outerHTML
= '';