diff options
Diffstat (limited to 'gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_multiline.html')
-rw-r--r-- | gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_multiline.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_multiline.html b/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_multiline.html new file mode 100644 index 0000000000..ff5912dcee --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_multiline.html @@ -0,0 +1,94 @@ +<!DOCTYPE> +<html> + <head> + <title>Checking zoomToFocusedInput scrolls that focused non-input element is visible position</title> + <script type="application/javascript" src="apz_test_utils.js"></script> + <script type="application/javascript" src="apz_test_native_event_utils.js"></script> + <script src="/tests/SimpleTest/paint_listener.js"></script> + </head> +<body> +<div style="height: 8000px;">ABC</div> +<div id="content"> +</div> +<!-- Leave additional room below the element so it can be scrolled to the center --> +<div style="height: 1000px;">ABC</div> +<script type="application/javascript"> +async function test() { + let utils = SpecialPowers.getDOMWindowUtils(window); + + // contenteditable + let div = document.createElement("div"); + div.setAttribute("contenteditable", "true"); + for (let i = 0; i < 200; i++) { + div.innerHTML += "foo<br>"; + } + div.innerHTML += "<span id=last>bar</span>"; + document.getElementById("content").appendChild(div); + + let selection = window.getSelection(); + selection.collapse(div.firstChild, 0); + window.scrollTo(0, 0); + await waitToClearOutAnyPotentialScrolls(window); + is(0, window.scrollY, "scroll position is reset"); + let transformEndPromise = promiseTransformEnd(); + utils.zoomToFocusedInput(); + await transformEndPromise; + await promiseApzFlushedRepaints(); + ok(window.scrollY > 0, "scroll position isn't top"); + + let prevY = window.scrollY; + + selection.collapse(document.getElementById("last").firstChild, 0); + window.scrollTo(0, 0); + await waitToClearOutAnyPotentialScrolls(window); + is(0, window.scrollY, "scroll position is reset"); + transformEndPromise = promiseTransformEnd(); + utils.zoomToFocusedInput(); + await promiseApzFlushedRepaints(); + ok(prevY < window.scrollY, "scroll position is visibile position of caret"); + + await transformEndPromise; + + document.getElementById("content").removeChild(div); + + // <textarea> element + let textarea = document.createElement("textarea"); + textarea.rows = 200; + for (let i = 0; i < 200; i++) { + textarea.value += "foo\n"; + } + document.getElementById("content").appendChild(textarea); + textarea.focus(); + + await waitToClearOutAnyPotentialScrolls(window); + + textarea.setSelectionRange(0, 0); + window.scrollTo(0, 0); + await waitToClearOutAnyPotentialScrolls(window); + is(0, window.scrollY, "scroll position is reset"); + transformEndPromise = promiseTransformEnd(); + utils.zoomToFocusedInput(); + await promiseApzFlushedRepaints(); + ok(window.scrollY > 0, "scroll position isn't top"); + prevY = window.scrollY; + + await transformEndPromise; + + textarea.setSelectionRange(textarea.value.length, textarea.value.length); + window.scrollTo(0, 0); + await waitToClearOutAnyPotentialScrolls(window); + is(0, window.scrollY, "scroll position is reset"); + transformEndPromise = promiseTransformEnd(); + utils.zoomToFocusedInput(); + await promiseApzFlushedRepaints(); + ok(prevY < window.scrollY, "scroll position is visibile position of caret"); + + await transformEndPromise; + + document.getElementById("content").removeChild(textarea); +} + +waitUntilApzStable().then(test).then(subtestDone, subtestFailed); +</script> +</body> +</html> |