| <!DOCTYPE html> |
| <html> |
| <head> |
| <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent"> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script> |
| window.jsTestIsAsync = true; |
| |
| var iframeTarget; |
| var pageScrollPositionBefore; |
| var iFrameScrollPositionBefore; |
| var continueCount = 5; |
| |
| var wheelCount = 0; |
| function onScrollWheel(evt) |
| { |
| wheelCount = wheelCount + 1; |
| } |
| |
| function checkForScroll() |
| { |
| // The iframe should not have scrolled at all. |
| var pageScrollPositionAfter = document.scrollingElement.scrollTop; |
| var iFrameScrollPositionAfter = window.frames['target'].document.scrollingElement.scrollTop; |
| |
| if (pageScrollPositionBefore != pageScrollPositionAfter) |
| testFailed("Page received wheel events."); |
| else |
| testPassed("Page did not receive wheel events."); |
| |
| if (window.internals) { |
| document.getElementById('layers').innerText = internals.layerTreeAsText(document, |
| internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES); |
| } |
| |
| finishJSTest(); |
| } |
| |
| function scrollTest() |
| { |
| pageScrollPositionBefore = document.scrollingElement.scrollTop; |
| |
| iframeTarget = document.getElementById('target'); |
| |
| var iframeBody = window.frames['target'].document.body; |
| iframeBody.scrollTop = iframeBody.scrollHeight - iframeTarget.clientHeight - 100; |
| |
| iFrameScrollPositionBefore = iframeBody.scrollTop; |
| |
| // Scroll the #source until we reach the #target. |
| var startPosX = Math.round(iframeTarget.offsetLeft) + 20; |
| var startPosY = Math.round(iframeTarget.offsetTop) + 100; |
| eventSender.mouseMoveTo(startPosX, startPosY); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue'); |
| eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end'); |
| eventSender.callAfterScrollingCompletes(checkForScroll); |
| } |
| |
| function setupTopLevel() |
| { |
| if (window.eventSender) { |
| eventSender.monitorWheelEvents(); |
| setTimeout(scrollTest, 0); |
| } else { |
| var messageLocation = document.getElementById('parent'); |
| var message = document.createElement('div'); |
| message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>" |
| + "inside the iframe, then use the mouse wheel or a two-finger swipe to scroll the iframe to the bottom (and beyond).<br/>" |
| + "<br/><br/>" |
| + "The test passes if you scroll far enough to see the row of END labels but the main page does not scroll.</p>"; |
| messageLocation.appendChild(message); |
| } |
| } |
| |
| window.addEventListener('load', () => { |
| document.addEventListener("mousewheel", onScrollWheel); |
| }, false); |
| </script> |
| </head> |
| <body> |
| <div id="parent" style="height: 2000px"> |
| <div id="source" style="height: 100px"> |
| Put mouse here and flick downwards |
| </div> |
| <iframe id="target" name="target" style="border:solid 1px green; height: 500px; width: 500px;" |
| src= "data:text/html, |
| <div id='notToBeScrolled' style='height: 1000px; width: 1000px;'> |
| TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/><br/> |
| This should still be visible inside the frame after you scroll down |
| <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> |
| <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> |
| <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> |
| This should NOT be visible inside the frame after you scroll down<br/> |
| <br/> |
| END END END END END END END END END END END END END |
| </div> |
| " |
| onload="setupTopLevel();" |
| > |
| </iframe> |
| </div> |
| <div id="console"></div> |
| <script> |
| description("Tests that iframe doesn't pass wheel events to main frame when scrolling at bottom"); |
| </script> |
| <pre id="layers">Layer tree goes here</p> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |