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" />
11 <div id=
"wbrs" class=
"testingDiv">
18 abc
<wbr>def
<wbr>ghi
<wbr>jkl
<wbr>mno
<wbr>pqr
22 <script class=
"testbody" type=
"text/javascript">
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");
79 window.onload = function() {
80 SpecialPowers.pushPrefEnv({
82 // Prevent whitespace between lines from being selected.
83 [
"layout.word_select.eat_space_to_next_word", false],
89 SimpleTest.waitForExplicitFinish();