fix(webview): set cookies for inline HTML on native#2298
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
PR #2291 added html/htmlBaseUrl support but setCookie() still required url to be non-null. Inline HTML mode clears url, so cookieHeader and cookies were silently ignored on iOS/Android. Resolve the cookie base URL from url or htmlBaseUrl (with the same default as InAppWebViewInitialData) and add unit tests. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a native WebView regression from PR #2291 where
cookieHeaderandcookieswere silently ignored when rendering inline HTML.Bug and impact
Trigger: A screen uses
EnsembleWebViewwith thehtmlproperty pluscookieHeaderorcookieson iOS/Android.Impact: Session/auth cookies are never applied. Inline HTML that depends on authenticated cookies fails to load protected content, causing login loops or broken embedded flows.
Root cause
PR #2291 added
html/htmlBaseUrlsupport viaInAppWebViewInitialData, butsetCookie()innative/webviewstate.dartstill requiredurlto be non-null. Settinghtmlclearsurl, so cookie setup returned early without configuring the cookie manager.Fix
resolvedWebViewCookieBaseUrl()that falls back tohtmlBaseUrl(or the same default used by nativeinitialData) whenurlis null.setCookie().How to Test
modules/ensemble, runflutter test test/webview_cookie_base_url_test.dart.html,htmlBaseUrl, andcookieHeader; verify the cookie is present for requests from the loaded document.Duplicate check
cursor/critical-bug-remediation-a983): fixes web iframe inline HTML rendering — different platform and code path.executeActionawait — unrelated.Type of Change
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests pass