Index: LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html |
diff --git a/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html b/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..45448ae98fc1457273abf7e9131585b66c34e288 |
--- /dev/null |
+++ b/LayoutTests/fast/events/drag-and-drop-autoscroll-inner-frame.html |
@@ -0,0 +1,123 @@ |
+<!DOCTYPE html> |
+<head> |
+<style type="text/css"> |
+#scrollable { |
+ height: 200px; |
+ overflow: auto; |
+ border: solid 3px #cc0000; |
+ font-size: 80px; |
+} |
+</style> |
+<script> |
+ |
+function finishTest() |
+{ |
+ eventSender.mouseUp(); |
+ window.testRunner.notifyDone(); |
+} |
+ |
+var x, y, middleTermScrollOffset; |
+var iframe, iframeDocument, draggable; |
+ |
+function log(msg) |
+{ |
+ document.getElementById('console').appendChild(document.createTextNode(msg + '\n')); |
+} |
+ |
+function testIt() |
+{ |
+ if (!window.eventSender) |
Julien - ping for review
2013/09/09 23:13:14
We don't get here if !window.eventSender as setTim
|
+ return; |
+ |
+ eventSender.dragMode = false; |
+ |
+ iframe = document.getElementById('scrollable'); |
+ iframeDocument = iframe.contentDocument; |
+ draggable = iframeDocument.getElementById('draggable'); |
+ |
+ iframeDocument.addEventListener("scroll", recordScroll); |
+ |
+ // Grab draggable. |
+ x = iframe.offsetLeft + draggable.offsetLeft + 7; |
+ y = iframe.offsetTop + draggable.offsetTop + 7; |
+ |
+ eventSender.mouseMoveTo(x, y); |
+ eventSender.mouseDown(); |
+ |
+ // Move mouse to the bottom autoscroll border belt. |
+ y = iframe.offsetTop + iframe.offsetHeight - 10; |
+ eventSender.mouseMoveTo(x, y); |
+} |
+ |
+function recordScroll(e) |
+{ |
+ autoscrollTestPart1(); |
+ iframeDocument.removeEventListener("scroll", recordScroll); |
+} |
+ |
+function recordScroll2(e) |
+{ |
+ autoscrollTestPart2(); |
+ iframeDocument.removeEventListener("scroll", recordScroll); |
+} |
+ |
+function autoscrollTestPart1() |
+{ |
+ if (iframe.contentDocument.body.scrollTop > 0) { |
Julien - ping for review
2013/09/09 23:13:14
Nit: I would flip the logic to do the failing case
|
+ middleTermScrollOffset = iframe.contentDocument.body.scrollTop; |
+ |
+ iframeDocument.addEventListener("scroll", recordScroll2); |
+ |
+ // Move mouse to the upper autoscroll border belt. |
+ y = iframe.offsetTop + 10; |
+ eventSender.mouseMoveTo(x, y); |
+ |
+ log("Passed: Autoscroll should have scrolled the iframe downwards, and did."); |
yosin_UTC9
2013/09/10 02:09:38
We should use testPassed(), e.g. testPassed('Autos
|
+ return; |
+ } |
+ |
+ log("Failed: Autoscroll should have scrolled the iframe downwards, but did not."); |
yosin_UTC9
2013/09/10 02:09:38
We should use testFailed(), e.g. testFailed('Autos
|
+ finishTest(); |
+} |
+ |
+function autoscrollTestPart2() |
+{ |
+ if (iframe.contentDocument.body.scrollTop < middleTermScrollOffset) |
yosin_UTC9
2013/09/10 02:09:38
We should use shouldBeTrue(), e.g. shouldBeTrue('i
|
+ log("Passed: Autoscroll should have scrolled the iframe upwards, and did."); |
+ else |
+ log("Failed: Autoscroll should have scrolled the iframe upwards, but did not."); |
+ |
+ finishTest(); |
+} |
+ |
+function setUpTest() |
+{ |
+ if (!window.eventSender) { |
+ console.log('Please run within DumpRenderTree'); |
+ return; |
+ } |
+ |
+ window.jsTestIsAsync = true; |
+ setTimeout(testIt, 0); |
yosin_UTC9
2013/09/10 02:09:38
We should start test window.onload rather than tim
|
+} |
+</script> |
+</head> |
+<body> |
+For manual testing, drag and drop "Drop Me" to downwards and then upwards. |
+<iframe id="scrollable" src="data:text/html, |
+<p id='draggable' draggable='true' style='cursor: hand;'> |
+ <b>Drag me!</b> |
+</p> |
+Try to drag and drop the text above in the input element at the bottom of this iframe. It should scroll. Then, try the way back. |
+<br><br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br>more<br><input> |
+"></iframe><br> |
+</div> |
+<div id="console"></div> |
+<script src="../js/resources/js-test-pre.js"></script> |
+<script> |
+description('Check autoscroll within an inner frame by drag-and-drop'); |
+setUpTest(); |
+</script> |
+<script src="../js/resources/js-test-post.js"></script> |
+</body> |
+</html> |