Move /platform/ios-simulator/accessibility tests to accessibility/ios-simulator/
[WebKit-https.git] / LayoutTests / tiled-drawing / scrolling / iframe_in_iframe.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <title>iFrame in iFrame Test</title>
5         <style>
6         * {
7             box-sizing: border-box;
8         }
9
10         .container {
11             width:100%;
12             overflow:auto;
13             height:auto;
14         }
15
16         .innercontainer {
17             height:100%;
18             width:50%;
19         }
20         </style>
21         <script src="../../resources/js-test-pre.js"></script>
22     </head>
23     <body>
24 <script>
25
26 var iframeTarget;
27 var innerIFrameTarget;
28 var pageScrollPositionBefore;
29 var iFrameScrollPositionBefore;
30 var continueCount = 5;
31
32 function checkForScroll()
33 {
34     // The IFrame should not have scrolled at all.
35     var pageScrollPositionAfter = document.body.scrollTop;
36     var iFrameScrollPositionAfter = window.frames['target'].document.body.scrollTop;
37     var innerIFrameScrollPositionAfter = iframeTarget.contentWindow.frames['target'].document.body.scrollTop;
38
39     if (pageScrollPositionBefore != pageScrollPositionAfter)
40         testFailed("Page received wheel events.");
41     else
42         testPassed("Page did not receive wheel events.");
43
44     if (iFrameScrollPositionBefore != iFrameScrollPositionAfter)
45         testFailed("iframe received wheel events.");
46     else
47         testPassed("iframe did not receive wheel events.");
48
49     if (innerIFrameScrollPositionBefore != innerIFrameScrollPositionAfter)
50         testPassed("iframe received wheel events.");
51     else
52         testFailed("iframe did not receive wheel events.");
53
54     finishJSTest();
55     testRunner.notifyDone();
56 }
57
58 function scrollTest()
59 {
60     pageScrollPositionBefore = document.body.scrollTop;
61
62     iframeTarget = document.getElementById('target');
63
64     var iFrameBody = window.frames['target'].document.body;
65     iFrameScrollPositionBefore = iFrameBody.scrollTop;
66
67     innerIFrameTarget = iframeTarget.contentWindow.frames['target'].document.body;
68     innerIFrameScrollPositionBefore = innerIFrameTarget.scrollTop;
69
70     // Scroll the #source until we reach the #target.
71     var startPosX = Math.round(iframeTarget.offsetLeft) + 20;
72     var startPosY = Math.round(iframeTarget.offsetTop) + 80;
73     eventSender.mouseMoveTo(startPosX, startPosY);
74     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
75     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
76     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
77     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
78     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
79     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
80     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
81     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
82     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
83     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
84     eventSender.callAfterScrollingCompletes(checkForScroll);
85 }
86
87 function setupTopLevel()
88 {
89     if (window.eventSender) {
90         testRunner.dumpAsText();
91         testRunner.waitUntilDone();
92
93         eventSender.monitorWheelEvents();
94         setTimeout(scrollTest, 0);
95     }
96 }
97 </script>
98         <div class="container">
99             <div class="innercontainer">
100                 <div style="width:100%;">
101                     <div>Inner Frame:</div>
102                     <div style="height:92%;">
103                         <iframe id="target" name="target" src="resources/testContent.html" onload="setupTopLevel();"></iframe>
104                     </div>
105                 </div>
106             </div>
107         </div>
108         <div id="console"></div>
109         <script>
110         description("Tests that iframe doesn't pass wheel events to main frame when scrolling inside iframe");
111         </script>
112         <script src="../../resources/js-test-post.js"></script>
113     </body>
114 </html>