Repository navigation
[Android] Fix doubled Content-Type header in BlazorWebView and HybridWebView responses - #39795
Conversation
WebKitWebViewClient passed the content type as the mimeType argument of WebResourceResponse and also left it in the responseHeaders map. Android WebView writes mimeType as the Content-Type header and then appends every map entry, so each static file reached the page as "text/css, text/css", and Blob.type and readAsDataURL carried the joined value too. WebResourceRequestedEventArgs.SetResponse built its Android response the same way, so intercepted responses were doubled as well. Content-Type now goes only through mimeType whenever the response has a body; without a body Android writes no mimeType header, so the map entry is kept. Fixes dotnet#39794
MauiHybridWebViewClient passed the content type both as the mimeType
argument of WebResourceResponse and in a responseHeaders map holding
only Content-Type, so Android WebView sent it twice ("text/html,
text/html"). The map added nothing else, so it is dropped.
Refs dotnet#39794
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39795Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39795" |
|
Hey there @@Kebechet! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
|
Hey there @Kebechet! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🟡 Changes recommended
The interception tests lack Android coverage for null and empty non-null streams with an explicit content type, leaving regressions in preserving exactly one Content-Type value undetected.
1 open issue
What changed in this PR
Fixes #39794 by preventing duplicate Content-Type headers in Android BlazorWebView and HybridWebView responses, avoiding malformed MIME values in fetched content.
Changes:
- Removes redundant headers where Android already supplies
Content-TypefrommimeType. - Preserves explicitly supplied content types for null-body intercepted responses.
- Adds device tests for static-content headers and BlazorWebView interception, including
Blob.typechecks.
| File | Description |
|---|---|
src/Core/src/Platform/Android/MauiHybridWebViewClient.cs |
Removes redundant header maps from static and bridge responses. |
src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/urlresolution.html |
Includes the response content type in test results. |
src/Controls/tests/DeviceTests/Elements/HybridWebView/HybridWebViewTests_ContentRootResolution.cs |
Adds single-content-type assertions for static files. |
src/Controls/src/Core/WebRequestInterceptingWebView/PlatformWebViewWebResourceRequestedEventArgs.cs |
Omits duplicate content-type entries while preserving null-body headers. |
src/BlazorWebView/tests/DeviceTests/Elements/BlazorWebViewTests.ContentType.cs |
Tests static and intercepted response headers and blob types. |
src/BlazorWebView/src/Maui/Android/WebKitWebViewClient.cs |
Removes the redundant content-type map entry from static responses. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Android WebView writes the mimeType argument as Content-Type only for a response that has a stream, even an empty one. For a null stream it answers with the app's status line and the headers map alone, so SetResponse keeps Content-Type in the map exactly when there is no stream. Both sides of that check are now pinned: on main's code the empty-stream case fails with "application/json, application/json", and with the null-body exception removed the null-stream case fails with no Content-Type at all.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
937ad8b
into
dotnet:candidate/11.0.1xx-sr2
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes #39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: #40195/#40197 repair title readiness, #39795 repairs MIME handling, and #39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from #40116, following #40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…WebView responses (dotnet#39795) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android, `BlazorWebView` serves every static file with the `Content-Type` header twice. The page reads it as `text/css, text/css`, and `Blob.type` and `FileReader.readAsDataURL` carry the joined value too (`data:image/svg+xml, image/svg+xml;base64,...`), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app. `WebKitWebViewClient.GetResponse` passed the content type as the `mimeType` argument of `WebResourceResponse` and also left it in the `responseHeaders` map. Android WebView writes `mimeType` as the `Content-Type` header (`SetHeader`) and then appends every map entry (`AddHeader`): - [`AndroidStreamReaderURLLoader::HeadersComplete`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/android_stream_reader_url_loader.cc#281) - [`WebResourceResponse::GetResponseHeaders`](https://chromium.googlesource.com/chromium/src/+/32914b0eb0231a426eab78ba84a1fdec6b9221bd/components/embedder_support/android/util/web_resource_response.cc#106) The same pattern was in two more Android places, fixed here as well: | Code path | Change | | --- | --- | | `WebKitWebViewClient.GetResponse` (BlazorWebView static content) | Removes `Content-Type` from the headers map; it is already the `mimeType` argument. | | `PlatformWebViewWebResourceRequestedEventArgs.SetResponse` (the `WebResourceRequested` interception API of BlazorWebView and HybridWebView) | Skips `Content-Type` in the headers map when the response has a body. Without a body Android writes no `mimeType` header (`HeadersComplete` runs with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear. | | `MauiHybridWebViewClient` (HybridWebView static content and bridge responses) | Passes no headers map; it only ever held `Content-Type`. | After the fix the header is exactly the `mimeType` value, e.g. `text/css` (Android does not append the `"UTF-8"` encoding argument to the header). Other platforms are unchanged. ### Tests New device tests fetch from inside the WebView and assert both `response.headers.get('content-type')` and `Blob.type`: - `BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader` (`.css`, `.svg`, `.txt`) - `BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader` (`SetResponse` with status 200 and 201) - `BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader` (`SetResponse` with a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154 `Blob.type` for it is `""` (the CI emulator runs WebView 109). - `HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader` (`index.html`, `safe-file.txt`) Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43): | Suite | Without fix | With fix | | --- | --- | --- | | BlazorWebView device tests (whole suite) | 53 total, 44 passed, **5 failed** (exactly the 5 new cases), 4 skipped | 53 total, 49 passed, 0 failed, 4 skipped | | Controls device tests, `Category=HybridWebView` | 101 total, 94 passed, **2 failed** (exactly the 2 new cases), 5 skipped | 101 total, 96 passed, 0 failed, 5 skipped | The skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the `MauiHybridWebViewClient` change. The two bodiless cases were added after review and pin the null-body exception from both sides: on `main`'s code the empty-stream case fails (`"application/json, application/json"`), and with the exception removed the null-stream case fails (`null`). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped. Failures without the fix: ``` StaticContentIsServedWithASingleContentTypeHeader(filePath: "content-type-test.css", expectedContentType: "text/css") Assert.Equal() Failure: Strings differ Expected: "text/css" Actual: "text/css, text/css" InterceptedResponseIsServedWithASingleContentTypeHeader(statusCode: 201, reasonPhrase: "Created") Assert.Equal() Failure: Strings differ Expected: "application/json" Actual: "application/json, application/json" StaticContent_IsServedWithASingleContentTypeHeader(path: "index.html", expectedContentType: "text/html") Assert.Equal() Failure: Strings differ Expected: "text/html" Actual: "text/html, text/html" ``` The new tests are cross-platform. On Windows (WebView2, `Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows`) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a single `Content-Type`, which the new tests assert. Commands: ``` dotnet build src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/MauiBlazorWebView.DeviceTests/Release/net10.0-android/com.microsoft.maui.mauiblazorwebview.devicetests-Signed.apk --package-name com.microsoft.maui.mauiblazorwebview.devicetests --instrumentation com.microsoft.maui.mauiblazorwebview.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk dotnet xharness android test --app artifacts/bin/Controls.DeviceTests/Release/net10.0-android/com.microsoft.maui.controls.devicetests-Signed.apk --package-name com.microsoft.maui.controls.devicetests --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation --device-id emulator-5554 -o <out> --arg TestFilter=Category=HybridWebView ``` Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type ### Issues Fixed Fixes dotnet#39794 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…otnet#40237) <!-- Please let the below note in for people that find this PR --> [!NOTE] Are you waiting for the changes in this PR to be merged? It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. This gallery/test correction is explicitly assigned to `candidate/11.0.1xx-sr2`, based on `7e47665ecb7f68d3fb31f8d02806e2bf177f505d`. It does not change framework behavior or release routing. ### Description of Change <!-- Enter description of the fix in this section --> Resetting the HybridWebView gallery properties and reloading the document did not reset its scroll position. Different `DefaultFile` values share the same browser URL, allowing the offset left by `navigation.html` to be restored in `index.html`. The native WebView frame remains `[27,90][1054,746]`, but its heading moves from Y=244 to Y=139 after navigation and Reset. This is document history dependence, not native control geometry. On Reset only, disable automatic history scroll restoration before reloading, then scroll the newly ready DOM to `(0,0)` and positively check both coordinates before publishing `Loaded`. Preserve exact-title matching, the old-document reload marker, DOM readiness independent of remote images, and the existing 50-attempt/100ms polling budget. Other gallery actions retain their existing title-readiness path. Strengthen the existing Shadow test by visiting `navigation.html`, resetting, and asserting that the native heading bounds return to their original position before the existing screenshot assertion. Refresh only the two Android API30 Shadow/FlowDirection goldens to the verified document origin. No product changes, offsets, delays, tolerance/mask/crop/retry changes, skips, or new harness are included. **Native causal evidence** — all Android runs use the same exclusively assigned API30 emulator, 1080x1920 at 420dpi: - Exact original CI1679745 APK, SHA256 `58ed1fc29acae710be628e47a957930faff6127f0d9a9230a5c954e59fc00639`: unchanged complete fixture has **9 passed / 2 failed**, with both original visuals differing by **7.90%**. The strengthened isolated Shadow test independently fails on heading bounds **Y244 -> Y139**, before screenshot comparison. - Trigger removed: the unchanged HybridWebView fixture with only its two navigation predecessors excluded passes **9/9**, including both visuals against the origin goldens. The original runner was copied for this control; no test exclusion was committed. - Fix applied: the complete fixture passes **11/11**, and both visual tests pass individually. Heading bounds are `[103,244][979,349]` before navigation and after Reset. - Gallery source reverted byte-for-byte to the candidate source and rebuilt with the same local toolchain: complete fixture returns to **9 passed / 2 failed**; isolated strengthened Shadow again fails **Y244 -> Y139**. The corresponding trigger-removed control passes **9/9**. - Fix restored and pushed as `ca6f36f39093dcc72c723c0cb01bfe7ce69f5952`: rebuilt after push, then **three complete fixture runs pass 11/11 each**. **Two additional isolated runs of each visual test pass**. No first-attempt failure was converted into a pass by rerunning it. **Commands and results:** - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Controls/tests/TestCases.HostApp/FeatureMatrix/HybridWebView/HybridWebViewControlPage.xaml.cs src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/HybridWebViewFeatureTests.cs --verbosity quiet` — passed. - `pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -DeviceUdid emulator-5582 -TestFilter 'FullyQualifiedName~HybridWebViewFeatureTests'` — restored fix and post-push rebuild passed **11/11**; the source-reverted control failed **2/11** as expected. - The isolated and repeat executions use the freshly built test assembly through `dotnet vstest`, with the same assigned emulator and independent TRX/log directories; existing screenshot strictness is unchanged. **Limits:** local source builds use the available .NET SDK **11.0.100**, runtime **11.0.0**, and GA Android workload, not the candidate-pinned **11.0.101-servicing.26559.106** toolchain. The emulator has WebView **91.0.4472.114**, not CI's WebView83. This is native causal validation, not pinned-CI or cross-platform certification. iOS, Windows, MacCatalyst and Android API36 were not run; their goldens are unchanged. Only automatic CI is requested by publishing this PR; no extra CI waves were queued. Upstream ownership was refreshed before publication: dotnet#40195/dotnet#40197 repair title readiness, dotnet#39795 repairs MIME handling, and dotnet#39918 owns broader test infrastructure. None implements this gallery reset correction. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Addresses the remaining Android HybridWebView Shadow and FlowDirection failures investigated from dotnet#40116, following dotnet#40197. No product issue is closed by this gallery-only correction. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
On Android,
BlazorWebViewserves every static file with theContent-Typeheader twice. The page reads it astext/css, text/css, andBlob.typeandFileReader.readAsDataURLcarry the joined value too (data:image/svg+xml, image/svg+xml;base64,...), which breaks anything that parses those values, e.g. html-to-image corrupts every image it embeds from the app.WebKitWebViewClient.GetResponsepassed the content type as themimeTypeargument ofWebResourceResponseand also left it in theresponseHeadersmap. Android WebView writesmimeTypeas theContent-Typeheader (SetHeader) and then appends every map entry (AddHeader):AndroidStreamReaderURLLoader::HeadersCompleteWebResourceResponse::GetResponseHeadersThe same pattern was in two more Android places, fixed here as well:
WebKitWebViewClient.GetResponse(BlazorWebView static content)Content-Typefrom the headers map; it is already themimeTypeargument.PlatformWebViewWebResourceRequestedEventArgs.SetResponse(theWebResourceRequestedinterception API of BlazorWebView and HybridWebView)Content-Typein the headers map when the response has a body. Without a body Android writes nomimeTypeheader (HeadersCompleteruns with its internal 404 and skips that branch), so there the map entry is kept and the header does not disappear.MauiHybridWebViewClient(HybridWebView static content and bridge responses)Content-Type.After the fix the header is exactly the
mimeTypevalue, e.g.text/css(Android does not append the"UTF-8"encoding argument to the header). Other platforms are unchanged.Tests
New device tests fetch from inside the WebView and assert both
response.headers.get('content-type')andBlob.type:BlazorWebViewTests.StaticContentIsServedWithASingleContentTypeHeader(.css,.svg,.txt)BlazorWebViewTests.InterceptedResponseIsServedWithASingleContentTypeHeader(SetResponsewith status 200 and 201)BlazorWebViewTests.InterceptedResponseWithoutABodyIsServedWithASingleContentTypeHeader(SetResponsewith a null stream and with an empty stream). The null-stream case asserts only the header, because before Chromium 154Blob.typefor it is""(the CI emulator runs WebView 109).HybridWebViewTests_ContentRootResolution.StaticContent_IsServedWithASingleContentTypeHeader(index.html,safe-file.txt)Run on an Android 15 emulator (API 35, x86_64, Android System WebView 155.0.8059.43):
Category=HybridWebViewThe skips are the existing ones (external echo service, platform-specific). The HybridWebView "without fix" column is the tree without the
MauiHybridWebViewClientchange.The two bodiless cases were added after review and pin the null-body exception from both sides: on
main's code the empty-stream case fails ("application/json, application/json"), and with the exception removed the null-stream case fails (null). With them, the BlazorWebView suite with the fix ran 55 tests: 51 passed, 0 failed, 4 skipped.Failures without the fix:
The new tests are cross-platform. On Windows (WebView2,
Run-DeviceTests.ps1 -Project BlazorWebView -Platform windows) the BlazorWebView suite with the fix ran 33 tests, 29 passed, 0 failed, 4 skipped, including all 7 new cases. iOS and MacCatalyst were not run locally; their handlers already send a singleContent-Type, which the new tests assert.Commands:
Reproduction app: https://github.com/Kebechet/maui-blazorwebview-duplicate-content-type
Issues Fixed
Fixes #39794