iframe and scrollbar with "overflow:auto" should support autoscroll with mousedrag
[WebKit-https.git] / LayoutTests / fast / events / drag-and-drop-autoscroll-inner-frame.html
1 <!DOCTYPE html>
2 <head>
3 <style type="text/css">
4 #scrollable {
5     height: 200px;
6     overflow: auto;
7     border: solid 3px #cc0000;
8     font-size: 80px;
9 }
10 </style>
11 <script>
12
13 var x, y, middleTermScrollOffset;
14 var iframe, iframeDocument, draggable;
15
16 function setUpTest()
17 {
18     if (!window.eventSender) {
19         log('Please run within DumpRenderTree');
20         return;
21     }
22
23     window.internals.settings.setAutoscrollForDragAndDropEnabled(true);
24     testRunner.waitUntilDone();
25     testIt();
26 }
27
28 function testIt()
29 {
30     eventSender.dragMode = false;
31
32     iframe = document.getElementById('scrollable');
33     iframeDocument = iframe.contentDocument;
34     draggable = iframeDocument.getElementById('draggable');
35
36     iframeDocument.addEventListener("scroll", recordScroll);
37
38     // Grab draggable.
39     x = iframe.offsetLeft + draggable.offsetLeft + 7;
40     y = iframe.offsetTop + draggable.offsetTop + 7;
41
42     eventSender.mouseMoveTo(x, y);
43     eventSender.mouseDown();
44
45     // Move mouse to the bottom autoscroll border belt.
46     y = iframe.offsetTop + iframe.offsetHeight - 10;
47     eventSender.mouseMoveTo(x, y);
48 }
49
50 function recordScroll(e)
51 {
52     iframeDocument.removeEventListener("scroll", recordScroll);
53     autoscrollTestPart1();
54 }
55
56 function recordScroll2(e)
57 {
58     iframeDocument.removeEventListener("scroll", recordScroll2);
59     autoscrollTestPart2();
60 }
61
62 function autoscrollTestPart1()
63 {
64     if (iframe.contentDocument.body.scrollTop == 0) {
65         testFailed("Autoscroll should have scrolled the iframe downwards, but did not");
66         finishTest();
67         return;
68     }
69
70     testPassed("Autoscroll should have scrolled the iframe downwards, and did.");
71     eventSender.mouseUp();
72     iframeDocument.addEventListener("scroll", recordScroll2);
73
74     middleTermScrollOffset = iframe.contentDocument.body.scrollTop;
75
76     // Grab draggable.
77     x = iframe.offsetLeft + draggable.offsetLeft + 7;
78     y = iframe.offsetTop + draggable.offsetTop + 7 - iframe.contentDocument.body.scrollTop ;
79
80     // Move mouse to the upper autoscroll border belt.
81     eventSender.mouseMoveTo(x, y);
82     eventSender.mouseDown();
83
84     y = iframe.offsetTop + 10;
85     eventSender.mouseMoveTo(x, y);
86 }
87
88 function autoscrollTestPart2()
89 {
90     shouldBeTrue("iframe.contentDocument.body.scrollTop < middleTermScrollOffset")
91     finishTest();
92 }
93
94 function finishTest()
95 {
96     eventSender.mouseUp();
97     testRunner.notifyDone();
98 }
99
100 </script>
101 </head>
102 <body>
103 For manual testing, drag and drop "Drop Me" downwards and then upwards.
104 <iframe id="scrollable" src="resources/iframe-drag-and-drop-autoscroll.html"></iframe><br>
105 </div>
106 <div id="console"></div>
107 <script src="../../resources/js-test-pre.js"></script>
108 <script>
109 description('Check autoscroll within an inner frame by drag-and-drop');
110 </script>
111 <script src="../../resources/js-test-post.js"></script>
112 </body>
113 </html>