browser_gesture_scroll.js (1207B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const URL = `data:text/html, 7 <!doctype html> 8 <meta charset="utf-8"> 9 <div style="height: 200vh"></div> 10 Some content 11 <div style="height: 200vh"></div> 12 `; 13 14 function getScrollPos(browser) { 15 return SpecialPowers.spawn(browser, [], () => { 16 return { 17 scrollY: Math.round(content.scrollY), 18 scrollMaxY: Math.round(content.scrollMaxY), 19 }; 20 }); 21 } 22 23 // Bug 1964901 24 add_task(async function test_scroll_command() { 25 await BrowserTestUtils.withNewTab(URL, async function (browser) { 26 { 27 let { scrollY, scrollMaxY } = await getScrollPos(browser); 28 is(scrollY, 0, "Should be scrolled to the top"); 29 isnot(scrollMaxY, 0, "Should be scrollable"); 30 } 31 let scrollEvent = SpecialPowers.spawn(browser, [], async () => { 32 await new Promise(r => { 33 content.addEventListener("scrollend", r, { once: true }); 34 }); 35 }); 36 goDoCommand("cmd_scrollBottom"); 37 await scrollEvent; 38 { 39 let { scrollY, scrollMaxY } = await getScrollPos(browser); 40 is(scrollY, scrollMaxY, "Should be scrolled to the bottom"); 41 } 42 }); 43 });