Ensure embedding token gets always propagated to parent frame
Currently, the code in RFHI::SetEmbeddingToken() (which gets called as
the result of a document being loaded in a renderer's RenderFrame for
the first time) takes care of locating the correct RenderFrameProxyHost
representing the parent frame remotely to send it the embedding token,
so that the parent-child relationship can get established.
However, there is a race condition for the particular case of inner web
contents in that such propagation will only work if SetEmbeddingToken()
gets called *after* the inner web contents are attached to the outer
one. In that case, since the outer delegater proxy has not been created
yet, SetEmbeddingToken() will fail to find the RenderFrameProxyHost and
the remote frame representing the parent frame in one renderer will not
have its embedding token properly set, breaking things such as the
accessibility tree, for instance.
To fix that, this CL splits RFHI::SetEmbeddingToken() in two parts: one
that actually sets the embedding token and another one that takes care
of propagating it to the parent frame. And with that in place, this CL
does also make sure that such propagation is requested also after inner
web contents get attached, so that the parent-child relationship is
always guaranteed to be set.
Bug: 1135691, 1094150
Change-Id: Ie3ddd24acb3ad224a08a31c622e319cd69affba8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462128
Commit-Queue: Mario Sanchez Prada <[email protected]>
Reviewed-by: Matt Falkenhagen <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: Dominic Mazzoni <[email protected]>
Cr-Commit-Position: refs/heads/master@{#816499}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index c983e5e..722e2bf 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2250,6 +2250,10 @@
observer->InnerWebContentsAttached(inner_web_contents_impl,
render_frame_host, is_full_page);
});
+
+ // Make sure that the inner web contents and its outer delegate get properly
+ // linked via the embedding token now that inner web contents are attached.
+ inner_main_frame->PropagateEmbeddingTokenToParentFrame();
}
std::unique_ptr<WebContents> WebContentsImpl::DetachFromOuterWebContents() {