Reland "[Extensions] Implement runtime.getDocumentId() API"
This is a reland of commit 28732282004a00c63d4642d84713c347cba46002
What changed in the reland:
- The pre-existing UAF in NavPrefetchBrowserTest (where
rfhi.GetDocumentToken() was called after a cross-document navigation
had already destroyed rfhi when BackForwardCache is disabled) was
fixed separately in crrev.com/c/8616829.
- Added "nodoc": true to runtime.getDocumentId in runtime.json and moved
the document_id_ assignment into the ExtensionDocumentUserData
constructor body after the lifecycle CHECK.
Original change's description:
> [Extensions] Implement runtime.getDocumentId() API
>
> This CL implements the synchronous chrome.runtime.getDocumentId()
> extension API which allows extension contexts and content scripts to
> synchronously retrieve the unique document ID of a given WindowProxy or
> frame owner element (iframe, frame, embed, or object), and throws a
> synchronous error if the target is invalid or detached.
>
> To support synchronous renderer-side execution, this CL:
> - Flag-guards this API logic behind a kApiRuntimeGetDocumentId flag
> - Exposes content::RenderFrameHost::GetDocumentToken() and unifies
> ExtensionApiFrameIdMap. Previously,
> ExtensionApiFrameIdMap::ExtensionDocumentUserData created a separate
> random base::UnguessableToken in the browser process that the renderer
> had no knowledge of. Now, we stop generating a separate document ID in
> the browser process and instead just use the existing document token in
> the renderer which ensures the ID will be returned synchronously.
> - Adds blink::WebFrame::FromWindow(): Blink already resolves DOM frame owner elements to a WebFrame*, but it lacked a helper to resolve a V8 Window / WindowProxy value to its corresponding WebFrame*.
> - Implements runtime.getDocumentId() in RuntimeHooksDelegate: The
> schema definition and feature rules are added and
> RuntimeHooksDelegate::HandleGetDocumentId() is implemented.
>
> Cross-origin same-process frames are supported in this CL, but
> out-of-process frames are not supported yet. This will be done in a
> separate CL.
>
> Fixed: 573738380
> Fuchsia-Binary-Size: Size increase is unavoidable.
> Change-Id: I9e6adf456344c2626e4b26c23ee31a08981b8ea2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8543050
> Reviewed-by: Scott Haseley <shaseley@chromium.org>
> Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
> Reviewed-by: Tim <tjudkins@chromium.org>
> Commit-Queue: Eva Su <evasu@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1723222}
Cq-Include-Trybots: luci.chromium.try:android-bfcache-rel,linux-bfcache-rel
Fixed: 573738380
Fuchsia-Binary-Size: Size increase is unavoidable.
Change-Id: I7c170dde5cbf93566327e80fe8b6f3f61c339618
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8614081
Commit-Queue: Eva Su <evasu@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Justin Lulejian <jlulejian@chromium.org>
Reviewed-by: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Andrea Orru <andreaorru@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1728316}
NOKEYCHECK=True
GitOrigin-RevId: 23d5301c11ac620a5e978e0daa06ace7aa8dd6e7
1 file changed