2 <script src=
"../../resources/ahem.js"></script>
3 <style type=
"text/css">
4 .ahem { font: 20px Ahem
; }
9 testRunner
.dumpAsText();
11 var onMacPlatform
= navigator
.userAgent
.search(/\bMac OS X\b/) != -1;
18 function generateContent() {
20 for (var i
= 0; i
< 10; ++i
)
21 content
+= "<p>line " + i
+ "</p>\n";
25 function runFrameScrollTest() {
26 var frame
= frames
[0];
27 var doc
= frame
.document
;
29 body
.innerHTML
= generateContent();
31 frame
.getSelection().collapse(body
.firstChild
, 0);
33 offsets
= [ 55, 175 ];
35 offsets
= [ 120, 240 ];
36 runScrollingTest("iframe", frame
, offsets
, function() { return frame
.pageYOffset
; });
39 function runDivScrollTest() {
40 var editable
= document
.getElementById('editable');
41 editable
.innerHTML
= generateContent();
43 window
.getSelection().collapse(editable
, 0);
45 offsets
= [ 75, 195 ];
47 offsets
= [ 140, 260 ];
48 runScrollingTest("div", editable
, offsets
, function() { return editable
.scrollTop
; });
51 function runScrollingTest(testName
, frame
, offsets
, scrollFunction
) {
53 var modifiers
= onMacPlatform
? ["altKey"] : [];
55 if (!window
.eventSender
)
58 eventSender
.keyDown("pageDown", modifiers
);
59 if (Math
.abs(scrollFunction() - offsets
[0]) > tolerance
) {
60 throw "Frame viewport should be around " + offsets
[0] +
61 "px , not at " + scrollFunction();
64 eventSender
.keyDown("pageDown", modifiers
);
65 if (Math
.abs(scrollFunction() - offsets
[1]) > tolerance
) {
66 throw "Frame viewport should be around " + offsets
[1] +
67 "px , not " + scrollFunction();
70 eventSender
.keyDown("pageUp", modifiers
);
71 if (Math
.abs(scrollFunction() - offsets
[0]) > tolerance
) {
72 throw "Frame viewport should be around " + offsets
[0] +
73 "px , not at " + scrollFunction();
76 document
.getElementById("results").innerHTML
+= testName
+ " PASS<br/>";
80 <body onload=
"runTest()">
81 <div>Page up/down (option+page up/down on Mac) should move the move cursor and scroll the content
82 in contenteditable elements. This sample covers scroll position test of a) iframe element containing
83 contenteditable body and b) content editable div element. Even though the cursor will move exactly to
84 the same location on all platforms (covered by test option-page-up-down.html), please note that Mac will
85 scroll the visible area by placing the cursor position in the middle. All other platforms will scroll by
86 keeping the cursor aligned with the top edge of the visible area.
</div>
87 <iframe src=
"../resources/contenteditable-iframe-fixed-size-src.html" style=
"height:150px; padding: 0px;"></iframe>
88 <div id=
"editable" contenteditable=
"true" class=
"ahem" style=
"height:150px; overflow:auto; padding: 0px; margin: 0px;"></div>
89 <div id=
"results"></div>