| <!DOCTYPE html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../assert_selection.js"></script> |
| <script> |
| // This tests the anchorNode, anchorOffset, focusNode and focusOffset properties |
| // of the Selection object. These properties are part of Mozilla's Selection |
| // object API, and so their values should be consistent in both browsers. |
| |
| selection_test( |
| '<div style="border: 1px solid blue; padding: 1em;"><span id="test">text</span></div>', |
| selection => { |
| assert_not_equals( |
| window.eventSender, undefined, |
| 'This test requires window.eventSender to simulate mouse clicks'); |
| |
| const document = selection.document; |
| const elem = document.getElementById('test'); |
| |
| // x, y should be in the middle of elem. |
| const x = selection.computeLeft(elem) + elem.offsetWidth / 2; |
| const y = selection.computeTop(elem) + elem.offsetHeight / 2; |
| |
| eventSender.mouseMoveTo(x, y); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| }, |
| '<div style="border: 1px solid blue; padding: 1em;"><span id="test">^text|</span></div>', |
| 'Anchor and focus of selection set by doubleclicking'); |
| </script> |