| <!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> |
| </head> |
| <body onload="setupTopLevel();"> |
| <script> |
| var pageScrollPositionBefore; |
| var iframeTarget; |
| var iFrameScrollPositionBefore; |
| var selectTarget; |
| var selectTargetScrollPositionBefore; |
| |
| function checkForScroll() |
| { |
| // The IFrame should not have scrolled at all. |
| var pageScrollPositionAfter = document.body.scrollTop; |
| if (pageScrollPositionAfter != pageScrollPositionAfter) |
| testFailed("Page consumed wheel events."); |
| else |
| testPassed("Page did not receive wheel events."); |
| |
| var iFrameScrollPositionAfter = window.frames['target'].document.body.scrollTop; |
| if (iFrameScrollPositionBefore != iFrameScrollPositionAfter) |
| testFailed("IFrame consumed wheel events."); |
| else |
| testPassed("IFrame did not receive wheel events."); |
| |
| var selectTargetScrollPositionAfter = selectTarget.scrollTop; |
| if (selectTargetScrollPositionBefore != selectTargetScrollPositionAfter) |
| testPassed("Select consumed wheel events."); |
| else |
| testFailed("Select did not receive wheel events."); |
| |
| finishJSTest(); |
| testRunner.notifyDone(); |
| } |
| |
| function scrollTest() |
| { |
| pageScrollPositionBefore = document.body.scrollTop; |
| iFrameScrollPositionBefore = window.frames['target'].document.body.scrollTop; |
| |
| iframeTarget = document.getElementById('target'); |
| |
| selectTarget = window.frames['target'].document.getElementById('selectTarget'); |
| selectTargetScrollPositionBefore = selectTarget.scrollTop; |
| |
| // Scroll the #source until we reach the #target. |
| var startPosX = Math.round(selectTarget.offsetLeft) + 10; |
| var startPosY = Math.round(selectTarget.offsetTop) + 10; // Slightly more than one wheel scroll away from the IFrame |
| 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); |
| |
| // We should finish via the scroll event; this will fire in the case of failure when the page doesn't scroll. |
| } |
| |
| function setupTopLevel() |
| { |
| if (window.eventSender) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| |
| 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/>" |
| + "at the top of the page, and then use the mouse wheel or a two-finger swipe to scroll the<br/>" |
| + "down past the iframe.<br/><br/>" |
| + "The iframe should not scroll.</p>"; |
| messageLocation.appendChild(message); |
| } |
| } |
| |
| </script> |
| <div id="parent" style="height: 2000px;"> |
| <iframe id="target" name="target" height="500" width="600" src="resources/select_iframe.html"></iframe> |
| </iframe> |
| </div> |
| <div id="console"></div> |
| <script> |
| description("Tests that iframe doesn't consume wheel events when scrolling a select in an iframe."); |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |