Skip to content

fix(android): use addDocumentStartJavaScript#9

Open
friofry wants to merge 2 commits into
masterfrom
ab/issue-20602-fix-injection
Open

fix(android): use addDocumentStartJavaScript#9
friofry wants to merge 2 commits into
masterfrom
ab/issue-20602-fix-injection

Conversation

@friofry
Copy link
Copy Markdown
Collaborator

@friofry friofry commented May 15, 2026

  • early user scripts injection

refs status-im/status-app#20602

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Android WebView bridge injection to use AndroidX WebKit’s document-start script injection (when supported) so bootstrap/user scripts can run earlier in the page lifecycle, plus a small JS-side readiness signal.

Changes:

  • Add window[ns].__ready = true to the page bootstrap to allow synchronous “ready” checks in addition to the qtWebChannelReady event.
  • On Android, detect WebViewFeature.DOCUMENT_START_SCRIPT support and register bootstrap + user scripts via WebViewCompat.addDocumentStartJavaScript.
  • Add cleanup for registered document-start scripts and keep an onPageStarted-based fallback when the feature is unsupported.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
mobilewebview/src/js/bootstrap_page.js Adds a __ready flag on the namespace object before firing the ready event.
mobilewebview/android/src/org/mobilewebview/MobileWebView.java Registers bootstrap/user scripts at document start via AndroidX WebKit, with cleanup and fallback injection logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mobilewebview/android/src/org/mobilewebview/MobileWebView.java Outdated
Comment thread mobilewebview/android/src/org/mobilewebview/MobileWebView.java
Comment thread mobilewebview/android/src/org/mobilewebview/MobileWebView.java Outdated
@friofry friofry force-pushed the ab/issue-20602-fix-injection branch from 92db5f9 to 1355349 Compare May 15, 2026 11:51
* if present to make early user scripts injection

refs status-im/status-app#20602
@friofry friofry force-pushed the ab/issue-20602-fix-injection branch 3 times, most recently from 5d57efe to fe6fa81 Compare May 15, 2026 13:26
@friofry friofry requested a review from Copilot May 15, 2026 13:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread mobilewebview/android/src/org/mobilewebview/MobileWebView.java
@friofry friofry force-pushed the ab/issue-20602-fix-injection branch from fe6fa81 to a3da140 Compare May 15, 2026 13:35
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.

2 participants