Closed foolip closed 5 years ago
Can non-trusted scroll events modify the scroll offset of the document?
I haven't tested but hope not. Dispatching events shouldn't trigger any behavior beyond invoking event callbacks, and the only case to the contrary I know of is click events, see https://dom.spec.whatwg.org/#dispatching-events and notes elsewhere in DOM, just search for "click".
https://wicg.github.io/largest-contentful-paint/#sec-modifications-DOM
Per this
document.body.dispatchEvent(new Event('scroll'))
should set the flag. This should be tested, and probably it's better to change the spec to use theisTrusted
flag to ignore these events. That would make it easier to later change where this information is maintained to the places where the events are created/dispatched, if it turns out the rule for this flag needs to be more complicated.Follow-up to https://github.com/WICG/largest-contentful-paint/issues/18 and https://github.com/WICG/largest-contentful-paint/pull/23.