Skip to content

Truly independent web browser

LibWeb+LibWebView+WebContent: Give each document a cross-process id

Shannon Boothf2650d31d22a
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index 0c00d11fb23..c449cdf65c7 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -480,6 +480,7 @@ WebIDL::ExceptionOr<GC::Ref<Document>> Document::create_and_initialize(Type type
document->m_was_created_via_cross_origin_redirects = navigation_params.response->redirect_taint() != Fetch::Infrastructure::RedirectTaint::SameOrigin;
document->m_about_base_url = navigation_params.about_base_url;
document->set_url(*creation_url);
+ document->set_id(navigation_params.document_id.has_value() ? *navigation_params.document_id : browsing_context->page().client().allocate_cross_process_id());
// AD-HOC: Record when the readiness becomes "loading" for PerformanceTiming's domLoading. The window is not yet
// associated with document, so relate the time to loadTimingInfo directly.
@@ -1872,6 +1873,12 @@ void Document::respond_to_base_url_changes(URL::URL const& old_document_url, URL
// FIXME: 4. Consider speculative loads given document.
}
+void Document::set_id(HTML::CrossProcessId id)
+{
+ VERIFY(!m_id.has_value());
+ m_id = id;
+}
+
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#set-the-url
void Document::set_url(URL::URL const& url)
{
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index d25ce516c20..5b2bae441f1 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -960,6 +960,9 @@ public:
bool is_initial_about_blank() const { return m_is_initial_about_blank; }
void set_is_initial_about_blank(bool b) { m_is_initial_about_blank = b; }
+ HTML::CrossProcessId id() const { return m_id.value(); }
+ void set_id(HTML::CrossProcessId);
+
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url
Optional<URL::URL> about_base_url() const { return m_about_base_url; }
void set_about_base_url(Optional<URL::URL> url)
@@ -1915,6 +1918,7 @@ private:
// https://html.spec.whatwg.org/multipage/dom.html#is-initial-about:blank
bool m_is_initial_about_blank { false };
+ Optional<HTML::CrossProcessId> m_id;
// https://html.spec.whatwg.org/multipage/dom.html#concept-document-about-base-url
Optional<URL::URL> m_about_base_url;
diff --git a/Libraries/LibWeb/DOM/DocumentLoading.h b/Libraries/LibWeb/DOM/DocumentLoading.h
index bdb8d10ec7f..e75e31027ef 100644
--- a/Libraries/LibWeb/DOM/DocumentLoading.h
+++ b/Libraries/LibWeb/DOM/DocumentLoading.h
@@ -20,7 +20,7 @@ bool can_load_document_with_type(MimeSniff::MimeType const&);
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-ua-inline
template<typename MutateDocument>
-GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::LocalNavigable> navigable, Optional<Utf16String> navigation_id, Bindings::NavigationTimingType navigation_timing_type, HTML::UserNavigationInvolvement user_involvement, URL::Origin origin, MutateDocument mutate_document)
+GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::LocalNavigable> navigable, Optional<Utf16String> navigation_id, Bindings::NavigationTimingType navigation_timing_type, HTML::UserNavigationInvolvement user_involvement, URL::Origin origin, Optional<HTML::CrossProcessId> document_id, MutateDocument mutate_document)
{
VERIFY(navigable->active_document());
@@ -77,6 +77,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::LocalNav
navigation_timing_type,
OptionalNone {},
user_involvement);
+ navigation_params->document_id = document_id;
// 5. Let document be the result of creating and initializing a Document object given "html", "text/html", and navigationParams.
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_utf16_fly_string, navigation_params).release_value_but_fixme_should_propagate_errors();
diff --git a/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Libraries/LibWeb/HTML/BrowsingContext.cpp
index a0aebd51741..69d1aae8c3c 100644
--- a/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -34,7 +34,7 @@ namespace Web::HTML {
GC_DEFINE_ALLOCATOR(BrowsingContext);
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context
-BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener)
+BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener, Optional<CrossProcessId> document_id)
{
// 1. Let openerTopLevelBrowsingContext be opener's top-level traversable's active browsing context.
// 2. Let group be openerTopLevelBrowsingContext's group.
@@ -42,7 +42,7 @@ BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_auxili
// NB: The UI process holds the group.
// 4. Set browsingContext and document be the result of creating a new browsing context and document with opener's active document, null, and group.
- auto [browsing_context, document] = create_a_new_browsing_context_and_document(page, opener->active_document(), nullptr);
+ auto [browsing_context, document] = create_a_new_browsing_context_and_document(page, opener->active_document(), nullptr, {}, {}, document_id);
// 5. Set browsingContext's is auxiliary to true.
browsing_context->m_is_auxiliary = true;
@@ -72,7 +72,7 @@ static void populate_with_html_head_body(GC::Ref<DOM::Document> document)
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context
-BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ptr<WindowProxy> existing_window_proxy, Optional<URL::Origin> determined_origin)
+BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ptr<WindowProxy> existing_window_proxy, Optional<URL::Origin> determined_origin, Optional<CrossProcessId> document_id)
{
// 1. Let browsingContext be a new browsing context.
GC::Ref<BrowsingContext> browsing_context = *GC::Heap::the().allocate<BrowsingContext>(page);
@@ -165,6 +165,7 @@ BrowsingContext::BrowsingContextAndDocument BrowsingContext::create_a_new_browsi
// Non-standard
window->set_associated_document(*document);
document->set_window(*window);
+ document->set_id(document_id.has_value() ? *document_id : page->client().allocate_cross_process_id());
// type: "html"
document->set_document_type(DOM::Document::Type::HTML);
diff --git a/Libraries/LibWeb/HTML/BrowsingContext.h b/Libraries/LibWeb/HTML/BrowsingContext.h
index 57ba9ecb093..da44a396cae 100644
--- a/Libraries/LibWeb/HTML/BrowsingContext.h
+++ b/Libraries/LibWeb/HTML/BrowsingContext.h
@@ -30,8 +30,8 @@ public:
GC::Ref<DOM::Document> document;
};
- static BrowsingContextAndDocument create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ptr<WindowProxy> existing_window_proxy = {}, Optional<URL::Origin> determined_origin = {});
- static BrowsingContextAndDocument create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener);
+ static BrowsingContextAndDocument create_a_new_browsing_context_and_document(GC::Ref<Page> page, GC::Ptr<DOM::Document> creator, GC::Ptr<DOM::Element> embedder, GC::Ptr<WindowProxy> existing_window_proxy = {}, Optional<URL::Origin> determined_origin = {}, Optional<CrossProcessId> document_id = {});
+ static BrowsingContextAndDocument create_a_new_auxiliary_browsing_context_and_document(GC::Ref<Page> page, GC::Ref<HTML::BrowsingContext> opener, Optional<CrossProcessId> document_id);
virtual ~BrowsingContext() override;
diff --git a/Libraries/LibWeb/HTML/HistoryExecutor.cpp b/Libraries/LibWeb/HTML/HistoryExecutor.cpp
index 77b7d86bf03..57599fe0ddb 100644
--- a/Libraries/LibWeb/HTML/HistoryExecutor.cpp
+++ b/Libraries/LibWeb/HTML/HistoryExecutor.cpp
@@ -568,6 +568,7 @@ bool HistoryExecutor::run_changing_navigable_history_step_job_impl(ChangingNavig
output->classic_history_api_state = move(result.classic_history_api_state);
output->resource_cleared = result.resource_cleared;
output->inline_content_origin = move(result.inline_content_origin);
+ output->document_id = result.document_id;
if (result.replacement_document_state.has_value()) {
output->replacement_document_state = DocumentState::create(result.replacement_document_state->id);
apply_session_history_document_state_descriptor_from_ui_process(*output->replacement_document_state, *result.replacement_document_state);
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cpp
index 7d5e211f0c5..cec022c7ffd 100644
--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp
+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp
@@ -959,6 +959,7 @@ void LocalNavigable::continue_navigation_at_population(NavigationPopulationReque
output->classic_history_api_state = move(result.classic_history_api_state);
output->resource_cleared = result.resource_cleared;
output->inline_content_origin = move(result.inline_content_origin);
+ output->document_id = result.document_id;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
// 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run
@@ -1893,7 +1894,7 @@ LocalNavigable::ChosenNavigable LocalNavigable::choose_a_navigable(Utf16View nam
window_type = new_window_type;
auto create_new_traversable = [&](GC::Ptr<BrowsingContext> opener) -> GC::Ref<LocalTraversableNavigable> {
- auto traversable = LocalTraversableNavigable::create_a_new_top_level_traversable(*new_web_view.page, opener, new_web_view.initial_history_entry.release_value());
+ auto traversable = LocalTraversableNavigable::create_a_new_top_level_traversable(*new_web_view.page, opener, new_web_view.initial_history_entry.release_value(), new_web_view.initial_document_id.release_value());
traversable->active_document()->relevant_settings_object().id = new_web_view.initial_environment_id.release_value();
traversable->active_browsing_context()->set_browsing_context_group_id(new_web_view.browsing_context_group_id);
new_web_view.page->set_top_level_traversable(traversable);
@@ -3120,13 +3121,13 @@ static void report_a_document_with_an_origin_of_its_own(LocalNavigable& navigabl
auto origin = output.inline_content_origin.has_value() && output.document->origin().is_same_origin(*output.inline_content_origin)
? PopulatedDocumentOrigin::InlineContent
: PopulatedDocumentOrigin::PdfViewer;
- navigable.page().client().page_did_create_populated_document_with_an_origin_of_its_own(navigable.id(), origin, output.document->relevant_settings_object().id);
+ navigable.page().client().page_did_create_populated_document_with_an_origin_of_its_own(navigable.id(), output.document->id(), origin, output.document->relevant_settings_object().id);
}
-static GC::Ref<DOM::Document> create_navigation_error_document(LocalNavigable& navigable, Optional<Utf16String> const& navigation_id, Bindings::NavigationTimingType navigation_timing_type, UserNavigationInvolvement user_involvement, URL::Origin const& origin, URL::URL const& url, Utf16String const& error_message)
+static GC::Ref<DOM::Document> create_navigation_error_document(LocalNavigable& navigable, Optional<Utf16String> const& navigation_id, Bindings::NavigationTimingType navigation_timing_type, UserNavigationInvolvement user_involvement, URL::Origin const& origin, Optional<CrossProcessId> document_id, URL::URL const& url, Utf16String const& error_message)
{
auto error_html = load_error_page(url, error_message.to_utf8()).release_value_but_fixme_should_propagate_errors();
- return create_document_for_inline_content(&navigable, navigation_id, navigation_timing_type, user_involvement, origin, [error_html](auto& document) {
+ return create_document_for_inline_content(&navigable, navigation_id, navigation_timing_type, user_involvement, origin, document_id, [error_html](auto& document) {
auto scripting_mode = document.is_scripting_enabled() ? HTML::ParserScriptingMode::Normal : HTML::ParserScriptingMode::Disabled;
auto parser = HTMLParser::create_from_byte_string(document, error_html, scripting_mode, "utf-8"sv);
document.set_url(URL::about_error());
@@ -3161,6 +3162,7 @@ static void load_document_or_handle_download(GC::Ref<NavigationParams> navigatio
navigation_params->navigation_timing_type,
navigation_params->user_involvement,
output.inline_content_origin.value(),
+ navigation_params->document_id,
output.redirected_url.value_or(url),
error_message);
@@ -3195,6 +3197,8 @@ void LocalNavigable::queue_navigation_and_traversal_task_for_session_history_ent
stop_or_resume_response_body_delivery(navigation_params);
return;
}
+ if (auto* params = navigation_params.get_pointer<GC::Ref<NavigationParams>>())
+ (*params)->document_id = output->document_id;
// 5. Queue a global task on the navigation and traversal task source, given navigable's active window, to run these steps:
queue_global_task(Task::Source::NavigationAndTraversal, HTML::relevant_global_object(*active_window()), GC::create_function(heap(), [this, url, source_allows_downloading, source_interface_origin, user_involvement, navigation_id, navigation_params, csp_navigation_type, navigation_timing_type, output, completion_steps]() mutable {
@@ -3243,7 +3247,7 @@ void LocalNavigable::queue_navigation_and_traversal_task_for_session_history_ent
// AD-HOC: Name the URL that actually failed to load: The last URL the navigation was redirected to, if
// any — rather than the URL it started at.
auto error_url = output->redirected_url.value_or(url);
- output->document = create_navigation_error_document(*this, navigation_id, navigation_timing_type, user_involvement, output->inline_content_origin.value(), error_url, error_message);
+ output->document = create_navigation_error_document(*this, navigation_id, navigation_timing_type, user_involvement, output->inline_content_origin.value(), output->document_id, error_url, error_message);
// 2. Make document unsalvageable given entry's document state's document and "navigation-failure".
if (output->document)
@@ -4702,6 +4706,7 @@ void finalize_a_cross_document_navigation(GC::Ref<LocalNavigable> navigable, His
.history_handling = history_handling,
.user_involvement = user_involvement,
.environment_id = pending_document ? Optional<Web::HTML::EnvironmentId> { pending_document->relevant_settings_object().id } : Optional<Web::HTML::EnvironmentId> {},
+ .document_id = pending_document ? Optional<CrossProcessId> { pending_document->id() } : Optional<CrossProcessId> {},
},
{
.pending_document = pending_document,
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.h b/Libraries/LibWeb/HTML/LocalNavigable.h
index 307999fcf46..3ec4bf59473 100644
--- a/Libraries/LibWeb/HTML/LocalNavigable.h
+++ b/Libraries/LibWeb/HTML/LocalNavigable.h
@@ -723,6 +723,7 @@ public:
RefPtr<DocumentState> replacement_document_state;
bool resource_cleared = false;
Optional<URL::Origin> inline_content_origin;
+ Optional<CrossProcessId> document_id;
void apply_to(NonnullRefPtr<SessionHistoryEntry> entry);
diff --git a/Libraries/LibWeb/HTML/LocalTraversableNavigable.cpp b/Libraries/LibWeb/HTML/LocalTraversableNavigable.cpp
index 1437fb348d9..ce0b77e1599 100644
--- a/Libraries/LibWeb/HTML/LocalTraversableNavigable.cpp
+++ b/Libraries/LibWeb/HTML/LocalTraversableNavigable.cpp
@@ -44,7 +44,7 @@ LocalTraversableNavigable::LocalTraversableNavigable(GC::Ref<Page> page)
LocalTraversableNavigable::~LocalTraversableNavigable() = default;
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-traversable
-GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_new_top_level_traversable(GC::Ref<Page> page, GC::Ptr<HTML::BrowsingContext> opener, Optional<SessionHistoryEntryDescriptor> initial_history_entry_from_owner)
+GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_new_top_level_traversable(GC::Ref<Page> page, GC::Ptr<HTML::BrowsingContext> opener, Optional<SessionHistoryEntryDescriptor> initial_history_entry_from_owner, Optional<CrossProcessId> document_id)
{
auto& vm = Bindings::main_thread_vm();
page->ensure_compositor_host();
@@ -61,12 +61,12 @@ GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_new_top_l
// 2. If opener is null, then set document to the second return value of creating a new top-level browsing context and document.
// NB: The UI process holds the group a top-level browsing context is created in.
if (!opener) {
- document = BrowsingContext::create_a_new_browsing_context_and_document(page, nullptr, nullptr, {}, initial_entry.document_state.origin).document;
+ document = BrowsingContext::create_a_new_browsing_context_and_document(page, nullptr, nullptr, {}, initial_entry.document_state.origin, document_id).document;
}
// 3. Otherwise, set document to the second return value of creating a new auxiliary browsing context and document given opener.
else {
- document = BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(page, *opener).document;
+ document = BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(page, *opener, document_id).document;
}
// 4. Let documentState be a new document state, with
@@ -118,10 +118,10 @@ GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_new_top_l
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#create-a-fresh-top-level-traversable
-GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_fresh_top_level_traversable(GC::Ref<Page> page, SessionHistoryEntryDescriptor initial_history_entry)
+GC::Ref<LocalTraversableNavigable> LocalTraversableNavigable::create_a_fresh_top_level_traversable(GC::Ref<Page> page, SessionHistoryEntryDescriptor initial_history_entry, CrossProcessId document_id)
{
// 1. Let traversable be the result of creating a new top-level traversable given null and the empty string.
- auto traversable = create_a_new_top_level_traversable(page, nullptr, move(initial_history_entry));
+ auto traversable = create_a_new_top_level_traversable(page, nullptr, move(initial_history_entry), document_id);
page->set_top_level_traversable(traversable);
// AD-HOC: Mark the about:blank document as finished parsing. This matches the behavior of the window open steps.
diff --git a/Libraries/LibWeb/HTML/LocalTraversableNavigable.h b/Libraries/LibWeb/HTML/LocalTraversableNavigable.h
index 2367a145ff3..19fc58080ac 100644
--- a/Libraries/LibWeb/HTML/LocalTraversableNavigable.h
+++ b/Libraries/LibWeb/HTML/LocalTraversableNavigable.h
@@ -27,8 +27,8 @@ class WEB_API LocalTraversableNavigable final : public LocalNavigable {
GC_DECLARE_ALLOCATOR(LocalTraversableNavigable);
public:
- static GC::Ref<LocalTraversableNavigable> create_a_new_top_level_traversable(GC::Ref<Page>, GC::Ptr<BrowsingContext> opener, Optional<SessionHistoryEntryDescriptor> initial_history_entry = {});
- static GC::Ref<LocalTraversableNavigable> create_a_fresh_top_level_traversable(GC::Ref<Page>, SessionHistoryEntryDescriptor initial_history_entry);
+ static GC::Ref<LocalTraversableNavigable> create_a_new_top_level_traversable(GC::Ref<Page>, GC::Ptr<BrowsingContext> opener, Optional<SessionHistoryEntryDescriptor> initial_history_entry = {}, Optional<CrossProcessId> document_id = {});
+ static GC::Ref<LocalTraversableNavigable> create_a_fresh_top_level_traversable(GC::Ref<Page>, SessionHistoryEntryDescriptor initial_history_entry, CrossProcessId document_id);
static GC::Ref<LocalTraversableNavigable> create_stand_in(Badge<Page>, RemoteNavigable&, SessionHistoryEntryDescriptor const& current_history_entry);
virtual ~LocalTraversableNavigable() override;
diff --git a/Libraries/LibWeb/HTML/NavigableContainer.cpp b/Libraries/LibWeb/HTML/NavigableContainer.cpp
index ea82b7c703c..8e8153df935 100644
--- a/Libraries/LibWeb/HTML/NavigableContainer.cpp
+++ b/Libraries/LibWeb/HTML/NavigableContainer.cpp
@@ -113,7 +113,7 @@ void NavigableContainer::create_new_child_navigable()
// 10. Let historyEntry be navigable's active session history entry.
auto history_entry = navigable->active_session_history_entry();
- page.client().page_did_create_child_frame(parent_navigable->id(), navigable->id(), navigable->hosted_state(), create_pending_session_history_entry_descriptor(*history_entry), document->origin(), document->relevant_settings_object().id);
+ page.client().page_did_create_child_frame(parent_navigable->id(), navigable->id(), navigable->hosted_state(), create_pending_session_history_entry_descriptor(*history_entry), document->origin(), document->relevant_settings_object().id, document->id());
// 12. Append the following session history traversal steps to traversable:
page.history_executor().request_history_operation(
diff --git a/Libraries/LibWeb/HTML/NavigationParams.h b/Libraries/LibWeb/HTML/NavigationParams.h
index 16d9cb52420..c44c76fd25d 100644
--- a/Libraries/LibWeb/HTML/NavigationParams.h
+++ b/Libraries/LibWeb/HTML/NavigationParams.h
@@ -20,6 +20,7 @@
#include <LibWeb/HTML/UserNavigationInvolvement.h>
#include <LibWebCommon/HTML/CrossOrigin/OpenerPolicy.h>
#include <LibWebCommon/HTML/CrossOrigin/OpenerPolicyEnforcementResult.h>
+#include <LibWebCommon/HTML/CrossProcessId.h>
#include <LibWebCommon/HTML/NavigationParamsDescriptor.h>
#include <LibWebCommon/HTML/SandboxingFlagSet.h>
#include <LibWebCommon/ReferrerPolicy/ReferrerPolicy.h>
@@ -54,6 +55,9 @@ struct NavigationParams : GC::Cell {
// AD-HOC: The agent cluster of the agent the UI process obtained for the new Document's window.
Optional<u64> agent_cluster_id;
+ // AD-HOC: The id the UI process gave the new Document.
+ Optional<CrossProcessId> document_id;
+
// AD-HOC: The group of the new top-level browsing context the UI process obtained for the new Document, when a
// browsing context group switch gave it one.
Optional<u64> new_browsing_context_group_id;
diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.h
index 2f567aa830a..3b3ba1408e0 100644
--- a/Libraries/LibWeb/Page/Page.h
+++ b/Libraries/LibWeb/Page/Page.h
@@ -607,8 +607,8 @@ public:
virtual void navigation_params_creation_finished(HTML::LocalNavigable&, HTML::NavigationPopulationRequest, HTML::NavigationPopulationResult);
virtual void history_navigation_params_creation_finished(HTML::CrossProcessId operation_id, HTML::HistoryNavigationPopulation);
virtual void navigation_population_failed(HTML::CrossProcessId, Utf16String const&) { }
- virtual void page_did_create_populated_document_with_an_origin_of_its_own(HTML::CrossProcessId, HTML::PopulatedDocumentOrigin, HTML::EnvironmentId const&) { }
- virtual void page_did_create_child_frame(HTML::CrossProcessId, HTML::CrossProcessId, HTML::HostedNavigableState const&, HTML::PendingSessionHistoryEntryDescriptor const&, URL::Origin const&, HTML::EnvironmentId const&) { }
+ virtual void page_did_create_populated_document_with_an_origin_of_its_own(HTML::CrossProcessId, HTML::CrossProcessId, HTML::PopulatedDocumentOrigin, HTML::EnvironmentId const&) { }
+ virtual void page_did_create_child_frame(HTML::CrossProcessId, HTML::CrossProcessId, HTML::HostedNavigableState const&, HTML::PendingSessionHistoryEntryDescriptor const&, URL::Origin const&, HTML::EnvironmentId const&, HTML::CrossProcessId) { }
virtual void page_did_change_hosted_navigable_state([[maybe_unused]] HTML::CrossProcessId navigable_id, [[maybe_unused]] HTML::HostedNavigableState const& state) { }
virtual void page_did_set_opener_browsing_context([[maybe_unused]] HTML::CrossProcessId navigable_id, [[maybe_unused]] Optional<HTML::CrossProcessId> opener_navigable_id) { }
virtual void page_did_completely_finish_loading([[maybe_unused]] HTML::CrossProcessId navigable_id) { }
@@ -751,6 +751,7 @@ public:
String window_handle;
Optional<HTML::SessionHistoryEntryDescriptor> initial_history_entry;
Optional<Web::HTML::EnvironmentId> initial_environment_id;
+ Optional<HTML::CrossProcessId> initial_document_id;
Optional<u64> browsing_context_group_id;
};
virtual NewWebViewResult page_did_request_new_web_view(HTML::ActivateTab, HTML::WebViewHints, [[maybe_unused]] Optional<HTML::CrossProcessId> opener_navigable_id, [[maybe_unused]] Optional<URL::URL> opener_base_url, [[maybe_unused]] Utf16String const& target_name, [[maybe_unused]] HTML::SandboxingFlagSet popup_sandboxing_flag_set) { return {}; }
diff --git a/Libraries/LibWebCommon/HTML/HistoryOperation.cpp b/Libraries/LibWebCommon/HTML/HistoryOperation.cpp
index 4354798383a..7a2b4b8fe19 100644
--- a/Libraries/LibWebCommon/HTML/HistoryOperation.cpp
+++ b/Libraries/LibWebCommon/HTML/HistoryOperation.cpp
@@ -17,6 +17,7 @@ ErrorOr<void> IPC::encode(Encoder& encoder, Web::FinalizeCrossDocumentNavigation
TRY(encoder.encode(parameters.history_handling));
TRY(encoder.encode(parameters.user_involvement));
TRY(encoder.encode(parameters.environment_id));
+ TRY(encoder.encode(parameters.document_id));
return {};
}
@@ -30,6 +31,7 @@ ErrorOr<Web::FinalizeCrossDocumentNavigationHistoryOperationParameters> IPC::dec
.history_handling = TRY(decoder.decode<Web::HTML::HistoryHandlingBehavior>()),
.user_involvement = TRY(decoder.decode<Web::HTML::UserNavigationInvolvement>()),
.environment_id = TRY(decoder.decode<Optional<Web::HTML::EnvironmentId>>()),
+ .document_id = TRY(decoder.decode<Optional<Web::HTML::CrossProcessId>>()),
};
}
diff --git a/Libraries/LibWebCommon/HTML/HistoryOperation.h b/Libraries/LibWebCommon/HTML/HistoryOperation.h
index 21411780598..7a1c52bc61e 100644
--- a/Libraries/LibWebCommon/HTML/HistoryOperation.h
+++ b/Libraries/LibWebCommon/HTML/HistoryOperation.h
@@ -29,6 +29,7 @@ struct FinalizeCrossDocumentNavigationHistoryOperationParameters {
HTML::HistoryHandlingBehavior history_handling;
HTML::UserNavigationInvolvement user_involvement;
Optional<Web::HTML::EnvironmentId> environment_id;
+ Optional<HTML::CrossProcessId> document_id;
};
struct ReconstructedChildNavigation {
diff --git a/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.cpp b/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.cpp
index 21986e25797..5a676dd5833 100644
--- a/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.cpp
+++ b/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.cpp
@@ -186,6 +186,7 @@ ErrorOr<void> encode(Encoder& encoder, Web::HTML::NavigationPopulationResult con
TRY(encoder.encode(result.replacement_document_state));
TRY(encoder.encode(result.resource_cleared));
TRY(encoder.encode(result.inline_content_origin));
+ TRY(encoder.encode(result.document_id));
return {};
}
@@ -199,6 +200,7 @@ ErrorOr<Web::HTML::NavigationPopulationResult> decode(Decoder& decoder)
.replacement_document_state = TRY(decoder.decode<Optional<Web::HTML::SessionHistoryDocumentStateDescriptor>>()),
.resource_cleared = TRY(decoder.decode<bool>()),
.inline_content_origin = TRY(decoder.decode<Optional<URL::Origin>>()),
+ .document_id = TRY(decoder.decode<Optional<Web::HTML::CrossProcessId>>()),
};
}
diff --git a/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.h b/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.h
index 62ac266173d..41ff066f177 100644
--- a/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.h
+++ b/Libraries/LibWebCommon/HTML/NavigationPopulationRequest.h
@@ -66,6 +66,7 @@ struct NavigationPopulationResult {
bool resource_cleared { false };
// The origin the UI process gives a document created for inline content in place of the response.
Optional<URL::Origin> inline_content_origin {};
+ Optional<CrossProcessId> document_id {};
};
struct HistoryNavigationPopulation {
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index f2f861e9ebd..6e4c26315dc 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -1070,6 +1070,7 @@ ErrorOr<NonnullRefPtr<WebContentClient>> Application::create_web_content_client(
auto root_navigable_id = navigable_to_adopt.has_value() ? *navigable_to_adopt : cross_process_id_allocator.allocate();
if (!initial_document_state_id.has_value())
initial_document_state_id = cross_process_id_allocator.allocate();
+ auto initial_document_id = cross_process_id_allocator.allocate();
auto client = TRY(WebView::launch_web_content_process(is_private, initial_page_id, root_navigable_id));
TRY(Application::the().connect_web_content_to_compositor(*client));
@@ -1085,10 +1086,10 @@ ErrorOr<NonnullRefPtr<WebContentClient>> Application::create_web_content_client(
entry.document_state.origin = URL::Origin::create_opaque();
return entry;
}();
- client->async_initialize(initial_page_id, move(remote_navigables), root_navigable_id, cross_process_id_allocator, initial_history_entry, system_visibility_state);
+ client->async_initialize(initial_page_id, move(remote_navigables), root_navigable_id, cross_process_id_allocator, initial_history_entry, initial_document_id, system_visibility_state);
if (!navigable_to_adopt.has_value())
- client->set_initial_top_level_history_entry({}, move(initial_history_entry));
+ client->set_initial_top_level_history_entry({}, move(initial_history_entry), initial_document_id);
client->request_server_site_bindings().did_connect(request_server_connection.client_id);
client->async_connect_to_request_server(move(request_server_connection.handle), request_server_connection.client_id);
diff --git a/Libraries/LibWebView/CanonicalBrowsingContext.cpp b/Libraries/LibWebView/CanonicalBrowsingContext.cpp
index 68215661e47..da8893240fa 100644
--- a/Libraries/LibWebView/CanonicalBrowsingContext.cpp
+++ b/Libraries/LibWebView/CanonicalBrowsingContext.cpp
@@ -31,7 +31,7 @@ Web::HTML::SandboxingFlagSet determine_the_creation_sandboxing_flags(CanonicalBr
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context
-CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_browsing_context_and_document(CanonicalDocument const* creator, Optional<Web::HTML::ReplicatedContainerState const&> embedder, CanonicalBrowsingContextGroup& group, Optional<Web::HTML::EnvironmentId> environment_id, Optional<URL::Origin> given_origin)
+CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_browsing_context_and_document(CanonicalDocument const* creator, Optional<Web::HTML::ReplicatedContainerState const&> embedder, CanonicalBrowsingContextGroup& group, Web::HTML::CrossProcessId document_id, Optional<Web::HTML::EnvironmentId> environment_id, Optional<URL::Origin> given_origin)
{
// 1. Let browsingContext be a new browsing context.
auto browsing_context = adopt_ref(*new CanonicalBrowsingContext);
@@ -85,7 +85,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::c
// origin: origin
// browsing context: browsingContext
// is initial about:blank: true
- auto document = CanonicalDocument::create(URL::about_blank(), origin, browsing_context, window, CanonicalDocument::IsInitialAboutBlank::Yes);
+ auto document = CanonicalDocument::create(document_id, URL::about_blank(), origin, browsing_context, window, CanonicalDocument::IsInitialAboutBlank::Yes);
// 19. If creator is non-null:
// 3. If creator's origin is same origin with creator's relevant settings object's top-level origin, then set
@@ -108,7 +108,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::c
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-browsing-context
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context-group-and-document
-CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document(Optional<URL::Origin> given_origin)
+CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document(Web::HTML::CrossProcessId document_id, Optional<URL::Origin> given_origin)
{
// NB: A group is kept alive by the browsing contexts in its browsing context set, so creating a new browsing context
// group and document is folded in here, where the browsing context holding the group is returned.
@@ -120,7 +120,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::c
CanonicalBrowsingContextGroup::append_to_user_agent_browsing_context_group_set(*group);
// 3. Let browsingContext and document be the result of creating a new browsing context and document with null, null, and group.
- auto browsing_context_and_document = create_a_new_browsing_context_and_document(nullptr, {}, *group, {}, move(given_origin));
+ auto browsing_context_and_document = create_a_new_browsing_context_and_document(nullptr, {}, *group, document_id, {}, move(given_origin));
// 4. Append browsingContext to group.
group->append(*browsing_context_and_document.browsing_context);
@@ -131,7 +131,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::c
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context
-CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(CanonicalNavigable& opener)
+CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(CanonicalNavigable& opener, Web::HTML::CrossProcessId document_id)
{
// 1. Let openerTopLevelBrowsingContext be opener's top-level traversable's active browsing context.
auto& opener_top_level_browsing_context = opener.top_level_traversable().active_browsing_context();
@@ -143,7 +143,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalBrowsingContext::c
VERIFY(group);
// 4. Let browsingContext and document be the result of creating a new browsing context and document with opener's active document, null, and group.
- auto browsing_context_and_document = create_a_new_browsing_context_and_document(&opener.active_document(), {}, *group, {});
+ auto browsing_context_and_document = create_a_new_browsing_context_and_document(&opener.active_document(), {}, *group, document_id, {});
// 5. Set browsingContext's is auxiliary to true.
browsing_context_and_document.browsing_context->m_is_auxiliary = true;
diff --git a/Libraries/LibWebView/CanonicalBrowsingContext.h b/Libraries/LibWebView/CanonicalBrowsingContext.h
index 4a72463f8e6..8350f2eff40 100644
--- a/Libraries/LibWebView/CanonicalBrowsingContext.h
+++ b/Libraries/LibWebView/CanonicalBrowsingContext.h
@@ -15,6 +15,7 @@
#include <AK/WeakPtr.h>
#include <LibURL/Origin.h>
#include <LibWebCommon/Forward.h>
+#include <LibWebCommon/HTML/CrossProcessId.h>
#include <LibWebCommon/HTML/SandboxingFlagSet.h>
#include <LibWebView/CanonicalDocument.h>
#include <LibWebView/Export.h>
@@ -30,9 +31,9 @@ public:
NonnullRefPtr<CanonicalDocument> document;
};
- static BrowsingContextAndDocument create_a_new_browsing_context_and_document(CanonicalDocument const* creator, Optional<Web::HTML::ReplicatedContainerState const&> embedder, CanonicalBrowsingContextGroup&, Optional<Web::HTML::EnvironmentId> environment_id, Optional<URL::Origin> given_origin = {});
- static BrowsingContextAndDocument create_a_new_top_level_browsing_context_and_document(Optional<URL::Origin> given_origin = {});
- static BrowsingContextAndDocument create_a_new_auxiliary_browsing_context_and_document(CanonicalNavigable& opener);
+ static BrowsingContextAndDocument create_a_new_browsing_context_and_document(CanonicalDocument const* creator, Optional<Web::HTML::ReplicatedContainerState const&> embedder, CanonicalBrowsingContextGroup&, Web::HTML::CrossProcessId document_id, Optional<Web::HTML::EnvironmentId> environment_id, Optional<URL::Origin> given_origin = {});
+ static BrowsingContextAndDocument create_a_new_top_level_browsing_context_and_document(Web::HTML::CrossProcessId document_id, Optional<URL::Origin> given_origin = {});
+ static BrowsingContextAndDocument create_a_new_auxiliary_browsing_context_and_document(CanonicalNavigable& opener, Web::HTML::CrossProcessId document_id);
~CanonicalBrowsingContext();
diff --git a/Libraries/LibWebView/CanonicalDocument.cpp b/Libraries/LibWebView/CanonicalDocument.cpp
index 31a6360fc74..80a9d6ce406 100644
--- a/Libraries/LibWebView/CanonicalDocument.cpp
+++ b/Libraries/LibWebView/CanonicalDocument.cpp
@@ -17,9 +17,9 @@
namespace WebView {
-NonnullRefPtr<CanonicalDocument> CanonicalDocument::create(URL::URL creation_url, URL::Origin origin, NonnullRefPtr<CanonicalBrowsingContext> browsing_context, NonnullRefPtr<CanonicalWindow> relevant_global_object, IsInitialAboutBlank is_initial_about_blank)
+NonnullRefPtr<CanonicalDocument> CanonicalDocument::create(Web::HTML::CrossProcessId id, URL::URL creation_url, URL::Origin origin, NonnullRefPtr<CanonicalBrowsingContext> browsing_context, NonnullRefPtr<CanonicalWindow> relevant_global_object, IsInitialAboutBlank is_initial_about_blank)
{
- auto document = adopt_ref(*new CanonicalDocument(move(creation_url), move(origin), move(browsing_context), move(relevant_global_object), is_initial_about_blank));
+ auto document = adopt_ref(*new CanonicalDocument(id, move(creation_url), move(origin), move(browsing_context), move(relevant_global_object), is_initial_about_blank));
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#initialise-the-document-object
// 10. Set window's associated Document to document.
@@ -35,8 +35,9 @@ NonnullRefPtr<CanonicalDocument> CanonicalDocument::create(URL::URL creation_url
return document;
}
-CanonicalDocument::CanonicalDocument(URL::URL creation_url, URL::Origin origin, NonnullRefPtr<CanonicalBrowsingContext> browsing_context, NonnullRefPtr<CanonicalWindow> relevant_global_object, IsInitialAboutBlank is_initial_about_blank)
- : m_creation_url(move(creation_url))
+CanonicalDocument::CanonicalDocument(Web::HTML::CrossProcessId id, URL::URL creation_url, URL::Origin origin, NonnullRefPtr<CanonicalBrowsingContext> browsing_context, NonnullRefPtr<CanonicalWindow> relevant_global_object, IsInitialAboutBlank is_initial_about_blank)
+ : m_id(id)
+ , m_creation_url(move(creation_url))
, m_origin(move(origin))
, m_browsing_context(move(browsing_context))
, m_relevant_global_object(move(relevant_global_object))
diff --git a/Libraries/LibWebView/CanonicalDocument.h b/Libraries/LibWebView/CanonicalDocument.h
index e8b4c6dc006..6f3571ec1ea 100644
--- a/Libraries/LibWebView/CanonicalDocument.h
+++ b/Libraries/LibWebView/CanonicalDocument.h
@@ -13,6 +13,7 @@
#include <LibURL/Origin.h>
#include <LibURL/URL.h>
#include <LibWebCommon/HTML/CrossOrigin/OpenerPolicy.h>
+#include <LibWebCommon/HTML/CrossProcessId.h>
#include <LibWebView/Export.h>
#include <LibWebView/Forward.h>
@@ -28,10 +29,12 @@ public:
Yes,
};
- static NonnullRefPtr<CanonicalDocument> create(URL::URL creation_url, URL::Origin, NonnullRefPtr<CanonicalBrowsingContext>, NonnullRefPtr<CanonicalWindow>, IsInitialAboutBlank);
+ static NonnullRefPtr<CanonicalDocument> create(Web::HTML::CrossProcessId id, URL::URL creation_url, URL::Origin, NonnullRefPtr<CanonicalBrowsingContext>, NonnullRefPtr<CanonicalWindow>, IsInitialAboutBlank);
~CanonicalDocument();
+ Web::HTML::CrossProcessId id() const { return m_id; }
+
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url
URL::URL const& creation_url() const { return m_creation_url; }
@@ -75,8 +78,9 @@ public:
void make_active();
private:
- CanonicalDocument(URL::URL creation_url, URL::Origin, NonnullRefPtr<CanonicalBrowsingContext>, NonnullRefPtr<CanonicalWindow>, IsInitialAboutBlank);
+ CanonicalDocument(Web::HTML::CrossProcessId id, URL::URL creation_url, URL::Origin, NonnullRefPtr<CanonicalBrowsingContext>, NonnullRefPtr<CanonicalWindow>, IsInitialAboutBlank);
+ Web::HTML::CrossProcessId m_id;
URL::URL m_creation_url;
URL::Origin m_origin;
NonnullRefPtr<CanonicalBrowsingContext> m_browsing_context;
diff --git a/Libraries/LibWebView/CanonicalNavigable.cpp b/Libraries/LibWebView/CanonicalNavigable.cpp
index ea2ceb205d5..87dbd92901f 100644
--- a/Libraries/LibWebView/CanonicalNavigable.cpp
+++ b/Libraries/LibWebView/CanonicalNavigable.cpp
@@ -341,7 +341,7 @@ CanonicalBrowsingContext::BrowsingContextAndDocument CanonicalNavigable::obtain_
// 10. Let newBrowsingContext be the first return value of creating a new top-level browsing context and document.
// NB: The navigation response's document replaces that document before any process creates it.
- auto new_browsing_context = CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document();
+ auto new_browsing_context = CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({});
// 11. Let navigationCOOP be navigationParams's cross-origin opener policy.
auto const& navigation_coop = navigation_params.opener_policy;
@@ -416,7 +416,7 @@ NonnullRefPtr<CanonicalDocument> CanonicalNavigable::create_and_initialize_a_doc
// opener policy: navigationParams's cross-origin opener policy
// URL: creationURL
// NB: The process hosting window's agent creates the document, with its other fields, and runs the remaining steps.
- auto document = CanonicalDocument::create(move(creation_url), navigation_params.origin, browsing_context, window.release_nonnull(), CanonicalDocument::IsInitialAboutBlank::No);
+ auto document = CanonicalDocument::create(navigation_params.document_id, move(creation_url), navigation_params.origin, browsing_context, window.release_nonnull(), CanonicalDocument::IsInitialAboutBlank::No);
document->set_opener_policy(navigation_params.opener_policy);
// 22. Return document.
@@ -830,36 +830,36 @@ bool CanonicalNavigable::populate_document_for_javascript_url(NonnullRefPtr<Cano
// The process hosting a document populated for the navigable created it with an origin other than its navigation
// params': a document for inline content in place of a response it found blocked, or the PDF viewer.
-void CanonicalNavigable::did_create_populated_document_with_an_origin_of_its_own(WebContentPage const& host, Web::HTML::PopulatedDocumentOrigin populated_document_origin, Web::HTML::EnvironmentId const& environment_id)
-{
- auto replace = [&](Optional<PopulatedDocument>& populated_document) {
- if (!populated_document.has_value() || populated_document->document->host() != &host)
- return false;
+void CanonicalNavigable::did_create_populated_document_with_an_origin_of_its_own(WebContentPage const& host, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin populated_document_origin, Web::HTML::EnvironmentId const& environment_id)
+{
+ Optional<PopulatedDocument&> populated_document;
+ if (m_ongoing_navigation.has_value() && m_ongoing_navigation->populated_document.has_value() && m_ongoing_navigation->populated_document->document->id() == document_id)
+ populated_document = *m_ongoing_navigation->populated_document;
+ else if (m_document_populated_by_history_job.has_value() && m_document_populated_by_history_job->document->id() == document_id)
+ populated_document = *m_document_populated_by_history_job;
+ if (!populated_document.has_value() || populated_document->document->host() != &host)
+ return;
- auto is_inline_content = populated_document_origin == Web::HTML::PopulatedDocumentOrigin::InlineContent;
- if (is_inline_content && !populated_document->inline_content_origin.has_value())
- return false;
- // AD-HOC: The PDF viewer runs with an origin of its own.
- auto origin = is_inline_content ? *populated_document->inline_content_origin : URL::Origin { "resource"_string, String {}, {} };
-
- auto url = is_inline_content ? URL::about_error() : populated_document->document->creation_url();
- NavigationLoader::ResponseDocument response_document {
- .is_inline_content = is_inline_content,
- .coop_enforcement_result = { .url = url, .origin = origin, .opener_policy = {} },
- .response_url = url,
- .request_current_url = {},
- .origin = origin,
- .opener_policy = {},
- .environment_id = environment_id,
- };
- auto document = create_and_initialize_a_document(response_document);
- document->set_host(populated_document->document->host());
- populated_document->document = move(document);
- return true;
- };
- if (m_ongoing_navigation.has_value() && replace(m_ongoing_navigation->populated_document))
+ auto is_inline_content = populated_document_origin == Web::HTML::PopulatedDocumentOrigin::InlineContent;
+ if (is_inline_content && !populated_document->inline_content_origin.has_value())
return;
- replace(m_document_populated_by_history_job);
+ // AD-HOC: The PDF viewer runs with an origin of its own.
+ auto origin = is_inline_content ? *populated_document->inline_content_origin : URL::Origin { "resource"_string, String {}, {} };
+
+ auto url = is_inline_content ? URL::about_error() : populated_document->document->creation_url();
+ NavigationLoader::ResponseDocument response_document {
+ .is_inline_content = is_inline_content,
+ .coop_enforcement_result = { .url = url, .origin = origin, .opener_policy = {} },
+ .response_url = url,
+ .request_current_url = {},
+ .origin = origin,
+ .opener_policy = {},
+ .environment_id = environment_id,
+ .document_id = document_id,
+ };
+ auto document = create_and_initialize_a_document(response_document);
+ document->set_host(populated_document->document->host());
+ populated_document->document = move(document);
}
// The history job finalizing the ongoing navigation is going to activate the document populated for it, even if a
diff --git a/Libraries/LibWebView/CanonicalNavigable.h b/Libraries/LibWebView/CanonicalNavigable.h
index 2e023a5e6ff..a0cc87111be 100644
--- a/Libraries/LibWebView/CanonicalNavigable.h
+++ b/Libraries/LibWebView/CanonicalNavigable.h
@@ -101,7 +101,7 @@ public:
void populate_document_for_ongoing_navigation(NonnullRefPtr<CanonicalDocumentState>, NonnullRefPtr<CanonicalDocument>, Optional<URL::Origin> inline_content_origin = {});
// Returns false, populating nothing, for a document that would hold access the active document lacks.
bool populate_document_for_javascript_url(NonnullRefPtr<CanonicalDocumentState>, NonnullRefPtr<CanonicalDocument>);
- void did_create_populated_document_with_an_origin_of_its_own(WebContentPage const& host, Web::HTML::PopulatedDocumentOrigin, Web::HTML::EnvironmentId const& environment_id);
+ void did_create_populated_document_with_an_origin_of_its_own(WebContentPage const& host, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin, Web::HTML::EnvironmentId const& environment_id);
void claim_document_populated_for_ongoing_navigation(CanonicalDocument const&);
void abandon_populated_document(CanonicalDocument const&);
void place_pending_document(WebContentPage&);
diff --git a/Libraries/LibWebView/CanonicalTraversable.cpp b/Libraries/LibWebView/CanonicalTraversable.cpp
index 7457196e41a..66270a7e157 100644
--- a/Libraries/LibWebView/CanonicalTraversable.cpp
+++ b/Libraries/LibWebView/CanonicalTraversable.cpp
@@ -723,18 +723,18 @@ bool CanonicalTraversable::is_origin_held_by_a_document(URL::Origin const& origi
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-traversable
-CanonicalTraversable& CanonicalTraversable::create_a_new_top_level_traversable(Web::HTML::CrossProcessId id, Optional<CanonicalNavigable&> opener, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry)
+CanonicalTraversable& CanonicalTraversable::create_a_new_top_level_traversable(Web::HTML::CrossProcessId id, Optional<CanonicalNavigable&> opener, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId document_id)
{
// 1. Let document be null.
RefPtr<CanonicalDocument> document;
// 2. If opener is null, then set document to the second return value of creating a new top-level browsing context and document.
if (!opener.has_value()) {
- document = CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document(initial_history_entry.document_state.origin).document;
+ document = CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document(document_id, initial_history_entry.document_state.origin).document;
}
// 3. Otherwise, set document to the second return value of creating a new auxiliary browsing context and document given opener.
else {
- document = CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(*opener).document;
+ document = CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(*opener, document_id).document;
}
// 4. Let documentState be a new document state, with
@@ -1481,6 +1481,7 @@ void CanonicalTraversable::continue_history_navigation_population(Web::HTML::Cro
// by the process that fetched it.
auto response_document = loader->response_document();
if (response_document.has_value()) {
+ response_document->document_id = Application::the().allocate_ui_process_cross_process_id();
pending_job.value()->did_populate_document = CanonicalNavigable::DidPopulateDocument::Yes;
auto document = navigable->create_and_initialize_a_document(*response_document);
pending_job.value()->document = document;
@@ -2618,6 +2619,11 @@ void CanonicalTraversable::finalize_a_cross_document_navigation(HistoryOperation
return;
}
+ if (!parameters.document_id.has_value()) {
+ finish_history_operation(operation.operation_id, Web::HTML::HistoryStepResult::NoMatchingEntry, {});
+ return;
+ }
+
// 8. Assert: initiatorOrigin is newDocument's origin.
// NB: The UI process creates its newDocument with initiatorOrigin, and with the opener policy evaluating a
// javascript: URL gives it: targetNavigable's active document's opener policy.
@@ -2630,6 +2636,7 @@ void CanonicalTraversable::finalize_a_cross_document_navigation(HistoryOperation
.origin = *initiator_origin,
.opener_policy = coop,
.environment_id = parameters.environment_id,
+ .document_id = *parameters.document_id,
};
// 11. Let documentState be a new document state with
diff --git a/Libraries/LibWebView/CanonicalTraversable.h b/Libraries/LibWebView/CanonicalTraversable.h
index 9009e9581c8..224010595f3 100644
--- a/Libraries/LibWebView/CanonicalTraversable.h
+++ b/Libraries/LibWebView/CanonicalTraversable.h
@@ -162,7 +162,7 @@ public:
ByteString queued_same_document_session_history_entries_for_debug() const;
void reload(OnHistoryOperationComplete = nullptr);
- static CanonicalTraversable& create_a_new_top_level_traversable(Web::HTML::CrossProcessId id, Optional<CanonicalNavigable&> opener, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry);
+ static CanonicalTraversable& create_a_new_top_level_traversable(Web::HTML::CrossProcessId id, Optional<CanonicalNavigable&> opener, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId document_id);
static bool is_origin_held_by_a_document(URL::Origin const&);
static CanonicalTraversable* traversable_containing(Web::HTML::CrossProcessId navigable_id);
static CanonicalNavigable* navigable_with_active_browsing_context(CanonicalBrowsingContext const&);
diff --git a/Libraries/LibWebView/NavigationLoader.cpp b/Libraries/LibWebView/NavigationLoader.cpp
index 063132f0efc..f2fdc1a0127 100644
--- a/Libraries/LibWebView/NavigationLoader.cpp
+++ b/Libraries/LibWebView/NavigationLoader.cpp
@@ -53,6 +53,7 @@ Optional<NavigationLoader::ResponseDocument> NavigationLoader::response_document
.origin = origin,
.opener_policy = {},
.environment_id = {},
+ .document_id = {},
};
}
@@ -79,6 +80,7 @@ Optional<NavigationLoader::ResponseDocument> NavigationLoader::response_document
.origin = fetched_navigation_params.origin,
.opener_policy = fetched_navigation_params.opener_policy,
.environment_id = {},
+ .document_id = {},
};
}
@@ -288,12 +290,14 @@ Web::HTML::NavigationPopulationResult const& NavigationLoader::result() const
return *m_result;
}
-// The window of the document the navigation params create takes over their reserved environment's id, which the UI
-// process generates, and is in the agent cluster of the agent the UI process obtained for it. A navigation without a
-// reserved environment gets one with the id.
+// The document the result creates takes the UI process's id for it. Its window takes over the navigation params'
+// reserved environment's id, which the UI process generates, and is in the agent cluster of the agent the UI process
+// obtained for it. A navigation without a reserved environment gets one with the id.
void NavigationLoader::set_document(CanonicalDocument const& document, CanonicalNavigable const& navigable)
{
VERIFY(m_result.has_value());
+ m_result->document_id = document.id();
+
auto* navigation_params = m_result->navigation_params.get_pointer<Web::HTML::NavigationParamsDescriptor>();
if (!navigation_params)
return;
diff --git a/Libraries/LibWebView/NavigationLoader.h b/Libraries/LibWebView/NavigationLoader.h
index 5e3c4ea1bc8..286327c5c0b 100644
--- a/Libraries/LibWebView/NavigationLoader.h
+++ b/Libraries/LibWebView/NavigationLoader.h
@@ -45,6 +45,7 @@ public:
Web::HTML::OpenerPolicy opener_policy;
// The id of the window environment a process created the document with before the UI process heard of it.
Optional<Web::HTML::EnvironmentId> environment_id;
+ Web::HTML::CrossProcessId document_id;
};
Optional<ResponseDocument> response_document() const;
void set_document(CanonicalDocument const&, CanonicalNavigable const&);
diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cpp
index b5689b02cdf..8d12d4a2a93 100644
--- a/Libraries/LibWebView/WebContentClient.cpp
+++ b/Libraries/LibWebView/WebContentClient.cpp
@@ -242,7 +242,7 @@ WebContentPage& WebContentClient::open_initial_page_for_new_top_level_traversabl
// A tab's first process creates its traversable, in the page that displays the tab.
VERIFY(m_initial_top_level_history_entry.has_value());
- auto& traversable = CanonicalTraversable::create_a_new_top_level_traversable(m_root_navigable_id, {}, m_initial_top_level_history_entry.release_value());
+ auto& traversable = CanonicalTraversable::create_a_new_top_level_traversable(m_root_navigable_id, {}, m_initial_top_level_history_entry.release_value(), m_initial_top_level_document_id);
auto& page = open_page_for_new_top_level_traversable(initial_page_id, traversable);
page.async_set_browsing_context_group(traversable.active_browsing_context().group()->id());
return page;
@@ -707,7 +707,7 @@ Messages::WebContentClient::DidRequestNewWebViewResponse WebContentClient::did_r
if (auto* page = this->page(page_id))
return page->did_request_new_web_view(activate_tab, hints, opener_navigable_id, move(opener_base_url), move(target_name), popup_sandboxing_flag_set);
- return { Optional<Web::PageId> {}, Optional<Web::HTML::CrossProcessId> {}, Optional<Web::HTML::SessionHistoryEntryDescriptor> {}, Optional<Web::HTML::EnvironmentId> {}, Optional<u64> {}, Web::HTML::VisibilityState::Hidden, String {} };
+ return { Optional<Web::PageId> {}, Optional<Web::HTML::CrossProcessId> {}, Optional<Web::HTML::SessionHistoryEntryDescriptor> {}, Optional<Web::HTML::EnvironmentId> {}, Optional<Web::HTML::CrossProcessId> {}, Optional<u64> {}, Web::HTML::VisibilityState::Hidden, String {} };
}
Messages::WebContentClient::StartWorkerAgentResponse WebContentClient::start_worker_agent(Web::PageId page_id, Web::HTML::WorkerAgentStartRequest request)
diff --git a/Libraries/LibWebView/WebContentClient.h b/Libraries/LibWebView/WebContentClient.h
index d629cad01cf..573167f6f07 100644
--- a/Libraries/LibWebView/WebContentClient.h
+++ b/Libraries/LibWebView/WebContentClient.h
@@ -97,7 +97,11 @@ public:
// Null outside test mode: the test endpoint is only connected when the UI process runs tests.
WebContentTestClient* test_connection() { return m_test_connection; }
- void set_initial_top_level_history_entry(Badge<Application>, Web::HTML::SessionHistoryEntryDescriptor entry) { m_initial_top_level_history_entry = move(entry); }
+ void set_initial_top_level_history_entry(Badge<Application>, Web::HTML::SessionHistoryEntryDescriptor entry, Web::HTML::CrossProcessId document_id)
+ {
+ m_initial_top_level_history_entry = move(entry);
+ m_initial_top_level_document_id = document_id;
+ }
WebContentPage& open_initial_page_for_new_top_level_traversable();
WebContentPage& open_page_for_new_top_level_traversable(Web::PageId, CanonicalTraversable&);
void discard_page_of_undisplayed_top_level_traversable(Web::PageId);
@@ -222,6 +226,7 @@ private:
Optional<Web::PageId> m_unassigned_initial_page_id;
Web::HTML::CrossProcessId m_root_navigable_id;
Optional<Web::HTML::SessionHistoryEntryDescriptor> m_initial_top_level_history_entry;
+ Web::HTML::CrossProcessId m_initial_top_level_document_id;
ProcessHandle m_process_handle;
diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cpp
index e9dd2725c90..51b4cfcd2fb 100644
--- a/Libraries/LibWebView/WebContentPage.cpp
+++ b/Libraries/LibWebView/WebContentPage.cpp
@@ -307,6 +307,7 @@ bool WebContentPage::continue_navigation_population_in_selected_process(Web::HTM
RefPtr<WebContentPage> host = this;
auto response_document = navigable->ongoing_navigation()->loader->response_document();
if (response_document.has_value()) {
+ response_document->document_id = Application::the().allocate_ui_process_cross_process_id();
auto const& request = navigable->ongoing_navigation()->loader->request();
auto document = navigable->create_and_initialize_a_document(*response_document);
navigable->ongoing_navigation()->loader->set_document(*document, *navigable);
@@ -728,13 +729,13 @@ void WebContentPage::did_completely_finish_loading(Web::HTML::CrossProcessId nav
navigable->active_document_completely_finished_loading();
}
-void WebContentPage::did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id)
+void WebContentPage::did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id)
{
if (auto navigable = traversable().find(navigable_id); navigable.has_value())
- navigable->did_create_populated_document_with_an_origin_of_its_own(*this, origin, environment_id);
+ navigable->did_create_populated_document_with_an_origin_of_its_own(*this, document_id, origin, environment_id);
}
-void WebContentPage::did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState hosted_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id)
+void WebContentPage::did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState hosted_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id, Web::HTML::CrossProcessId document_id)
{
auto& traversable = this->traversable();
@@ -768,7 +769,7 @@ void WebContentPage::did_create_child_frame(Web::HTML::CrossProcessId parent_fra
auto group = container_document.browsing_context().top_level_browsing_context().group();
// 3. Let browsingContext and document be the result of creating a new browsing context and document given element's node document, element, and group.
- auto document = CanonicalBrowsingContext::create_a_new_browsing_context_and_document(&container_document, hosted_state.container, *group, move(environment_id), move(origin)).document;
+ auto document = CanonicalBrowsingContext::create_a_new_browsing_context_and_document(&container_document, hosted_state.container, *group, document_id, move(environment_id), move(origin)).document;
// 6. Let documentState be a new document state, with
// document: document
@@ -2574,18 +2575,19 @@ Messages::WebContentClient::DidRequestNewWebViewResponse WebContentPage::did_req
if (opener_navigable_id.has_value()) {
opener = hosted_navigable(*opener_navigable_id);
if (!opener.has_value())
- return { {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, {} };
+ return { {}, {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, {} };
}
// The popup blocker runs in the renderer, which a compromised renderer skips. Each popup takes the activation of
// input the UI process delivered to the page, as the renderer's popup consumes the activation of its window.
if (Application::the().blocks_pop_ups() && !consume_transient_user_activation())
- return { {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, {} };
+ return { {}, {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, {} };
auto root_navigable_id = Application::the().allocate_ui_process_cross_process_id();
auto initial_history_entry = Web::HTML::create_initial_session_history_entry_descriptor(
Application::the().allocate_ui_process_cross_process_id(), move(opener_base_url), move(target_name));
- auto& traversable = CanonicalTraversable::create_a_new_top_level_traversable(root_navigable_id, opener, move(initial_history_entry));
+ auto document_id = Application::the().allocate_ui_process_cross_process_id();
+ auto& traversable = CanonicalTraversable::create_a_new_top_level_traversable(root_navigable_id, opener, move(initial_history_entry), document_id);
traversable.active_browsing_context().set_popup_sandboxing_flag_set(popup_sandboxing_flag_set);
auto new_page_id = Application::the().allocate_page_id();
@@ -2598,13 +2600,13 @@ Messages::WebContentClient::DidRequestNewWebViewResponse WebContentPage::did_req
if (!traversable.view().has_value()) {
client().discard_page_of_undisplayed_top_level_traversable(new_page_id);
CanonicalTraversable::remove_from_user_agent_top_level_traversable_set(traversable);
- return { {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, move(window_handle) };
+ return { {}, {}, {}, {}, {}, {}, Web::HTML::VisibilityState::Hidden, move(window_handle) };
}
traversable.represent_group_everywhere();
auto environment_id = traversable.active_document().relevant_global_object().relevant_settings_object().id();
Optional<u64> browsing_context_group_id = traversable.active_browsing_context().group()->id();
- return { new_page_id, root_navigable_id, traversable.active_session_history_entry()->descriptor(), move(environment_id), browsing_context_group_id, traversable.system_visibility_state(), move(window_handle) };
+ return { new_page_id, root_navigable_id, traversable.active_session_history_entry()->descriptor(), move(environment_id), document_id, browsing_context_group_id, traversable.system_visibility_state(), move(window_handle) };
}
void WebContentPage::did_close_browsing_context()
diff --git a/Libraries/LibWebView/WebContentPage.h b/Libraries/LibWebView/WebContentPage.h
index 1069efeac6e..879e528a9ae 100644
--- a/Libraries/LibWebView/WebContentPage.h
+++ b/Libraries/LibWebView/WebContentPage.h
@@ -173,8 +173,8 @@ private:
virtual void did_request_window_focus_of_navigable(Web::HTML::CrossProcessId navigable_id) override;
virtual void did_request_set_opener_of_navigable(Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId opener_navigable_id) override;
virtual void did_completely_finish_loading(Web::HTML::CrossProcessId navigable_id) override;
- virtual void did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id) override;
- virtual void did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState replicated_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id) override;
+ virtual void did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id) override;
+ virtual void did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState replicated_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id, Web::HTML::CrossProcessId document_id) override;
virtual void did_set_browser_zoom(double factor) override;
virtual void did_set_device_pixel_ratio_for_testing(double device_pixel_ratio) override;
virtual void did_find_in_page(size_t current_match_index, Optional<size_t> total_match_count) override;
diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp
index 479d70a1790..b57d24ce753 100644
--- a/Services/WebContent/ConnectionFromClient.cpp
+++ b/Services/WebContent/ConnectionFromClient.cpp
@@ -141,9 +141,9 @@ void ConnectionFromClient::set_font_service(IPC::TransportHandle handle, IPC::Fi
Web::Platform::FontPlugin::install(*new Web::Platform::FontPlugin(m_enable_test_mode, font_provider));
}
-void ConnectionFromClient::initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state)
+void ConnectionFromClient::initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state)
{
- m_page_host->initialize(initial_page_id, move(remote_navigables), root_navigable_id, cross_process_id_allocator, move(initial_history_entry), system_visibility_state);
+ m_page_host->initialize(initial_page_id, move(remote_navigables), root_navigable_id, cross_process_id_allocator, move(initial_history_entry), initial_document_id, system_visibility_state);
}
void ConnectionFromClient::create_representing_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables)
diff --git a/Services/WebContent/ConnectionFromClient.h b/Services/WebContent/ConnectionFromClient.h
index be39624ed57..13f335b974c 100644
--- a/Services/WebContent/ConnectionFromClient.h
+++ b/Services/WebContent/ConnectionFromClient.h
@@ -95,7 +95,7 @@ private:
Optional<PageClient const&> page(Web::PageId index, SourceLocation = SourceLocation::current()) const;
virtual void set_font_service(IPC::TransportHandle, IPC::File catalog, u64 catalog_size, u64 generation) override;
- virtual void initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state) override;
+ virtual void initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state) override;
virtual void create_representing_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables) override;
virtual void create_embedded_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state) override;
virtual void continue_history_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::SessionHistoryEntryDescriptor target_entry, Optional<Web::Bindings::NavigationType>, Web::HTML::HistoryNavigationPopulation) override;
diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cpp
index c1516f3ccbc..e55bd10d228 100644
--- a/Services/WebContent/PageClient.cpp
+++ b/Services/WebContent/PageClient.cpp
@@ -401,14 +401,14 @@ void PageClient::page_did_change_navigable_container_state(Web::HTML::CrossProce
client().async_did_change_navigable_container_state(m_id, navigable_id, state);
}
-void PageClient::page_did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId const& environment_id)
+void PageClient::page_did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId const& environment_id)
{
- client().async_did_create_populated_document_with_an_origin_of_its_own(m_id, navigable_id, origin, environment_id);
+ client().async_did_create_populated_document_with_an_origin_of_its_own(m_id, navigable_id, document_id, origin, environment_id);
}
-void PageClient::page_did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState const& replicated_state, Web::HTML::PendingSessionHistoryEntryDescriptor const& initial_history_entry, URL::Origin const& origin, Web::HTML::EnvironmentId const& environment_id)
+void PageClient::page_did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState const& replicated_state, Web::HTML::PendingSessionHistoryEntryDescriptor const& initial_history_entry, URL::Origin const& origin, Web::HTML::EnvironmentId const& environment_id, Web::HTML::CrossProcessId document_id)
{
- client().async_did_create_child_frame(m_id, parent_frame_id, frame_id, replicated_state, initial_history_entry, origin, environment_id);
+ client().async_did_create_child_frame(m_id, parent_frame_id, frame_id, replicated_state, initial_history_entry, origin, environment_id, document_id);
}
void PageClient::page_did_update_child_frame_viewport(Web::HTML::CrossProcessId frame_id, Web::DevicePixelRect viewport_rect, Web::DevicePixelRect viewport_intersection)
@@ -1565,10 +1565,11 @@ PageClient::NewWebViewResult PageClient::page_did_request_new_web_view(Web::HTML
VERIFY(response->root_navigable_id().has_value());
VERIFY(response->initial_history_entry().has_value());
VERIFY(response->initial_environment_id().has_value());
+ VERIFY(response->initial_document_id().has_value());
auto& new_client = m_owner.create_page(*response->new_page_id(), *response->root_navigable_id());
new_client.page().set_system_visibility_state(response->system_visibility_state());
- return { &new_client.page(), response->take_handle(), response->take_initial_history_entry(), response->take_initial_environment_id(), response->browsing_context_group_id() };
+ return { &new_client.page(), response->take_handle(), response->take_initial_history_entry(), response->take_initial_environment_id(), response->initial_document_id(), response->browsing_context_group_id() };
}
void PageClient::page_did_close()
diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.h
index 0efa4777db4..5cae0451474 100644
--- a/Services/WebContent/PageClient.h
+++ b/Services/WebContent/PageClient.h
@@ -201,8 +201,8 @@ private:
virtual void page_did_set_opener_browsing_context(Web::HTML::CrossProcessId navigable_id, Optional<Web::HTML::CrossProcessId> opener_navigable_id) override;
virtual void page_did_completely_finish_loading(Web::HTML::CrossProcessId navigable_id) override;
virtual void page_did_change_navigable_container_state(Web::HTML::CrossProcessId navigable_id, Web::HTML::ReplicatedContainerState const&) override;
- virtual void page_did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::PopulatedDocumentOrigin, Web::HTML::EnvironmentId const& environment_id) override;
- virtual void page_did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState const&, Web::HTML::PendingSessionHistoryEntryDescriptor const& initial_history_entry, URL::Origin const& origin, Web::HTML::EnvironmentId const& environment_id) override;
+ virtual void page_did_create_populated_document_with_an_origin_of_its_own(Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin, Web::HTML::EnvironmentId const& environment_id) override;
+ virtual void page_did_create_child_frame(Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState const&, Web::HTML::PendingSessionHistoryEntryDescriptor const& initial_history_entry, URL::Origin const& origin, Web::HTML::EnvironmentId const& environment_id, Web::HTML::CrossProcessId document_id) override;
virtual void page_did_update_child_frame_viewport(Web::HTML::CrossProcessId frame_id, Web::DevicePixelRect viewport_rect, Web::DevicePixelRect viewport_intersection) override;
virtual void forward_mouse_event_to_remote_navigable(Web::PageId, Web::HTML::CrossProcessId navigable_id, Web::MouseEvent) override;
virtual void page_did_destroy_child_frame(Web::HTML::CrossProcessId frame_id) override;
diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp
index cc513fc46ef..2c76b7a97f7 100644
--- a/Services/WebContent/PageHost.cpp
+++ b/Services/WebContent/PageHost.cpp
@@ -22,7 +22,7 @@ PageHost::PageHost(ConnectionFromClient& client)
{
}
-void PageHost::initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state)
+void PageHost::initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state)
{
VERIFY(m_pages.is_empty());
m_cross_process_id_allocator = cross_process_id_allocator;
@@ -32,7 +32,7 @@ void PageHost::initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteN
if (remote_navigables.is_empty()) {
auto& first_page = create_page(initial_page_id, root_navigable_id);
first_page.page().set_system_visibility_state(system_visibility_state);
- Web::HTML::LocalTraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), move(initial_history_entry));
+ Web::HTML::LocalTraversableNavigable::create_a_fresh_top_level_traversable(first_page.page(), move(initial_history_entry), initial_document_id);
return;
}
auto& first_page = create_page(initial_page_id);
diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h
index 148dccb5e76..2eb3404947a 100644
--- a/Services/WebContent/PageHost.h
+++ b/Services/WebContent/PageHost.h
@@ -40,7 +40,7 @@ public:
static NonnullOwnPtr<PageHost> create(ConnectionFromClient& client) { return adopt_own(*new PageHost(client)); }
virtual ~PageHost();
- void initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state);
+ void initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state);
Optional<PageClient&> page(Web::PageId page_id);
PageClient& create_page(Web::PageId page_id, Optional<Web::HTML::CrossProcessId> pending_root_navigable_id = {});
void remove_page(Badge<PageClient>, Web::PageId page_id);
diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc
index 5a6364d7b2b..bdb3033056c 100644
--- a/Services/WebContent/WebContentClient.ipc
+++ b/Services/WebContent/WebContentClient.ipc
@@ -95,8 +95,8 @@ endpoint WebContentClient routed by Web::PageId page_id
did_finish_history_navigation_params_creation(Web::PageId page_id, Web::HTML::CrossProcessId operation_id, Web::HTML::HistoryNavigationPopulation population) =|
did_finish_navigation_params_creation(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Utf16String navigation_id, Optional<Web::HTML::NavigationPopulationResult> result) =|
did_fail_navigation_population(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Utf16String navigation_id) =|
- did_create_populated_document_with_an_origin_of_its_own(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id) =|
- did_create_child_frame(Web::PageId page_id, Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState hosted_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id) =|
+ did_create_populated_document_with_an_origin_of_its_own(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::CrossProcessId document_id, Web::HTML::PopulatedDocumentOrigin origin, Web::HTML::EnvironmentId environment_id) =|
+ did_create_child_frame(Web::PageId page_id, Web::HTML::CrossProcessId parent_frame_id, Web::HTML::CrossProcessId frame_id, Web::HTML::HostedNavigableState hosted_state, Web::HTML::PendingSessionHistoryEntryDescriptor initial_history_entry, URL::Origin origin, Web::HTML::EnvironmentId environment_id, Web::HTML::CrossProcessId document_id) =|
did_change_hosted_navigable_state(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Web::HTML::HostedNavigableState state) =|
did_set_opener_browsing_context(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id, Optional<Web::HTML::CrossProcessId> opener_navigable_id) =|
did_completely_finish_loading(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) =|
@@ -203,7 +203,7 @@ endpoint WebContentClient routed by Web::PageId page_id
did_post_broadcast_channel_message(Web::PageId page_id, Web::HTML::PostedBroadcastChannelMessage message) =|
did_update_resource_count(Web::PageId page_id, i32 count_waiting) =|
- [NotRouted] did_request_new_web_view(Web::PageId page_id, Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional<Web::HTML::CrossProcessId> opener_navigable_id, Optional<URL::URL> opener_base_url, Utf16String target_name, Web::HTML::SandboxingFlagSet popup_sandboxing_flag_set) => (Optional<Web::PageId> new_page_id, Optional<Web::HTML::CrossProcessId> root_navigable_id, Optional<Web::HTML::SessionHistoryEntryDescriptor> initial_history_entry, Optional<Web::HTML::EnvironmentId> initial_environment_id, Optional<u64> browsing_context_group_id, Web::HTML::VisibilityState system_visibility_state, String handle)
+ [NotRouted] did_request_new_web_view(Web::PageId page_id, Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional<Web::HTML::CrossProcessId> opener_navigable_id, Optional<URL::URL> opener_base_url, Utf16String target_name, Web::HTML::SandboxingFlagSet popup_sandboxing_flag_set) => (Optional<Web::PageId> new_page_id, Optional<Web::HTML::CrossProcessId> root_navigable_id, Optional<Web::HTML::SessionHistoryEntryDescriptor> initial_history_entry, Optional<Web::HTML::EnvironmentId> initial_environment_id, Optional<Web::HTML::CrossProcessId> initial_document_id, Optional<u64> browsing_context_group_id, Web::HTML::VisibilityState system_visibility_state, String handle)
[NotRouted] did_close_browsing_context(Web::PageId page_id) =|
did_change_needs_beforeunload_check(Web::PageId page_id, bool needs_beforeunload_check) =|
did_consume_user_activation(Web::PageId page_id, Web::HTML::UserActivationConsumption consumption) =|
diff --git a/Services/WebContent/WebContentServer.ipc b/Services/WebContent/WebContentServer.ipc
index 7c2f7d4beed..5aeec61d99a 100644
--- a/Services/WebContent/WebContentServer.ipc
+++ b/Services/WebContent/WebContentServer.ipc
@@ -64,7 +64,7 @@
endpoint WebContentServer routed by Web::PageId page_id
{
set_font_service(IPC::TransportHandle handle, IPC::File catalog, u64 catalog_size, u64 generation) =|
- [NotRouted] initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state) =|
+ [NotRouted] initialize(Web::PageId initial_page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::CrossProcessIdAllocator cross_process_id_allocator, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::CrossProcessId initial_document_id, Web::HTML::VisibilityState system_visibility_state) =|
[NotRouted] create_representing_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables) =|
create_embedded_page(Web::PageId page_id, Vector<Web::HTML::RemoteNavigableDescriptor> remote_navigables, Web::HTML::CrossProcessId root_navigable_id, Web::HTML::SessionHistoryEntryDescriptor initial_history_entry, Web::HTML::VisibilityState system_visibility_state) =|
insert_remote_navigable(Web::PageId page_id, Web::HTML::RemoteNavigableDescriptor navigable) =|
diff --git a/Tests/LibWebView/TestApplyHistoryStep.cpp b/Tests/LibWebView/TestApplyHistoryStep.cpp
index c1b7b5f5b8f..5a73e6df3e7 100644
--- a/Tests/LibWebView/TestApplyHistoryStep.cpp
+++ b/Tests/LibWebView/TestApplyHistoryStep.cpp
@@ -111,13 +111,13 @@ struct TestTraversable {
TestTraversable()
{
traversable.set_id(root_id());
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
}
WebView::CanonicalNavigable& add_child(Web::HTML::CrossProcessId id)
{
auto& child = traversable.append_child(make<WebView::CanonicalNavigable>(id));
- child.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ child.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
return child;
}
diff --git a/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp b/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp
index ac212227fb3..1bdd5f69836 100644
--- a/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp
+++ b/Tests/LibWebView/TestCanonicalBrowsingContextGroup.cpp
@@ -22,7 +22,7 @@ static URL::Origin origin_for(StringView url)
TEST_CASE(top_level_browsing_context_is_alone_in_a_new_group)
{
- auto browsing_context = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().browsing_context;
+ auto browsing_context = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).browsing_context;
auto group = browsing_context->group();
VERIFY(group);
@@ -33,13 +33,13 @@ TEST_CASE(top_level_browsing_context_is_alone_in_a_new_group)
TEST_CASE(auxiliary_browsing_context_joins_the_openers_group)
{
WebView::CanonicalTraversable opener;
- opener.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ opener.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
- auto popup_browsing_context = WebView::CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(opener).browsing_context;
+ auto popup_browsing_context = WebView::CanonicalBrowsingContext::create_a_new_auxiliary_browsing_context_and_document(opener, {}).browsing_context;
EXPECT_EQ(popup_browsing_context->group(), opener.active_browsing_context().group());
EXPECT_EQ(popup_browsing_context->group()->id(), opener.active_browsing_context().group()->id());
- EXPECT_NE(WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().browsing_context->group()->id(), opener.active_browsing_context().group()->id());
+ EXPECT_NE(WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).browsing_context->group()->id(), opener.active_browsing_context().group()->id());
EXPECT_EQ(popup_browsing_context->group()->browsing_context_set().size(), 2u);
EXPECT(popup_browsing_context->is_auxiliary());
EXPECT_EQ(popup_browsing_context->opener_browsing_context().ptr(), &opener.active_browsing_context());
@@ -47,13 +47,13 @@ TEST_CASE(auxiliary_browsing_context_joins_the_openers_group)
TEST_CASE(child_browsing_context_is_not_in_the_group)
{
- auto top_level = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document();
+ auto top_level = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({});
auto top_level_browsing_context = top_level.browsing_context;
auto group = top_level_browsing_context->group();
VERIFY(group);
Web::HTML::ReplicatedContainerState embedder {};
- auto child_browsing_context = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(top_level.document.ptr(), embedder, *group, {}).browsing_context;
+ auto child_browsing_context = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(top_level.document.ptr(), embedder, *group, {}, {}).browsing_context;
EXPECT_EQ(child_browsing_context->group(), nullptr);
EXPECT_EQ(&child_browsing_context->top_level_browsing_context(), top_level_browsing_context.ptr());
@@ -63,12 +63,12 @@ TEST_CASE(child_browsing_context_is_not_in_the_group)
TEST_CASE(replacing_a_traversables_browsing_context_leaves_its_group)
{
WebView::CanonicalTraversable traversable;
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
auto* initial_browsing_context = &traversable.active_browsing_context();
VERIFY(initial_browsing_context->group());
NonnullRefPtr initial_group = *initial_browsing_context->group();
- auto replacement = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document();
+ auto replacement = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({});
traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, replacement.document)));
EXPECT_EQ(&traversable.active_browsing_context(), replacement.browsing_context.ptr());
@@ -77,7 +77,7 @@ TEST_CASE(replacing_a_traversables_browsing_context_leaves_its_group)
TEST_CASE(removing_a_browsing_context_clears_its_group)
{
- auto browsing_context = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().browsing_context;
+ auto browsing_context = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).browsing_context;
VERIFY(browsing_context->group());
NonnullRefPtr group = *browsing_context->group();
@@ -90,7 +90,7 @@ TEST_CASE(removing_a_browsing_context_clears_its_group)
TEST_CASE(target_snapshot_params_take_the_popup_or_container_sandboxing_flags)
{
WebView::CanonicalTraversable traversable;
- auto top_level = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document();
+ auto top_level = WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({});
traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, top_level.document)));
auto popup_flags = Web::HTML::SandboxingFlagSet::SandboxedNavigation | Web::HTML::SandboxingFlagSet::SandboxPropagatesToAuxiliaryBrowsingContexts;
top_level.browsing_context->set_popup_sandboxing_flag_set(popup_flags);
@@ -103,7 +103,7 @@ TEST_CASE(target_snapshot_params_take_the_popup_or_container_sandboxing_flags)
.local_name = "iframe"_utf16_fly_string,
.iframe_referrer_policy = Web::ReferrerPolicy::ReferrerPolicy::NoReferrer,
};
- auto frame_document = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(top_level.document.ptr(), embedder, *top_level.browsing_context->group(), {}).document;
+ auto frame_document = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(top_level.document.ptr(), embedder, *top_level.browsing_context->group(), {}, {}).document;
auto& frame = traversable.append_child(make<WebView::CanonicalNavigable>(Web::HTML::CrossProcessId { 2, 1 }));
frame.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, frame_document)));
frame.set_hosted_state({
@@ -125,7 +125,7 @@ TEST_CASE(target_snapshot_params_take_the_popup_or_container_sandboxing_flags)
TEST_CASE(response_browsing_context_is_activated_only_at_commit)
{
WebView::CanonicalTraversable traversable;
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
auto* initial_context = &traversable.active_browsing_context();
auto initial_group = initial_context->group();
auto destination_url = URL::Parser::basic_parse("https://ladybird.org/"sv).release_value();
@@ -142,6 +142,7 @@ TEST_CASE(response_browsing_context_is_activated_only_at_commit)
.origin = destination_url.origin(),
.opener_policy = {},
.environment_id = {},
+ .document_id = {},
});
auto* destination_context = &destination_document->browsing_context();
auto navigation_id = Utf16String::from_utf8("navigation"sv);
@@ -179,7 +180,7 @@ TEST_CASE(response_browsing_context_is_activated_only_at_commit)
TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)
{
WebView::CanonicalTraversable traversable;
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
auto displayed_group = traversable.active_browsing_context().group();
auto destination_url = URL::Parser::basic_parse("https://ladybird.org/"sv).release_value();
@@ -196,6 +197,7 @@ TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)
.origin = destination_url.origin(),
.opener_policy = {},
.environment_id = {},
+ .document_id = {},
});
auto destination_group = destination_document->browsing_context().group();
VERIFY(destination_group && destination_group != displayed_group);
@@ -218,7 +220,7 @@ TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)
traversable.did_commit_navigation(*WebView::CanonicalSessionHistoryEntry::create(destination_document_state), move(committed_state), 1, navigation_id, WebView::CanonicalNavigable::DidPopulateDocument::Yes, {});
Web::HTML::ReplicatedContainerState embedder {};
- auto frame_document = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(destination_document.ptr(), embedder, *destination_group, {}).document;
+ auto frame_document = WebView::CanonicalBrowsingContext::create_a_new_browsing_context_and_document(destination_document.ptr(), embedder, *destination_group, {}, {}).document;
auto& frame = traversable.append_child(make<WebView::CanonicalNavigable>(Web::HTML::CrossProcessId { 2, 1 }));
frame.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, frame_document)));
@@ -236,6 +238,7 @@ TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)
.origin = frame_url.origin(),
.opener_policy = {},
.environment_id = {},
+ .document_id = {},
});
EXPECT_EQ(&document->relevant_global_object().agent(), destination_group->obtain_similar_origin_window_agent(frame_url.origin(), false).ptr());
@@ -244,7 +247,7 @@ TEST_CASE(child_navigation_under_a_document_that_switched_groups_uses_its_group)
TEST_CASE(clearing_a_navigation_abandons_only_the_document_populated_for_it)
{
WebView::CanonicalTraversable traversable;
- auto make_document = [] { return WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document; };
+ auto make_document = [] { return WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document; };
traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, make_document())));
// A document a history job populated outlives a navigation admitted and cleared meanwhile.
@@ -267,7 +270,7 @@ TEST_CASE(clearing_a_navigation_abandons_only_the_document_populated_for_it)
TEST_CASE(document_claimed_by_a_history_job_outlives_a_newer_navigation)
{
WebView::CanonicalTraversable traversable;
- auto make_document = [] { return WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document; };
+ auto make_document = [] { return WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document; };
traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, make_document())));
// The history job finalizing a navigation claims the document populated for it.
@@ -304,7 +307,7 @@ TEST_CASE(document_claimed_by_a_history_job_outlives_a_newer_navigation)
TEST_CASE(populated_document_replaces_tracked_load_when_document_state_is_reused)
{
WebView::CanonicalTraversable traversable;
- auto entry = WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create(Web::HTML::CrossProcessId { 1, 1 }, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document));
+ auto entry = WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create(Web::HTML::CrossProcessId { 1, 1 }, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document));
entry->navigation_api_id = Utf16String::from_utf8("entry"sv);
traversable.set_active_session_history_entry(entry);
auto navigation_id = Utf16String::from_utf8("reload"sv);
@@ -329,7 +332,7 @@ TEST_CASE(populated_document_replaces_tracked_load_when_document_state_is_reused
TEST_CASE(same_document_traversal_commits_only_navigations_admitted_before_it)
{
WebView::CanonicalTraversable traversable;
- auto entry = WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create(Web::HTML::CrossProcessId { 1, 1 }, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document));
+ auto entry = WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create(Web::HTML::CrossProcessId { 1, 1 }, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document));
traversable.set_active_session_history_entry(entry);
auto committed_state = [] {
return Web::HTML::HostedNavigableState {
@@ -414,6 +417,7 @@ static NonnullRefPtr<WebView::CanonicalDocument> navigate_to_a_new_group(WebView
.origin = destination_url.origin(),
.opener_policy = opener_policy,
.environment_id = {},
+ .document_id = {},
});
return document;
}
@@ -421,7 +425,7 @@ static NonnullRefPtr<WebView::CanonicalDocument> navigate_to_a_new_group(WebView
TEST_CASE(same_origin_plus_coep_response_isolates_its_new_group)
{
WebView::CanonicalTraversable traversable;
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
auto document = navigate_to_a_new_group(traversable, Web::HTML::OpenerPolicyValue::SameOriginPlusCOEP);
auto group = document->browsing_context().group();
@@ -434,7 +438,7 @@ TEST_CASE(same_origin_plus_coep_response_isolates_its_new_group)
TEST_CASE(same_origin_response_leaves_its_new_group_unisolated)
{
WebView::CanonicalTraversable traversable;
- traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ traversable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
auto document = navigate_to_a_new_group(traversable, Web::HTML::OpenerPolicyValue::SameOrigin);
auto group = document->browsing_context().group();
diff --git a/Tests/LibWebView/TestSessionHistory.cpp b/Tests/LibWebView/TestSessionHistory.cpp
index 14b5e15b713..3dd1ad7a320 100644
--- a/Tests/LibWebView/TestSessionHistory.cpp
+++ b/Tests/LibWebView/TestSessionHistory.cpp
@@ -17,7 +17,7 @@
static void give_active_document(WebView::CanonicalNavigable& navigable)
{
- navigable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document().document)));
+ navigable.set_active_session_history_entry(WebView::CanonicalSessionHistoryEntry::create(WebView::CanonicalDocumentState::create({}, WebView::CanonicalBrowsingContext::create_a_new_top_level_browsing_context_and_document({}).document)));
}
static Web::HTML::CrossProcessId navigable_id(StringView id)