[IntersectionObserver] Handle hidden OOPIF's correctly

When an OOPIF is hidden, by scrolling it outside the parent
document's viewport, or by setting display:none or visibility:hidden,
then the iframe process stops running lifecycle updates, and
IntersectionObserver notifications are not generated. That means that
an IntersectionObserver running in the iframe process will not get a
"not intersecting" notification until lifecycle updates resume.

With this change, IntersectionObservers are forced to run when an
OOPIF is hidden, so that the "not intersecting" notifications will be
generated without waiting for a lifecycle update.

Adding LocalFrame::WasShown and LocalFrame::WasHidden revealed another
latent bug -- LocalFrameView::visibility_observer_ was not turned off
in LocalFrameView::Dispose. As a result, it continued generating
notifications and sending IPC's to the browser, even after the
LocalFrameView was disposed. This is a problem with OOPIF's, because
all iframe's are initially created as a LocalFrameView and later
converted to a RemoteFrameView. The initial, temporary LFV would
start up its visibility_observer_, which would continue pumping out
notifications that were redundant -- and sometimes conflicting --
with IPC's sent from the RemoteFrameView. This bug only became
apparent when writing the test included in this patch, which was
flaky until LFV::visibility_observer_ was properly shut down in
LFV::Dispose().

BUG=941231
R=dtapuska@chromium.org,kenrb@chromium.org,chrishtr@chromium.org

Change-Id: I9c78742930c1829c49998b6f0212d58292fda57f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1568200
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652155}
13 files changed