var smoothScrollPref = "general.smoothScroll";
SimpleTest.waitForExplicitFinish(); var win = window.open("file_bug915962.html", "_blank", "width=600,height=600,scrollbars=yes");
function waitForScrollEvent(aWindow) {
return new Promise(resolve => {
aWindow.addEventListener("scroll", () => { SimpleTest.executeSoon(resolve); }, {once: true, capture: true});
});
}
function waitAndCheckNoScrollEvent(aWindow) {
let gotScroll = false;
function recordScroll() {
gotScroll = true;
}
aWindow.addEventListener("scroll", recordScroll, {capture: true});
return waitToClearOutAnyPotentialScrolls(aWindow).then(function() {
aWindow.removeEventListener("scroll", recordScroll, {capture: true});
is(gotScroll, false, "check that we didn't get a scroll");
});
}
SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({"set": [[smoothScrollPref, false]]}, startTest);
}, win);
async function startTest() {
// Make sure that pressing Space when a tabindex=-1 element is focused
// will scroll the page. varbutton = win.document.querySelector("button"); var sc = win.document.querySelector("div");
sc.focus();
await waitToClearOutAnyPotentialScrolls(win);
is(win.scrollY, 0, "Sanity check");
let waitForScrolling = waitForScrollEvent(win);
synthesizeKey(" ", {}, win);
await waitForScrolling;
isnot(win.scrollY, 0, "Page is scrolled down"); var oldY = win.scrollY;
waitForScrolling = waitForScrollEvent(win);
synthesizeKey(" ", {shiftKey: true}, win);
await waitForScrolling;
ok(win.scrollY < oldY, "Page is scrolled up");
// Make sure that pressing Space when a tabindex=-1 element is focused
// will not scroll the page, and will activate the element. button.focus();
await waitToClearOutAnyPotentialScrolls(win); var clicked = false; button.onclick = () => clicked = true;
oldY = win.scrollY;
let waitForNoScroll = waitAndCheckNoScrollEvent(win);
synthesizeKey(" ", {}, win);
await waitForNoScroll;
ok(win.scrollY <= oldY, "Page is not scrolled down");
ok(clicked, "The button should be clicked");
synthesizeKey("VK_TAB", {}, win);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.