Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the JS injection demo #4704

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

kaidokert
Copy link
Member

@kaidokert kaidokert commented Jan 16, 2025

Updated the example to hook everything up in the appropriate places.

b/379731250

zhongqiliang pushed a commit to zhongqiliang/cobalt that referenced this pull request Jan 17, 2025
Incorporate Chromium's js_injection module into the Chrobalt codebase to enable JavaScript injection capabilities.
Move the Kabuki polyfill scripts into cobalt/embedded_resources.
Utilize the embed_polyfilled_javascript GN rule to convert the JavaScript files in cobalt/embedded_resources into embedded_js.h.
In the CobaltWebContentsObserver constructor, load the embedded JavaScript from embedded_js.h into the GeneratedResourceMap. Use AddDocumentStartJavaScript() to inject the polyfill code into web pages. This ensures the polyfills are executed early in the page lifecycle.
Override the RunScriptsAtDocumentStart() method in CobaltContentRendererClient to execute the injected polyfill JavaScript code.
This PR is built on top of Kaido 's draft PR youtube#4704.

b/384742721
zhongqiliang added a commit that referenced this pull request Jan 19, 2025
1. Incorporate Chromium's js_injection module into the Chrobalt codebase
to enable JavaScript injection capabilities.
2. Move the Kabuki polyfill scripts into cobalt/embedded_resources.
3. Utilize the embed_polyfilled_javascript GN rule to convert the
JavaScript files in cobalt/embedded_resources into embedded_js.h.
4. In the CobaltWebContentsObserver constructor, load the embedded
JavaScript from embedded_js.h into the GeneratedResourceMap. Use
AddDocumentStartJavaScript() to inject the polyfill code into web pages.
This ensures the polyfills are executed early in the page lifecycle.
5. Override the RunScriptsAtDocumentStart() method in
CobaltContentRendererClient to execute the injected polyfill JavaScript
code.

This PR is built on top of Kaido 's draft PR
#4704.

b/384742721

---------

Co-authored-by: Kaido Kert <kaidokert@google.com>
Co-authored-by: Colin Liang <colinliang@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant