w3c / IntersectionObserver

Intersection Observer
https://www.w3.org/TR/intersection-observer/
Other
3.62k stars 526 forks source link

Clarify root bounds policy for nested iframes with A-B-A origins #409

Closed szager-chromium closed 3 years ago

szager-chromium commented 4 years ago

The existing InteresectionObserver spec uses obsolete language in defining rootBounds:

"If target belongs to the same unit of related similar-origin browsing contexts as the intersection root, this will be the root intersection rectangle. Otherwise, this will be null."

The html spec has deprecated "unit of related similar-origin browsing contexts", but it previously referred to a connected graph of same-origin browsing contexts. The closest concept in the currect spec is probably the "browsing context scope origin":

https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-scope-origin

That basically describes any browsing context that is in the "unit of related similar-origin browsing contexts" as the top-level document.

The intent of the original IntersectionObserver spec language was that rootBounds should be null whenever the target is in a cross-origin iframe, even if the top document is same-origin to the target's document.

A recent WPT commit added a test which contradicts this interpretation:

https://github.com/web-platform-tests/wpt/commit/57d1b42674b8226de887e68e8e73bfd9257fb333

I propose that the test be removed from WPT.

szager-chromium commented 3 years ago

After further discussion in pull request #448, it was decided that rootBounds should be populated as long as the browsing context containing the observation target Element is same-origin-domain with the top-level browsing context. So the intersection-observer/same-origin-grand-child-iframe.sub.html test is correct.