Skip to content

Truly independent web browser

LibWebView: Mark the entry a history job populated as ever populated

sideshowbarkere83376472542
diff --git a/Libraries/LibWebView/CanonicalNavigable.cpp b/Libraries/LibWebView/CanonicalNavigable.cpp
index b4afd9b552e..e3959132820 100644
--- a/Libraries/LibWebView/CanonicalNavigable.cpp
+++ b/Libraries/LibWebView/CanonicalNavigable.cpp
@@ -1548,6 +1548,11 @@ void CanonicalNavigable::apply_populated_history_entry(CanonicalSessionHistoryEn
entry.classic_history_api_state = populated_entry.classic_history_api_state;
if (populated_entry.document_state.id == entry.document_state->id) {
entry.document_state->resource = populated_entry.document_state.resource;
+ // https://html.spec.whatwg.org/multipage/browsing-the-web.html#populating-a-session-history-entry
+ // 7.1. Set entry's document state's ever populated to true.
+ // NB: The populated entry is the UI process's population request, which can't know that a document came of it.
+ // The entry holds the document that was populated for it.
+ entry.document_state->ever_populated = true;
return;
}
@@ -1561,6 +1566,8 @@ void CanonicalNavigable::apply_populated_history_entry(CanonicalSessionHistoryEn
document_state->populated_document = exchange(entry.document_state->populated_document, {});
if (m_document_state_populated_by_history_job == entry.document_state)
m_document_state_populated_by_history_job = document_state;
+ // 7.1. Set entry's document state's ever populated to true.
+ document_state->ever_populated = true;
entry.document_state = move(document_state);
}
diff --git a/Tests/LibWebView/test-webdriver-session-history.py b/Tests/LibWebView/test-webdriver-session-history.py
index 5d41c1d580f..a4f557932b5 100755
--- a/Tests/LibWebView/test-webdriver-session-history.py
+++ b/Tests/LibWebView/test-webdriver-session-history.py
@@ -2095,6 +2095,30 @@ def run_failed_redirected_navigation_shows_failed_url_test(webdriver_port, page_
request(webdriver_port, "DELETE", f"/session/{session_id}")
+def run_back_to_reloaded_initial_about_blank_test(webdriver_port, url_a):
+ # Reloading the initial about:blank leaves a document that isn't initial, so the navigation from it adds an entry
+ # rather than replacing it, and going back traverses to the entry the reload populated.
+ session_id = create_session(webdriver_port)
+ try:
+ log = [f"reloaded initial about:blank: {current_url(webdriver_port, session_id)}"]
+ execute_script(webdriver_port, session_id, "window.beforeReload = true; return null;")
+ refresh(webdriver_port, session_id)
+ wait_for_script_result(
+ webdriver_port,
+ session_id,
+ "reloaded initial about:blank",
+ "return [window.beforeReload === undefined, document.readyState];",
+ lambda result: result == [True, "complete"],
+ log,
+ )
+ load_url_from_ui(webdriver_port, session_id, url_a)
+ expect_url(webdriver_port, session_id, "after leaving the reloaded about:blank", url_a, log)
+ request(webdriver_port, "POST", f"/session/{session_id}/back", {})
+ expect_url(webdriver_port, session_id, "back to the reloaded about:blank", "about:blank", log)
+ finally:
+ request(webdriver_port, "DELETE", f"/session/{session_id}")
+
+
def run_self_contained_navigation_tests(webdriver_port, page_port, url_a):
run_webdriver_fragment_navigation_test(webdriver_port, url_a)
run_webdriver_intercepted_navigation_click_test(
@@ -3070,6 +3094,8 @@ def run_test(webdriver_binary):
request(webdriver_port, "DELETE", f"/session/{session_id}")
session_id = None
+ run_back_to_reloaded_initial_about_blank_test(webdriver_port, url_a)
+
session_id = create_session(webdriver_port)
log = [f"first-entry replace initial: {current_url(webdriver_port, session_id)}"]
load_url_from_ui(webdriver_port, session_id, url_a)