Open Bug 1904195 Opened 1 year ago Updated 1 year ago

Height of document greater than the sum of the scroll value and window inner height

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 127
defect

Tracking

()

UNCONFIRMED

People

(Reporter: hello, Unassigned, NeedInfo)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0

Steps to reproduce:

On a private website, I have code to lazy load more search results when the user scrolls to the bottom.

This is the code in question, which worked fine until Firefox 127.0.0 and still works in Chrome current:
function getDocHeight() {
console.log(
'getDocHeight',
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);

return Math.max(
    document.body.scrollHeight, document.documentElement.scrollHeight,
    document.body.offsetHeight, document.documentElement.offsetHeight,
    document.body.clientHeight, document.documentElement.clientHeight
);

}

document.addEventListener("scroll", function () {
var docHeight = getDocHeight();
var scrollY = window.pageYOffset || document.documentElement.scrollTop;
var windowHeight = window.innerHeight;

let theHomeBox = document.querySelector('#home_pane');
if (theHomeBox) {
	theHomeBox.setAttribute('data-scrollofset', Math.floor(scrollY));
}

console.log('==');
console.log(`docHeight=${docHeight}`);
console.log(`scrollY=${scrollY}`);
console.log(`windowHeight=${windowHeight}`);
console.log(`scrollY + windowHeight=${scrollY + windowHeight}`);

if (docHeight <= scrollY + windowHeight) {
	console.log('page_ajax_load: GO');
	load_sidebar_pagination();
}

});

Actual results:

Here's what the console logs for the values:

getDocHeight 2243 2243 0 2243 0 473

docHeight=2243
scrollY=1770
windowHeight=472
scrollY + windowHeight=2242

First thing jumping out to me in 127.0.0 and 127.0.1 is the one pixel difference between document.documentElement.clientHeight (473) and window.innerHeight (472).

The load_sidebar_pagination() is never called in these versions of Firefox.

Expected results:

docHeight should be the same value as the sum of scrollY and windowHeight and then load_sidebar_pagination() should be called to lazy load more results.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

I attached the wrong sample code, which I was troubleshooting with ChatGPT.

document.addEventListener("scroll", function () {
	var docHeight = getDocHeight();
	var scrollY = window.pageYOffset || document.documentElement.scrollTop;
	var windowHeight = window.innerHeight;

	console.log('==');
	console.log(`docHeight=${docHeight}`);
	console.log(`scrollY=${scrollY}`);
	console.log(`windowHeight=${windowHeight}`);
	console.log(`scrollY + windowHeight=${scrollY + windowHeight}`);

	if (docHeight == (scrollY + windowHeight)) {
		console.log('page_ajax_load: GO');
		load_sidebar_pagination();
	}
});

The console log and Chrome testing is based on this.

The severity field is not set for this bug.
:sefeng, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(sefeng)

Thanks for the bug report! If this is reproducible easily, do you mind to use https://mozilla.github.io/mozregression/ to find the regression range?

Flags: needinfo?(sefeng)
Severity: -- → S3
Flags: needinfo?(hello)
You need to log in before you can comment on or make changes to this bug.