Bug 1879774 [wpt PR 44524] - WebKit export: Implement field-sizing support for input...
[gecko.git] / layout / generic / test / test_selection_doubleclick.html
blob54e472b8b833d5c6cf416da02fb3c3cd3822d7e8
1 <!DOCTYPE>
2 <html>
3 <head>
4 <title>selection preventDefault test</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script src="/tests/SimpleTest/EventUtils.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
10 <body>
11 <div id="wbrs" class="testingDiv">
12 abc<wbr>def<br>
13 ghi<wbr>jkl<br>
14 mno<wbr>pqr<br>
15 </div>
17 <p id="paragraphWbr">
18 abc<wbr>def<wbr>ghi<wbr>jkl<wbr>mno<wbr>pqr
19 </p>
21 <pre id="test">
22 <script class="testbody" type="text/javascript">
24 function test()
26 const kLF = !navigator.platform.indexOf("Win") ? "\r\n" : "\n";
27 const isMac = navigator.platform.indexOf("Mac") >= 0;
28 const combinators = isMac ? {shiftKey: true, altKey: true}
29 : {shiftKey: true, accelKey: true};
31 var wbrElement = document.getElementById("wbrs");
33 //double clicking selects across wbr elements.
34 synthesizeMouse(wbrElement, 5, 5, { clickCount: 2 });
35 var selectedText = window.getSelection().toString();
36 console.log(selectedText);
37 is(selectedText,"abcdef", "Select across WBR elements with double click: OK");
39 //selecting first letter of wbr element and using shift + arrowRight selects across wbr elements.
40 synthesizeMouse(wbrElement, 1, 5, { type: "mousedown" });
41 synthesizeMouse(wbrElement, 2, 5, { type: "mousemove" });
42 synthesizeMouse(wbrElement, 2, 5, { type: "mouseup" });
43 synthesizeKey("KEY_ArrowRight", {shiftKey:true});
44 synthesizeKey("KEY_ArrowRight", {shiftKey:true});
45 synthesizeKey("KEY_ArrowRight", {shiftKey:true});
46 synthesizeKey("KEY_ArrowRight", {shiftKey:true});
47 var selectedText = window.getSelection().toString();
48 console.log(selectedText);
49 is(selectedText, "abcd", "Select across WBR elements using shift and right arrow: OK");
51 //selection using ctrl + shift + rightArrow selects across wbr elements
52 synthesizeMouse(wbrElement, 1, 5, { type: "mousedown" });
53 synthesizeMouse(wbrElement, 2, 5, { type: "mousemove" });
54 synthesizeMouse(wbrElement, 2, 5, { type: "mouseup" });
55 synthesizeKey("KEY_ArrowRight", combinators);
56 var selectedText = window.getSelection().toString();
57 console.log(selectedText);
58 is(selectedText, "abcdef", "Select across WBR elements using shift + ctrl + right arrow: OK");
60 //selection using ctrl + shift + rightArrow selects across wbr and br elements
61 synthesizeMouse(wbrElement, 1, 5, { type: "mousedown" });
62 synthesizeMouse(wbrElement, 2, 5, { type: "mousemove" });
63 synthesizeMouse(wbrElement, 2, 5, { type: "mouseup" });
64 synthesizeKey("KEY_ArrowRight", combinators);
65 synthesizeKey("KEY_ArrowRight", combinators);
66 var selectedText = window.getSelection().toString();
67 console.log(selectedText);
68 is(selectedText, "abcdef" + kLF + "ghijkl", "Select across WBR elements using shift + ctrl + right arrow: OK");
70 //double clicking on a paragraph selects across wbr elements
71 var paragraphWbr = document.getElementById("paragraphWbr");
72 synthesizeMouse(paragraphWbr, 5, 5, { clickCount: 2 });
73 var selectedText = window.getSelection().toString();
74 console.log(selectedText);
75 is(selectedText,"abcdefghijklmnopqr", "Select across WBR elements in paragraph with double click: OK");
77 SimpleTest.finish();
79 window.onload = function() {
80 SpecialPowers.pushPrefEnv({
81 set: [
82 // Prevent whitespace between lines from being selected.
83 ["layout.word_select.eat_space_to_next_word", false],
85 }).then(() => {
86 setTimeout(test, 0);
87 });
89 SimpleTest.waitForExplicitFinish();
90 </script>
91 </pre>
92 </body>
93 </html>