4 if (window
.testRunner
) {
5 testRunner
.dumpAsText();
6 internals
.settings
.setSmartInsertDeleteEnabled(false);
7 internals
.settings
.setSelectTrailingWhitespaceEnabled(true);
10 function getPositionOfNode(id
)
12 var n
= document
.getElementById(id
);
13 var pos
= {x
: 0, y
: 0};
16 pos
.x
+= n
.offsetLeft
+ n
.clientLeft
;
17 pos
.y
+= n
.offsetTop
+ n
.clientTop
;
23 function doubleClickNode(id
)
25 var pos
= getPositionOfNode(id
);
26 eventSender
.mouseMoveTo(pos
.x
+ 2, pos
.y
+ 2);
27 eventSender
.mouseDown();
28 eventSender
.leapForward(1);
29 eventSender
.mouseUp();
30 eventSender
.leapForward(100);
31 eventSender
.mouseDown();
32 eventSender
.leapForward(1);
33 eventSender
.mouseUp();
36 function doTest(testId
, expectedText
)
38 // Simulate a double click.
39 doubleClickNode(testId
);
41 // Get the text of the current selection.
42 var sel
= window
.getSelection();
43 var actualText
= sel
.getRangeAt(0).toString();
45 if (expectedText
== actualText
) {
46 log("Passed " + testId
);
48 log("Failed " + testId
);
49 log(" Expected: " + expectedText
);
50 log(" Actual: " + actualText
);
57 if (window
.testRunner
) {
58 doTest("test1", "Doubleclickme \u00a0\u00a0\u00a0 ");
59 doTest("test2", "Doubleclickme");
60 doTest("test3", "Doubleclickme \u00a0\u00a0 ");
61 doTest("test4", "Doubleclickme");
62 doTest("test5", "Doubleclickme \u00a0\u00a0");
63 doTest("test6", "Doubleclickme \u00a0\t\t\t\u00a0");
69 var l
= document
.getElementById('log');
70 l
.appendChild(document
.createTextNode(msg
));
71 l
.appendChild(document
.createElement('br'));
76 <body onload=
"runTests()">
78 This tests that double-clicking a word on the Windows platform selects the whitespace after the word.
82 <span id=test1
>Doubleclickme
|END|
</span>
86 <span id=test2
>Doubleclickme|END|
</span>
90 <span id=test3
>Doubleclickme
</span>
96 <span id=
"test4">Doubleclickme
</span>
98 |(Should not have been extended into this line)|
102 <span id=
"test5">Doubleclickme
</span> <img src=
"does-not-exist.png" />
106 <span id=
"test6">Doubleclickme
</span> |END|