Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / input / scroll-viewport-page-up-down.html
blob71c1cc3d86e952003d08167ba4ad449a63e18edb
1 <head>
2 <script src="../../resources/ahem.js"></script>
3 <style type="text/css">
4 .ahem { font: 20px Ahem; }
5 </style>
6 <script>
8 if (window.testRunner)
9 testRunner.dumpAsText();
11 var onMacPlatform = navigator.userAgent.search(/\bMac OS X\b/) != -1;
13 function runTest() {
14 runFrameScrollTest();
15 runDivScrollTest();
18 function generateContent() {
19 var content = "";
20 for (var i = 0; i < 10; ++i)
21 content += "<p>line " + i + "</p>\n";
22 return content;
25 function runFrameScrollTest() {
26 var frame = frames[0];
27 var doc = frame.document;
28 var body = doc.body;
29 body.innerHTML = generateContent();
30 frame.focus();
31 frame.getSelection().collapse(body.firstChild, 0);
32 if (onMacPlatform)
33 offsets = [ 55, 175 ];
34 else
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();
42 editable.focus();
43 window.getSelection().collapse(editable, 0);
44 if (onMacPlatform)
45 offsets = [ 75, 195 ];
46 else
47 offsets = [ 140, 260 ];
48 runScrollingTest("div", editable, offsets, function() { return editable.scrollTop; });
51 function runScrollingTest(testName, frame, offsets, scrollFunction) {
52 var tolerance = 0;
53 var modifiers = onMacPlatform ? ["altKey"] : [];
55 if (!window.eventSender)
56 return;
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/>";
78 </script>
79 </head>
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>
90 </body>