Skip to content

[Windows] Fixed : WebView CanGoBack Returns true when it Shouldn't - #37648

Merged
kubaflo merged 7 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-37534
Aug 26, 2026
Merged

kubaflo merged 7 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-37534

Conversation

@SubhikshaSf4851

Copy link
Copy Markdown
Contributor

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 whether this change resolves your issue. Thank you!

This pull request addresses issues with the accuracy of the CanGoBack and CanGoForward properties in the Windows WebView handler, ensuring that navigation state is correctly reflected and not stale. It also adds a regression test to prevent future issues with navigation history.

Description of Change

Fixes and improvements to WebView navigation state:

  • Updated the logic in WebViewHandler.Windows.cs to check CoreWebView2.CanGoBack and CoreWebView2.CanGoForward instead of relying solely on the WebView2 control properties, which could become stale and cause incorrect navigation behavior.
  • Enhanced the UpdateCanGoBackForward extension method in WebViewExtensions.cs to prefer the CoreWebView2 navigation state for CanGoBack and CanGoForward, falling back to the control's properties only when necessary.

Testing and regression prevention:

  • Added a new test, CanGoBackIsFalseAfterReturningToFirstPage, to verify that CanGoBack is set to false after navigating back to the first page, preventing regressions related to navigation history.

Issues Fixed

Fixes #37534

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforeFix37534.mp4
AfterFix37534.mp4

Ahamed-Ali and others added 5 commits August 13, 2026 23:08
### Description of Change
This pull request makes a minor update to the UI test pipeline
configuration

- Pipeline configuration simplification:
* Removed the **duplicate** code that set the `$deviceType` variable and
appended the `--skin` argument to the test command in
`eng/pipelines/common/ui-tests-steps.yml`.


The same code was already added at [line
133](https://github.com/dotnet/maui/blob/main/eng/pipelines/common/ui-tests-steps.yml#L133)
as part of [PR dotnet#33409](dotnet#33409).

The duplicate code was also added at [line
156](https://github.com/dotnet/maui/blob/main/eng/pipelines/common/ui-tests-steps.yml#L156)
as part of [PR dotnet#31631](dotnet#31631).
<!-- 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

This follow-up repairs the skill-evaluation failures exposed by dotnet#36799
and hardens the credentialed Vally evaluator so skill regressions,
infrastructure failures, incomplete trials, parser differences, and
reporting-side failures are classified accurately.

### Root Causes

- `try-fix-capabilities` could exceed its numeric threshold while
remaining red because Vally independently hard-fails execution errors
and incomplete trials. Aggregate score never overrides those vetoes.
- `pr-review-gh-auth` routed correctly, but its isolated fixture omitted
the phase-specific unauthenticated public-GitHub fallback required by
the grader.
- Later failures exposed evaluator defects rather than skill
regressions: PAT authentication did not prove model entitlement, model
discovery did not initially match Vally 0.12's effective execution plan,
matrix-only token offsets removed run-level rotation entropy, and
parallel legs amplified shared PAT contention.
- Run `31518503277` restored the synthetic target correctly, but one
agent deleted Vally's pre-existing untracked `try-fix/` input to force
an empty `git status`; Vally correctly treated that deletion as
workspace drift.
- Run `31524806025` completed every evaluation successfully, but a
transient GitHub API fetch failure occurred before the comment step
exported its already-computed verdict, making reporting red despite
green suites.
- Review found parser-semantic splits between Psych and Vally's pinned
`yaml@2.9.0`: duplicate keys could be first-wins in AST policy checks
but last-wins at runtime, while YAML merge keys/tags were interpreted
differently and could hide executable evaluator fields from trusted
validation.

### Changes

- Replaced unreliable operational probes with bounded fixtures while
preserving repeated trials, behavioral rubrics, strict thresholds, and
hard-veto semantics.
- Added the unauthenticated GitHub fallback fixture and deterministic
skill-invocation/tool-call graders.
- Upgraded to Vally 0.12 and made aggregation fail closed on execution
errors, incomplete/skipped stimuli, malformed output, invocation
failures, and missing mandatory coverage.
- Added trusted fixture preparation plus path, symlink, Git,
environment, executable, attachment, hook, settings, MCP, executor, and
repository-control isolation.
- Serialized matrix legs while retaining three trials per stimulus.
- Made model discovery use only executed `eval*.vally.yaml` specs and
Vally 0.12's effective executor and prompt-grader fields; implicit
prompt-grader fallbacks are rejected.
- Added model-aware PAT selection with run/rerun/matrix-distributed
rotation and exact sentinel probes through the pinned evaluator runtime;
reused it in the advisory soak.
- Clarified that `try-fix` must preserve every pre-existing untracked
path, including evaluator-loaded skill inputs. Trusted validation
enforces both the skill contract and restoration fixture instruction
while retaining `diff-empty` as the method-independent veto.
- Exported the authoritative evaluation verdict before PR-comment API
calls, added bounded API retries, and made comment publication advisory
so transient GitHub failures cannot erase or invert the commit status.
- Reduced soak workflow permissions to `contents: read` and made `/user`
transport failures explicit without exposing PATs.
- Made required-stimulus policy fail closed when a configured stimulus
is renamed or removed, and bound each fixture marker/ref to the YAML
stimulus that owns it so a correctly named decoy cannot satisfy the
policy.
- Parse each eval spec once and reject duplicate semantic mapping keys,
textual YAML merge keys, and normalized explicit merge tags recursively
before loading. This prevents Psych/Vally parser disagreement from
bypassing prompt, ref, repository-control, or executable-environment
validation.
- Limited frozen-worktree test detection to full immutable commit IDs;
ordinary explicit branch bases continue using authoritative PR file
metadata.
- Added deterministic regressions for model planning, PAT distribution
and transport errors, deleted evaluator controls, host-only XAML
invocation, evaluator-owned input preservation, required-stimulus
rename/decoy/parser bypasses, branch-versus-immutable test detection,
and reporting-side verdict preservation.

### Validation

Current head: `fd8f3d543e1a1eb90e8432a0cbae07a18b52dbdd`.

- Exact-head [Skill Validation run
31807806898](https://github.com/dotnet/maui/actions/runs/31807806898),
[`maui-pr` build
1553690](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1553690),
Build Analysis, CLA, static checks, Pester, and the hermeticity gate are
green.
- All evaluated suites passed. Key suites: `try-fix-restore-protocol`
**1.00 / 1.00**, `try-fix-capabilities` **0.93 / 0.80**,
`pr-review-gh-auth` **1.00 / 0.80**, and
`verify-tests-fail-without-fix-capabilities` **0.94 / 0.87**.
- Local trusted evaluator/reporting harness: **70 tests, 306 assertions,
0 failures/errors/skips**.
- All **16** Vally specs pass strict lint with pinned
`@microsoft/vally-cli@0.12.0`.
- All **8** skill test directories pass trusted validation and resolve
the effective plan to `gpt-5.6-sol` plus `claude-opus-5`; non-eval
soak/hermeticity specs do not contaminate matrix selection.
- Ruby syntax, Bash syntax, ShellCheck, workflow YAML parsing, Pester
(**8 passed**), and `git diff --check` pass.
- Final whole-diff review found no high-confidence correctness or
security blockers; all review threads are resolved.
- `pull_request_target` executes trusted workflow/helper code from
default `main`; candidate selector/reporting helper behavior is
therefore covered deterministically here and becomes the credentialed
trusted path after merge.

### Issues Fixed

Follow-up to dotnet#36799.

---------

Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Vally Fixture <vally-fixture@example.invalid>
Copilot-Session: b9f7de2c-86d7-47cd-8ac8-aeff57d0b0f3
Copilot-Session: 806beb89-5041-4c7b-bcbf-998d6fbab8dc
<!-- 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

Extend the existing `release-readiness` skill with deterministic,
copy-ready Preview and servicing-release handoff generation from
readiness JSON plus separately verified public evidence.

- Keep missing or unverified release facts as explicit `TBD` values and
enforce public-safe URLs, structured metadata, NuGet configuration, and
Markdown output.
- Correct Preview workload installation guidance with package-source
mapping and the prior-major public compatibility feed while keeping
workload-set packages isolated to `dotnet-workloads`.
- Add focused regression coverage and run it in the release-readiness
validation workflow.

The renderer is a projection of the existing readiness engines rather
than a second survey, so Preview and SR semantics remain distinct while
sharing one public handoff format.

### Safety and Architecture

- Public output requires an explicit JSON boolean `PublicEvidence:
true`.
- The renderer rebuilds NuGet XML from an allow-list and accepts only
public `dnceng/public` Azure Artifacts feeds or the exact NuGet.org
service index.
- Public evidence URLs, structured build metadata, timestamps, Markdown,
local paths, credential-shaped values, and owner/sign-off prose are
validated or omitted.
- Workload-set packages map only to `dotnet-workloads`; component and
compatibility packages resolve through their appropriate public feeds.

### What Not to Do

- Do not use the handoff renderer as a second readiness survey or let it
select a newer build implicitly.
- Do not copy private source-page content, credentials, owners, or
sign-offs into public evidence.
- Do not map unrelated component packages to `dotnet-workloads`; missing
upstream packages can otherwise surface as misleading authorization
failures.

### Validation

- `pwsh -NoProfile -File
.github/skills/release-readiness/tests/Test-ReleaseHandoff.ps1`
- `pwsh -NoProfile -File
.github/skills/release-readiness/tests/Test-ReleaseReadiness.ps1
-SkipE2E`

### Issues Fixed

N/A

---------

Co-authored-by: PureWeen <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3db5742d-7e40-4a23-a3ea-de3bc3f0848e
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37648

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37648"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Aug 19, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 19, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@vishnumenon2684

Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 24, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Expert Review — 5 findings

See inline comments for details.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review Summary

@SubhikshaSf4851 — new AI review results are available based on commit de7039f.

Gate Passed Confidence High Platform Windows


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: WINDOWS · Base: main · Merge base: 19a18889

Test Without Fix (expect FAIL) With Fix (expect PASS)
📱 WebViewHandlerTests (CanGoBackIsFalseAfterReturningToFirstPage) Category=WebView ✅ FAIL — 377s ✅ PASS — 277s
🔴 Without fix — 📱 WebViewHandlerTests (CanGoBackIsFalseAfterReturningToFirstPage): FAIL ✅ · 377s

(no coded error found; showing last 1200 chars)

ss the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
Platform\Windows\TabbedPage\TabbedPageStyle.xaml(13,13): XamlCompiler warning WMC1510: Ensure the property path is trimming and AOT compatible by making use of 'Compiled Bindings (x:bind)' if possible or by specifying the 'x:DataType' directive with the respective binding data context and marking the type declaration with the 'WinRT.GeneratedBindableCustomProperty' attribute or the 'Microsoft.UI.Xaml.Data.Bindable' attribute. If you are unable to do either but can ensure the data type is attributed correctly, then you can also suppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
    0 Error(s)
Time Elapsed 00:04:35.67
  Passed: 0
  Failed: 1
  Skipped: 0
  Total: 1
  Tests completed with exit code: 1
🟢 With fix — 📱 WebViewHandlerTests (CanGoBackIsFalseAfterReturningToFirstPage): PASS ✅ · 277s

(no coded error found; showing last 1200 chars)

uppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
Platform\Windows\TabbedPage\TabbedPageStyle.xaml(13,13): XamlCompiler warning WMC1510: Ensure the property path is trimming and AOT compatible by making use of 'Compiled Bindings (x:bind)' if possible or by specifying the 'x:DataType' directive with the respective binding data context and marking the type declaration with the 'WinRT.GeneratedBindableCustomProperty' attribute or the 'Microsoft.UI.Xaml.Data.Bindable' attribute. If you are unable to do either but can ensure the data type is attributed correctly, then you can also suppress the warning by specifying `x:SuppressXamlTrimWarnings=True` within the closest element. If not, the property path might be trimmed and will not be AOT compatible. [D:\a\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net10.0-windows10.0.19041.0]
    0 Error(s)
Time Elapsed 00:04:22.66
  Passed: 1
  Failed: 0
  Skipped: 0
  Total: 1
  Tests completed successfully
📁 Fix files reverted (2 files)
  • src/Core/src/Handlers/WebView/WebViewHandler.Windows.cs
  • src/Core/src/Platform/Windows/WebViewExtensions.cs

📋 Pre-Flight — Context & Validation

PR #37648 Pre-Flight

Context

  • PR: [WIP][Windows] Fixed : WebView CanGoBack Returns true when it Shouldn't
  • Issue: #37534, WebView.CanGoBack on Windows Returns true When it Shouldn't
  • Platform: Windows 11 / Windows WebView2
  • Problem: After navigating from an initial WebView page to a second page and then back to the first page, IWebView.CanGoBack can remain true. Application code then calls GoBack() repeatedly instead of falling back to app-level navigation.
  • Base / merge base: main / 19a188896c0e518c0d201db181f67166c740724d
  • Materialized PR commit: ffa08dd4723068a338f6f42b0ad67847c0ac767b

Existing PR Approach

The PR changes:

  1. src/Core/src/Handlers/WebView/WebViewHandler.Windows.cs
    • MapGoBack and MapGoForward prefer CoreWebView2.CanGoBack / CanGoForward over the WebView2 control wrapper properties before setting CurrentNavigationEvent.
    • Both mappers cache and null-check PlatformView.
  2. src/Core/src/Platform/Windows/WebViewExtensions.cs
    • UpdateCanGoBackForward prefers the underlying CoreWebView2 history values and falls back to the WebView2 control properties before core initialization.
  3. src/Core/tests/DeviceTests/Handlers/WebView/WebViewHandlerTests.Windows.cs
    • Adds CanGoBackIsFalseAfterReturningToFirstPage, which loads two HTML pages, navigates back, and asserts CanGoBack == false.

The existing fix assumes the WinUI WebView2.CanGoBack / CanGoForward wrapper values are stale while the underlying CoreWebView2 values are current.

Validation Contract

The prior gate already proved the regression test fails without the production fix and passes with it:

  • Without fix: 0 passed, 1 failed
  • With fix: 1 passed, 0 failed
  • Primary command: pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Core -Platform windows -TestFilter "Category=WebView" -Rebuild
  • No additional mandatory regression test was supplied for STEP 5a; do not run a full suite.
  • Do not repeat the separate gate A/B verification.

Candidate Boundaries

  • Each candidate must use a root-cause mechanism different from the PR fix and from earlier candidates.
  • Production files eligible for baseline restoration and modification:
    • src/Core/src/Handlers/WebView/WebViewHandler.Windows.cs
    • src/Core/src/Platform/Windows/WebViewExtensions.cs
  • The added regression test remains in place but is read-only for try-fix.
  • Preserve all unrelated pre-existing tracked and untracked worktree changes.
  • Use only pwsh .github/scripts/EstablishBrokenBaseline.ps1 and its exact -Restore mode for baseline handling.
  • One implementation/test pass is allowed, plus at most one focused correction/retest.

Pre-Flight Result

Ready for two sequential bounded try-fix attempts. Gate verification is accepted and must not be rerun.


🔬 Code Review — Deep Analysis

Expert PR Evaluation — PR #37648

Verdict: Approve with non-blocking hardening changes
Confidence: High for the production mechanism; medium for long-term test stability.

Independent Assessment

The Windows handler now uses CoreWebView2.CanGoBack and CoreWebView2.CanGoForward as the authoritative navigation-history state, with the WinUI WebView2 wrapper properties as a pre-initialization fallback. The same source is used both when publishing IWebView state and when deciding whether GoBack/GoForward can execute. The added Windows device test covers returning from a second HTML page to the first page.

This is the correct root-cause mechanism. STEP 5a candidate 1 showed that republishing the wrapper properties later does not repair their stale state, while candidate 2's handler-owned counters cannot faithfully represent WebView2 joint-session history such as history.pushState() and script-initiated navigation.

Findings

  1. Moderate — disposed CoreWebView2 access: UpdateCanGoBackForward now reads CoreWebView2 directly even though this file's IsValid() helper documents that the access can throw after WebView2.Close(). A delayed SendNavigated continuation or late source update can reach this path after disconnect. Guard the read with IsValid().
  2. Moderate — incomplete pre-initialization guard: MapGoBack and MapGoForward null-check PlatformView, but UpdateGoBack and UpdateGoForward still dereference a null CoreWebView2. Guard the core before calling those helpers; the wrapper fallback is not useful before core initialization.
  3. Moderate — initial-navigation test race: the test subscribes after handler creation may already have started the first navigation. Register the callback and trigger a fresh source update after subscription.
  4. Moderate — assertion timing race: NavigatedDelegate completes before SendNavigated calls UpdateCanGoBackForward, so the test can resume before the state under test is published. Use asynchronous continuations and wait for the expected state.
  5. Minor — dead local: remove the unused platformView local from the new test.

The raw inline findings are recorded in ../inline-findings.json.

Blast Radius and Failure Modes

The production change is localized to Windows WebView; it does not affect startup, static/shared state, public API, trimming, or other platforms. It runs for every Windows WebView navigation-state update. Pre-core initialization remains safe in UpdateCanGoBackForward, but command mapping still needs the core guard noted above. The new direct core access introduces a post-Close() risk unless routed through IsValid(). Using WebView2's own history state correctly covers script-driven history mutations that a parallel MAUI counter would miss.

Prior Review and CI

The three GitHub review surfaces could not be queried because gh is unauthenticated; no prior error finding is present in the supplied local artifacts. The trusted gate passed: the regression test fails without the production fix and passes with it. The focused STEP 5a Windows WebView run also completed with 1,981 passed, 111 skipped, and no failures for the candidate that retained the regression test.


🛠️ Try-Fix — Analysis & Comparison

Alternative Fix Candidates — PR #37648

Candidate 1 — Navigation-State Publication Ordering

Model: claude-opus-5
Result: FAIL
Artifacts: CustomAgentLogsTmp/PRState/37648/PRAgent/try-fix-1/content.md

The candidate refreshed the existing WinUI WebView2 wrapper history properties before Navigated, testing whether consumers merely observed a one-event-old value. The focused Windows Category=WebView run built and deployed successfully, but CanGoBackIsFalseAfterReturningToFirstPage remained the sole failure. This disproves the timing-only hypothesis: WebView2.CanGoBack itself is still stale at navigation completion. Candidate 2 must avoid both wrapper-state resampling and the PR's direct CoreWebView2 state-source swap.

Candidate 2 — Handler-Owned Navigation History

Model: gpt-5.6-sol
Result: FAIL
Artifacts: CustomAgentLogsTmp/PRState/37648/PRAgent/try-fix-2/content.md

The candidate independently tracked successful NewPage/Back/Forward transitions and derived navigation availability without either platform property source. After one focused correction, the same Windows Category=WebView command passed all 2,092 discovered tests (1,981 passed, 111 skipped). It was nevertheless rejected because inline expert review found a major untested correctness gap: WebView2 history.pushState() changes and script-initiated history navigation can bypass NavigationCompleted or MAUI command mappers, causing the handler-owned counters to diverge and suppress valid navigation.

Aggregate Assessment

Neither alternative is safe:

  1. Publication reordering fails the primary regression because the WinUI wrapper remains stale even at navigation completion.
  2. Handler-owned bookkeeping passes the regression but cannot faithfully model WebView2 joint-session history.

Together, the attempts strengthen the existing PR's root-cause choice: the underlying CoreWebView2 history state is required as the authoritative source rather than timing changes or a parallel history model.


📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the description is accurate and detailed, but the title contains a stale [WIP] marker and does not follow the platform/component/action format.

Recommended title

[Windows] WebView: Fix stale CanGoBack and CanGoForward state

Recommended description

This pull request fixes stale `CanGoBack` and `CanGoForward` values in the Windows WebView handler so application navigation decisions reflect the current WebView2 history. It also adds a regression test for returning to the first page.

### Description of Change

The WinUI `WebView2.CanGoBack` and `WebView2.CanGoForward` wrapper properties can remain stale after navigation. The underlying `CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` properties reflect the current navigation state.

**Fixes and improvements to WebView navigation state:**

* Updated `WebViewHandler.Windows.cs` so `MapGoBack` and `MapGoForward` prefer `CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` before setting the current navigation event, with the WebView2 control properties retained as a fallback before core initialization.
* Updated `WebViewExtensions.UpdateCanGoBackForward` to prefer the `CoreWebView2` navigation state when publishing `CanGoBack` and `CanGoForward`, with the WebView2 control properties retained as a fallback before core initialization.

**Testing and regression prevention:**

* Added `CanGoBackIsFalseAfterReturningToFirstPage`, which loads two HTML pages, navigates back to the first page, and verifies that `CanGoBack` becomes `false`.

### Issues Fixed

Fixes #37534

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674"> | <video src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580"> |

🏁 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Winner: pr

The submitted PR uses the correct Windows WebView2 source of truth and is the only candidate that combines a sound history model with trusted A/B regression evidence: the added test fails without the fix and passes with it. Expert review found useful lifecycle and test-stability hardening opportunities, but classified them as non-blocking; the one permitted pr-plus-reviewer implementation did not compile and therefore cannot replace the validated submission.

Comparative Ranking

Rank Candidate Validation Correctness assessment
1 pr PASS — trusted Gate: regression fails without the fix and passes with it Uses CoreWebView2.CanGoBack / CanGoForward, which accurately reflects the browser's joint-session history. No blocking expert finding.
2 try-fix-2 PASS — 1,981 passed, 111 skipped, 0 failed Rejected despite passing the regression: handler-owned counters diverge for history.pushState() and script-initiated navigation and can suppress valid navigation.
3 pr-plus-reviewer FAIL/BLOCKED BEFORE TESTS — candidate build reported CS0103 for unavailable AssertEventually and WMC0001 for MiddleApp Preserves the PR's correct mechanism and adds worthwhile lifecycle/test hardening, but the submitted refinement is not buildable and has no passing regression result. No repair/retest loop was permitted.
4 try-fix-1 FAIL — regression remained the sole failed test (1,980 passed, 111 skipped) Republishing WinUI wrapper state later does not help because the wrapper property itself remains stale.

Expert Findings on the Submitted PR

  • UpdateCanGoBackForward directly reads CoreWebView2 on paths that may resume after WebView2.Close(); the existing IsValid() guard would harden this.
  • command mapping guards PlatformView but not an uninitialized/disposed CoreWebView2;
  • the regression test can miss the initial navigation callback and can observe state before the post-Navigated update;
  • the new test contains an unused local.

These are follow-up hardening and test-reliability improvements rather than evidence that the chosen production mechanism is wrong. The change is Windows-only, introduces no public API or shared/static state, and moves Windows behavior toward the live platform history semantics already expected by IWebView.

Decision

Approve the raw PR candidate. It satisfies the trusted Gate and is safer than both alternative mechanisms. The failed pr-plus-reviewer validation is recorded in pr-plus-reviewer/validation.log; its changes are not recommended as the winning patch in their current form.


📱 UI Tests — ViewBaseTests

Detected UI test categories: ViewBaseTests

[!WARNING]
No UI test results were produced for the detected categories. The PR build itself was
fine — the deep UI stage was skipped or interrupted on infrastructure (the
merge-for-testing step, emulator/simulator boot, or an Appium hang), not by this PR's code.
This is usually transient; the review re-runs on new commits (a maintainer can also re-run it).


🧭 Next Steps — review latest findings

No alternative fix was selected for this run. Review the session findings and CI results before merging.

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 24, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this one ready?

@SubhikshaSf4851 SubhikshaSf4851 changed the title [WIP][Windows] Fixed : WebView CanGoBack Returns true when it Shouldn't [Windows] Fixed : WebView CanGoBack Returns true when it Shouldn't Aug 26, 2026
@sheiksyedm
sheiksyedm marked this pull request as ready for review August 26, 2026 10:09
Copilot AI lite review requested due to automatic review settings August 26, 2026 10:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Windows WebView handler/navigation-state plumbing to avoid stale CanGoBack/CanGoForward values by preferring CoreWebView2’s navigation state, and adds a Windows device test intended to prevent regressions around back-history state.

Changes:

  • Prefer CoreWebView2 state (when available) for CanGoBack/CanGoForward updates in Windows WebView2 integration.
  • Adjust Windows WebView handler command mappers (GoBack/GoForward) to consult CoreWebView2 state rather than relying on potentially stale control properties.
  • Add a Windows device test covering CanGoBack becoming false again after returning to the first page.

Reviewed changes

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

File Description
src/Core/tests/DeviceTests/Handlers/WebView/WebViewHandlerTests.Windows.cs Adds a Windows regression test for CanGoBack correctness after navigating back to the first page.
src/Core/src/Platform/Windows/WebViewExtensions.cs Updates navigation helpers to use IsValid() and prefer CoreWebView2 for CanGoBack/CanGoForward synchronization.
src/Core/src/Handlers/WebView/WebViewHandler.Windows.cs Updates Windows handler command mapping to use CoreWebView2 navigation state when setting navigation event context.

Comment on lines +131 to +136
// Use CoreWebView2.CanGoForward rather than the WebView2 control's CanGoForward,
// which can be stale (see UpdateCanGoBackForward).
if ((platformView.CoreWebView2?.CanGoForward ?? platformView.CanGoForward) && handler is WebViewHandler w)
{
w.CurrentNavigationEvent = WebNavigationEvent.Forward;
}
Comment on lines +113 to +118
// Use CoreWebView2.CanGoBack rather than the WebView2 control's CanGoBack,
// which can be stale (see UpdateCanGoBackForward).
if ((platformView.CoreWebView2?.CanGoBack ?? platformView.CanGoBack) && handler is WebViewHandler w)
{
w.CurrentNavigationEvent = WebNavigationEvent.Back;
}
Comment on lines +104 to +107
var handler = CreateHandler(webView);

var platformView = handler.PlatformView;

@kubaflo
kubaflo changed the base branch from main to inflight/current August 26, 2026 12:57
@kubaflo
kubaflo merged commit 7183cdc into dotnet:inflight/current Aug 26, 2026
7 of 9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Skill Validation Results

@SubhikshaSf4851 — new skill validation results are available based on this last commit: deb7ed2.
To request a fresh validation after new comments or commits, comment /evaluate-skills.

Overall Failed Static Failed LLM Skipped Skills 0 Agents 0

❌ Skill Validation Results — deb7ed2 · [Windows] Fixed : WebView CanGoBack Returns true when it Shouldn't · 2026-08-26T12:58:28Z

❌ Static Checks Failed

Skills: 0 | Eval specs linted:

⏭️ LLM Evaluation: Skipped

💡 LLM evaluation was not run for this external PR.
A repository contributor can post /evaluate-skills on this PR to trigger full evaluation.

🔍 Full results and investigation steps

@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Aug 26, 2026
kubaflo pushed a commit that referenced this pull request Aug 27, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 2, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 3, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 6, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 7, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 8, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 9, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 11, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 15, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 18, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
kubaflo pushed a commit that referenced this pull request Sep 21, 2026
…37648)

<!-- Please keep the note below for people who 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 whether this change resolves your
issue. Thank you!

This pull request addresses issues with the accuracy of the `CanGoBack`
and `CanGoForward` properties in the Windows WebView handler, ensuring
that navigation state is correctly reflected and not stale. It also adds
a regression test to prevent future issues with navigation history.

### Description of Change
**Fixes and improvements to WebView navigation state:**

* Updated the logic in `WebViewHandler.Windows.cs` to check
`CoreWebView2.CanGoBack` and `CoreWebView2.CanGoForward` instead of
relying solely on the WebView2 control properties, which could become
stale and cause incorrect navigation behavior.
* Enhanced the `UpdateCanGoBackForward` extension method in
`WebViewExtensions.cs` to prefer the `CoreWebView2` navigation state for
`CanGoBack` and `CanGoForward`, falling back to the control's properties
only when necessary.

**Testing and regression prevention:**

* Added a new test, `CanGoBackIsFalseAfterReturningToFirstPage`, to
verify that `CanGoBack` is set to false after navigating back to the
first page, preventing regressions related to navigation history.


<!-- Enter description of the fix in this section -->

### 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. -->

Fixes #37534 

### Tested the behavior in the following platforms

- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac


| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video
src="https://github.com/user-attachments/assets/c6c4e68b-21ac-49cd-ad96-3f628c889674">
| <video
src="https://github.com/user-attachments/assets/1a0fcee7-32d4-42a6-8003-25b89087e580">
|

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 26, 2026
@github-actions github-actions Bot modified the milestones: .NET 10 SR11, .NET 10 SR12 Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebView.CanGoBack on Windows Returns true When it Shouldn't

7 participants