| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script> |
| if (window.internals) |
| internals.settings.setScrollAnimatorEnabled(false); |
| </script> |
| <style> |
| ::-webkit-scrollbar { |
| width: 0px; |
| height: 0px; |
| } |
| |
| body, html { |
| width: 100%; |
| height: 100%; |
| margin: 0; |
| } |
| |
| #rootscroller { |
| width: 100%; |
| height: 100%; |
| overflow: auto; |
| position: absolute; |
| left: 0; |
| top: 0; |
| z-index: -1; |
| background-color: red; |
| } |
| |
| .spacer { |
| width: 200%; |
| height: 200%; |
| } |
| |
| #inflow { |
| width: 200%; |
| height: 200%; |
| background-color: lightgreen; |
| z-index: 1; |
| } |
| </style> |
| |
| <div id="rootscroller"> |
| <div class="spacer"> |
| </div> |
| </div> |
| |
| <!--This element overflows the viewport and appears over the root scroller. |
| Therefore, scrolling it should scroll the document rather than the root |
| scroller --> |
| <div id="inflow"> |
| This test ensures that when the document is not the root scroller, i.e. |
| another element has been set as document.rootScroller, it can still be |
| scrolled via the keyboard. |
| </div> |
| |
| <script> |
| function click(x, y) { |
| return new Promise((resolve, reject) => { |
| var pointerActions = |
| [{source: "mouse", |
| actions: [ |
| { name: "pointerMove", x: x, y: y }, |
| { name: "pointerDown", x: x, y: y, button: 'left'}, |
| { name: "pointerUp", x: x, y: y, button: 'left' }]}]; |
| chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); |
| }); |
| } |
| |
| window.onload = function() { |
| var rootscroller = document.querySelector('#rootscroller'); |
| document.rootScroller = rootscroller; |
| |
| promise_test( t => { |
| // Ensure the "inflow" element/document is focused to receive keyboard |
| // events. |
| return click(100, 100).then( () => { |
| if (window.internals) { |
| assert_equals(internals.effectiveRootScroller(document), |
| rootscroller, |
| "Failed to set root scroller"); |
| } |
| eventSender.keyDown('ArrowDown'); |
| |
| assert_greater_than( |
| document.scrollingElement.scrollTop, 0, "Document must be scrolled"); |
| assert_equals( |
| rootscroller.scrollTop, 0, "RootScroller must not be scrolled"); |
| }) |
| }, "Arrow keys should scroll document."); |
| } |
| </script> |