Skip to content

Add CefFrameHandler binding (GH #33) - #52

Merged
Thrameos merged 1 commit into
masterfrom
backport/cef-frame-handler
Sep 6, 2026
Merged

Thrameos merged 1 commit into
masterfrom
backport/cef-frame-handler

Conversation

@Thrameos

@Thrameos Thrameos commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • CEF exposes frame lifecycle events (onFrameCreated/onFrameDestroyed/onFrameAttached/onFrameDetached, onMainFrameChanged) that JCEF had no Java binding for at all -- no way for an app to observe when a sub-frame (e.g. an iframe) is created, attaches to its renderer process, or is torn down.
  • Adds native/frame_handler.{h,cpp} + org.cef.handler.CefFrameHandler/CefFrameHandlerAdapter, wired into client_handler.cpp/CefClient the same way CefFindHandler (PR Add CefFindHandler binding (GH #32) #51) was -- this branch's existing GetHandler<T>() template pattern.
  • Backport of coverage/phase1-value-objects-phase2-handlers's 17ba666 -- the CefFrameHandler half only. That commit also adds CefPermissionHandler, a separate, larger, independent handler; splitting it into its own follow-up PR for cheaper review (per this repo's review-cost-ordering convention).
  • JCEF_TRACE calls dropped (not on master). Fresh CefFrameHandlerTest built directly on TestFrame instead of porting CefFrameHandlerCoverageTest, which depends on SharedBrowserExtension (not present on master).

Test plan

  • Full clean rebuild (fresh cmake reconfigure to pick up the new frame_handler.cpp/.h sources, + ninja -C jcef_build jcef under -Werror, + tools/compile.sh linux64)
  • New CefFrameHandlerTest.subFrameLifecycleCallbacksFire(): loads a page with a data: URL iframe and asserts both onFrameCreated and onFrameAttached fire for the non-main sub-frame
  • Full local suite: 124/124 tests passing, including the new test
  • Post-suite Aborted (core dumped) after the JUnit summary is the already-tracked, pre-existing GH Release build: SIGSEGV in libc.so.6 during JVM shutdown after all tests pass #10 shutdown SIGSEGV, unrelated to this change
  • CI (build/test/coverage jobs)

🤖 Generated with Claude Code

https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq

@Thrameos Thrameos added the enhancement New feature or request label Sep 6, 2026
@Thrameos Thrameos mentioned this pull request Sep 6, 2026
4 of 5 tasks
@codecov

codecov Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.50%. Comparing base (f56d33c) to head (05c047b).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
native/frame_handler.cpp 74.13% 5 Missing and 10 partials ⚠️
java/org/cef/CefClient.java 66.66% 3 Missing and 4 partials ⚠️
java/org/cef/handler/CefFrameHandlerAdapter.java 50.00% 3 Missing ⚠️
java/org/cef/handler/CefClientHandler.java 60.00% 2 Missing ⚠️
java/tests/junittests/CefFrameHandlerTest.java 90.47% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #52      +/-   ##
============================================
+ Coverage     39.82%   40.50%   +0.67%     
- Complexity      781      817      +36     
============================================
  Files           249      255       +6     
  Lines         15045    15309     +264     
  Branches       2468     2503      +35     
============================================
+ Hits           5992     6201     +209     
- Misses         7814     7837      +23     
- Partials       1239     1271      +32     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CEF exposes frame lifecycle events (onFrameCreated/Destroyed/Attached/
Detached, onMainFrameChanged) that JCEF had no Java binding for at all --
no way to observe when a sub-frame (e.g. an iframe) is created, attached
to its renderer process, or torn down.

Adds native/frame_handler.{h,cpp} + org.cef.handler.CefFrameHandler/
CefFrameHandlerAdapter, wired into client_handler.cpp/CefClient the same
way CefFindHandler was (this branch's existing GetHandler<T>() template
pattern).

Backport of coverage/phase1-value-objects-phase2-handlers's 17ba666
(frame-handler half only; CefPermissionHandler is a separate, larger
follow-up), with JCEF_TRACE calls dropped (not on master) and a fresh
CefFrameHandlerTest built directly on TestFrame instead of
CefFrameHandlerCoverageTest (which depends on SharedBrowserExtension,
not present on master).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq
@Thrameos
Thrameos force-pushed the backport/cef-frame-handler branch from 1f6adcb to 05c047b Compare September 6, 2026 03:11
@Thrameos
Thrameos merged commit e0afbde into master Sep 6, 2026
12 of 13 checks passed
@Thrameos
Thrameos deleted the backport/cef-frame-handler branch September 6, 2026 03:27
Thrameos added a commit that referenced this pull request Sep 6, 2026
Previously there was no way for a JCEF app to grant/deny camera, mic, or
geolocation requests at all -- Alloy style silently denies everything.
Adds CefPermissionHandler (onRequestMediaAccessPermission,
onShowPermissionPrompt, onDismissPermissionPrompt), wired into
client_handler.cpp/CefClient the same way as every other handler.

Adds CefMediaAccessCallback and CefPermissionPromptCallback (new _N
callback classes, following the existing CefJSDialogCallback_N pattern).
Permission result/media-permission-type bit flags are passed as raw ints
with a nested constants class (CefContextMenuParams.TypeFlags' existing
convention), matching cef_media_access_permission_types_t/
cef_permission_request_result_t's declaration order exactly.

Backport of coverage/phase1-value-objects-phase2-handlers's 17ba666 (the
CefPermissionHandler half; CefFrameHandler landed separately in PR #52).
JCEF_TRACE calls dropped (not on master).

Not covered by an automated end-to-end test: getUserMedia() requires a
secure context and this suite's test URLs are http://test.com, so the
request would be rejected by Blink before ever reaching CEF's permission
layer. Extended CefClientTest's existing addAndRemoveEveryHandlerType()
wiring smoke test instead, the cheapest coverage that actually exercises
this change (add/remove round-trip through the real native ref).

New _N JNI classes registered in tools/make_all_jni_headers.{sh,bat} per
this repo's convention for regenerating hand-edited JNI headers.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant