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

Integrate js_injection and make java bridge polyfill script work #4715

Merged

Conversation

zhongqiliang
Copy link
Contributor

@zhongqiliang zhongqiliang commented Jan 17, 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

@zhongqiliang zhongqiliang force-pushed the js_injection_with_embeded_resource branch 2 times, most recently from 6522cac to bb95b2c Compare January 17, 2025 19:38
@zhongqiliang zhongqiliang changed the title Js injection demo with example.js Integrate js_injection and make java bridge polyfill script work Jan 17, 2025
@zhongqiliang zhongqiliang marked this pull request as ready for review January 17, 2025 19:54
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 zhongqiliang force-pushed the js_injection_with_embeded_resource branch from bb95b2c to 5f91b04 Compare January 17, 2025 20:02
Copy link
Contributor

@johnxwork johnxwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Would you wait for Kaido to take a look since you collaborated on it?

Copy link
Member

@kaidokert kaidokert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay

@zhongqiliang zhongqiliang enabled auto-merge (squash) January 19, 2025 16:16
@zhongqiliang zhongqiliang merged commit 73018f4 into youtube:main Jan 19, 2025
87 of 88 checks passed
@zhongqiliang zhongqiliang deleted the js_injection_with_embeded_resource branch January 19, 2025 17:01
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.

3 participants