Move LegacyBindingEnabled / JavascriptBindingPropertyName to per browser settings#5231
Move LegacyBindingEnabled / JavascriptBindingPropertyName to per browser settings#5231campersau wants to merge 2 commits intocefsharp:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughMigrates JavaScript binding configuration from wrapper-level fields to per-browser Changes
Sequence DiagramsequenceDiagram
participant Browser as Browser Instance
participant Cache as Per-Browser Cache
participant Factory as Settings Factory
participant Context as JS Context
participant Binder as Binding Logic
Browser->>Cache: OnBrowserCreated(browserId) -> GetOrAdd(browserId, factory)
Cache->>Factory: invoke JavascriptBindingSettingsFactory(int)
Factory-->>Cache: return JavascriptBindingSettings
Cache-->>Browser: cached settings associated with browserId
Browser->>Context: OnContextCreated(frame)
Context->>Cache: TryGetValue(browserId)
Cache-->>Context: JavascriptBindingSettings (or null)
Context->>Binder: If settings != null -> evaluate settings (names, legacy flag)
Binder-->>Context: Apply global property / legacy root bindings as per settings
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
CefSharp.Test/JavascriptBinding/JavascriptBindingTests.cs (1)
91-122: Consider adding isolation assertions to verify per-browser settings don't leak.The test verifies that each browser has its expected binding object, which is good. However, to fully validate per-browser isolation, consider also verifying that:
browser1does not havewindow.cefSharp(since it has a custom name)browser1does not havewindow.bindingApiObject2browser2does not havewindow.bindingApiObject1This would catch any accidental cross-contamination between browser instances sharing a render process.
💡 Example additional assertions
// After the existing assertions, add isolation checks: var isolation1 = await browser1.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'"); Assert.True(isolation1.Success, isolation1.Message); Assert.True((bool)isolation1.Result, "browser1 should not have default cefSharp"); var isolation2 = await browser2.EvaluateScriptAsync("typeof window.cefSharp === 'undefined'"); Assert.True(isolation2.Success, isolation2.Message); Assert.True((bool)isolation2.Result, "browser2 should not have default cefSharp");🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CefSharp.Test/JavascriptBinding/JavascriptBindingTests.cs` around lines 91 - 122, The test ShouldWorkWhenUsingCustomGlobalObjectNameInMultipleBrowsers currently checks that each browser exposes its expected global, but doesn't assert that other globals are absent; add additional EvaluateScriptAsync checks and assertions (using browser1, browser2, browser3 and Assert.True/Assert.False) after the existing assertions to verify browser1 does not have window.cefSharp or window.bindingApiObject2, browser2 does not have window.cefSharp or window.bindingApiObject1, and browser3 does not have the custom names, ensuring per-browser isolation and no render-process leakage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@CefSharp.Test/JavascriptBinding/JavascriptBindingTests.cs`:
- Around line 91-122: The test
ShouldWorkWhenUsingCustomGlobalObjectNameInMultipleBrowsers currently checks
that each browser exposes its expected global, but doesn't assert that other
globals are absent; add additional EvaluateScriptAsync checks and assertions
(using browser1, browser2, browser3 and Assert.True/Assert.False) after the
existing assertions to verify browser1 does not have window.cefSharp or
window.bindingApiObject2, browser2 does not have window.cefSharp or
window.bindingApiObject1, and browser3 does not have the custom names, ensuring
per-browser isolation and no render-process leakage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4a007db3-794d-450b-997f-c0d3af1bb52d
📒 Files selected for processing (4)
CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cppCefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.hCefSharp.BrowserSubprocess.Core/JavascriptBindingSettings.hCefSharp.Test/JavascriptBinding/JavascriptBindingTests.cs
|
✅ Build CefSharp 146.0.70-CI5462 completed (commit 205dafcb77 by @campersau) |
|
❌ Build CefSharp 146.0.70-CI5463 failed (commit 834355dc39 by @campersau) |
Fixes: Addresses #5229 (comment)
Summary:
Changes:
How Has This Been Tested?
Unittests
Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit
New Features
Improvements
Tests