Skip to content

LibWeb+LibWebView: On error pages, name the URL that actually failed - #11016

Merged
gmta merged 2 commits into
LadybirdBrowser:masterfrom
sideshowbarker:fix-error-page-url-after-redirect
Aug 14, 2026
Merged

LibWeb+LibWebView: On error pages, name the URL that actually failed#11016
gmta merged 2 commits into
LadybirdBrowser:masterfrom
sideshowbarker:fix-error-page-url-after-redirect

Conversation

@sideshowbarker

@sideshowbarker sideshowbarker commented Aug 5, 2026

Copy link
Copy Markdown
Member

Problem: When a navigation is redirected (e.g., from http to https) and the fetch of the redirect target then fails (e.g., on a TLS cert-verification failure), we misreport which URL failed — in two places: (1) The error page names the URL the navigation started at (e.g., the http one) — rather than the one that actually failed (e.g., the https one). And (2) once the inline error page commits, the URL bar shows about:error (the internal URL of the error document), instead of the address that failed to load. That same clobber also makes the WebDriver “navigate to” flow treat every failing load as never finishing — so it times out; no session history entry matches about:error.

Cause: Two separate defects: (1) populate_session_history_entry_document() moves result->redirected_url into output->redirected_url right after it allocates output; the error-page branch below then reads result->redirected_url.value_or(url). A moved-from Optional is always empty, so the fallback to the pre-redirect URL is taken unconditionally, and the redirect-aware code there is dead by construction. And separately, (2) when a document finishes loading, WebContent reports that document’s URL, and did_finish_loading() stores it as the view’s URL. Documents created for inline error content carry the reserved URL about:error (per the HTML spec); so, that internal URL clobbers the session-history-entry URL (the URL that failed to load, after any redirects) — which the view already received when the entry committed.

Fix: Read the redirect target from output->redirected_url, the field the transfer populates, and comment the transfer point so readers know result’s redirect fields must not be read past it. Treat an about:error finish like the suppressed-history case, and keep the URL the view already shows. Firefox and Chromium likewise never surface their internal error-document URLs (about:neterror and chrome-error://chromewebdata): Both show the URL that actually failed to load. Fixes #11014.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d94d1bb8-d4cd-44a2-b0b5-86fdcc7ecaef

📥 Commits

Reviewing files that changed from the base of the PR and between c7545cd and 087d60c.

📒 Files selected for processing (5)
  • Libraries/LibWeb/HTML/LocalNavigable.cpp
  • Libraries/LibWebView/WebContentClient.cpp
  • Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt
  • Tests/LibWeb/Text/input/navigation/error-page-after-failed-redirected-navigation.html
  • Tests/LibWebView/test-webdriver-session-history.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • Libraries/LibWeb/HTML/LocalNavigable.cpp
  • Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt
  • Libraries/LibWebView/WebContentClient.cpp
  • Tests/LibWebView/test-webdriver-session-history.py

📝 Walkthrough

Walkthrough

The navigation failure path now uses the final redirected URL. Error-document loads preserve the existing view URL. Text and WebDriver tests verify error-page output, displayed URLs, and session history.

Changes

Failed redirected navigation

Layer / File(s) Summary
Error-page URL selection
Libraries/LibWeb/HTML/LocalNavigable.cpp
Navigation-failure error pages now read redirected URL metadata from output after it receives the redirect fields.
Error-document URL preservation
Libraries/LibWebView/WebContentClient.cpp
did_finish_loading preserves the existing view URL when the completed document URL is about:error.
Redirect-failure validation
Tests/LibWeb/Text/input/navigation/error-page-after-failed-redirected-navigation.html, Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt, Tests/LibWebView/test-webdriver-session-history.py
Tests cover failed TLS redirects and verify the failed destination URL in the error page, UI state, and WebContent session history.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BrowserTest
  participant LocalNavigable
  participant WebContentClient
  participant SessionHistory
  BrowserTest->>LocalNavigable: navigate through redirect
  LocalNavigable->>WebContentClient: complete with about:error
  WebContentClient->>SessionHistory: preserve failed destination URL
  BrowserTest->>SessionHistory: verify displayed URL and history entries
Loading
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the redirect failure, error-page URL, URL bar, and WebDriver fixes in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sideshowbarker sideshowbarker changed the title LibWeb+LibWebView: Name the URL that actually failed on error pages LibWeb+LibWebView: On error pages, name the URL that actually failed Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Tests/LibWebView/test-webdriver-session-history.py`:
- Around line 2253-2269: Update the wait_for_session_history predicate in the
failed redirected navigation test to require WebContent history convergence as
well as the existing UI URL match, using webContentHistoryMatchesUI or an
equivalent check that expects [url_a, url_tls_failure]. Keep the subsequent
WebContent assertion unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 965280b4-1479-4280-a6ba-1dec559358dc

📥 Commits

Reviewing files that changed from the base of the PR and between a35d615 and 4fb0c96.

📒 Files selected for processing (5)
  • Libraries/LibWeb/HTML/LocalNavigable.cpp
  • Libraries/LibWebView/WebContentClient.cpp
  • Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt
  • Tests/LibWeb/Text/input/navigation/error-page-after-failed-redirected-navigation.html
  • Tests/LibWebView/test-webdriver-session-history.py

Comment thread Tests/LibWebView/test-webdriver-session-history.py
@sideshowbarker
sideshowbarker force-pushed the fix-error-page-url-after-redirect branch from 4fb0c96 to 7ffe705 Compare August 6, 2026 00:10
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@Tests/LibWeb/Text/input/navigation/error-page-after-failed-redirected-navigation.html`:
- Line 24: Bound the polling loop around dumpContains("Failed to load") with a
deadline or maximum poll count, and call the test’s failure path when the
condition is still false at the limit; preserve the existing polling and done()
flow when the error page appears.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d34acb65-46f8-43f5-b4dd-aef4739e2490

📥 Commits

Reviewing files that changed from the base of the PR and between c7545cd and 7ffe705.

📒 Files selected for processing (5)
  • Libraries/LibWeb/HTML/LocalNavigable.cpp
  • Libraries/LibWebView/WebContentClient.cpp
  • Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt
  • Tests/LibWeb/Text/input/navigation/error-page-after-failed-redirected-navigation.html
  • Tests/LibWebView/test-webdriver-session-history.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • Libraries/LibWebView/WebContentClient.cpp
  • Libraries/LibWeb/HTML/LocalNavigable.cpp
  • Tests/LibWeb/Text/expected/navigation/error-page-after-failed-redirected-navigation.txt
  • Tests/LibWebView/test-webdriver-session-history.py

Problem: When a server redirects a navigation (e.g., from http to https)
and the fetch of the redirect target then fails (say, with a TLS cert-
verification failure), the error page names the start URL (e.g., the
http URL) instead of the URL that actually failed (e.g., the https URL).

Cause: populate_session_history_entry_document() moves result->
redirected_url into output->redirected_url right after it allocates
output. The subsequent error-page branch then reads result->
redirected_url.value_or(url). But a moved-from Optional is always empty;
so, the fallback to the pre-redirect URL is taken unconditionally and
the redirect-aware code there is dead by construction.

Fix: Read the redirect target from output->redirected_url (the field the
transfer populated) and comment the transfer point — so readers know
result’s redirect fields must not be read past it.

Fixes LadybirdBrowser#11014
Problem: After a failed navigation commits the browser’s inline error
page, the URL bar shows “about:error” — the internal URL of the error
document — instead of the address that failed to load. The WebDriver
“navigate to” flow also treats such loads as never finishing and times
out — since no session history entry matches about:error. Seen in
issue LadybirdBrowser#11014, where an http-to-https redirect failed TLS verification,
and the URL bar ended up not naming the https URL that failed.

Cause: When a document finishes loading, WebContent reports the
document’s URL, and did_finish_loading() stores it as the view’s URL.
Documents created for inline error content have the reserved URL
about:error (per the HTML spec), so that internal URL clobbers the
session-history-entry URL — the URL that failed to load, after any
redirects — which the view already received when the entry committed.

Fix: Treat an about:error finish like the suppressed-history case, and
keep the URL the view already shows. Firefox/Chromium also never surface
their internal error-document URLs (chrome-error://chromewebdata and
about:neterror): Both show the URL that actually failed to load.
@sideshowbarker
sideshowbarker force-pushed the fix-error-page-url-after-redirect branch from 7ffe705 to 087d60c Compare August 6, 2026 00:29
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@gmta
gmta merged commit f9894ab into LadybirdBrowser:master Aug 14, 2026
15 checks passed
@sideshowbarker
sideshowbarker deleted the fix-error-page-url-after-redirect branch August 15, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http:// SSL error shown when server redirects to https:// with invalid cert

2 participants