Skip to content

LibWeb: Pass a null sourceDocument to Browser UI initiated navigations #4515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions Libraries/LibWeb/DOM/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3870,32 +3870,6 @@ void Document::set_policy_container(GC::Ref<HTML::PolicyContainer> policy_contai
m_policy_container = policy_container;
}

// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-source-snapshot-params
GC::Ref<HTML::SourceSnapshotParams> Document::snapshot_source_snapshot_params() const
{
// To snapshot source snapshot params given a Document sourceDocument, return a new source snapshot params with
return heap().allocate<HTML::SourceSnapshotParams>(
// has transient activation
// true if sourceDocument's relevant global object has transient activation; otherwise false
as<HTML::Window>(HTML::relevant_global_object(*this)).has_transient_activation(),

// sandboxing flags
// sourceDocument's active sandboxing flag set
m_active_sandboxing_flag_set,

// allows downloading
// false if sourceDocument's active sandboxing flag set has the sandboxed downloads browsing context flag set; otherwise true
!has_flag(m_active_sandboxing_flag_set, HTML::SandboxingFlagSet::SandboxedDownloads),

// fetch client
// sourceDocument's relevant settings object
relevant_settings_object(),

// source policy container
// a clone of sourceDocument's policy container
policy_container()->clone(heap()));
}

// https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables
Vector<GC::Root<HTML::Navigable>> Document::descendant_navigables()
{
Expand Down
2 changes: 0 additions & 2 deletions Libraries/LibWeb/DOM/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,6 @@ class Document

u32 unload_counter() const { return m_unload_counter; }

GC::Ref<HTML::SourceSnapshotParams> snapshot_source_snapshot_params() const;

void update_for_history_step_application(GC::Ref<HTML::SessionHistoryEntry>, bool do_not_reactivate, size_t script_history_length, size_t script_history_index, Optional<Bindings::NavigationType> navigation_type, Optional<Vector<GC::Ref<HTML::SessionHistoryEntry>>> entries_for_navigation_api = {}, GC::Ptr<HTML::SessionHistoryEntry> previous_entry_for_activation = {}, bool update_navigation_api = true);

HashMap<URL::URL, GC::Ptr<HTML::SharedResourceRequest>>& shared_resource_requests();
Expand Down
6 changes: 2 additions & 4 deletions Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,12 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
});

// FIXME: Handle 'parallel queue' task destination
auto task_destination = fetch_params.task_destination().get<GC::Ref<JS::Object>>();

// 5. Queue a fetch task to run processResponseEndOfBodyTask with fetchParams’s task destination.
Infrastructure::queue_fetch_task(fetch_params.controller(), task_destination, move(process_response_end_of_body_task));
Infrastructure::queue_fetch_task(fetch_params.controller(), fetch_params.task_destination(), move(process_response_end_of_body_task));
};

// FIXME: Handle 'parallel queue' task destination
auto task_destination = fetch_params.task_destination().get<GC::Ref<JS::Object>>();
auto task_destination = fetch_params.task_destination();

// 4. If fetchParams’s process response is non-null, then queue a fetch task to run fetchParams’s process response
// given response, with fetchParams’s task destination.
Expand Down
10 changes: 4 additions & 6 deletions Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,18 @@ void Body::fully_read(JS::Realm& realm, Web::Fetch::Infrastructure::Body::Proces

// FIXME: 1. If taskDestination is null, then set taskDestination to the result of starting a new parallel queue.
// FIXME: Handle 'parallel queue' task destination
VERIFY(!task_destination.has<Empty>());
auto task_destination_object = task_destination.get<GC::Ref<JS::Object>>();

// 2. Let successSteps given a byte sequence bytes be to queue a fetch task to run processBody given bytes, with taskDestination.
auto success_steps = [&realm, process_body, task_destination_object](ByteBuffer bytes) {
queue_fetch_task(*task_destination_object, GC::create_function(realm.heap(), [process_body, bytes = move(bytes)]() mutable {
auto success_steps = [&realm, process_body, task_destination](ByteBuffer bytes) {
queue_fetch_task(task_destination, GC::create_function(realm.heap(), [process_body, bytes = move(bytes)]() mutable {
process_body->function()(move(bytes));
}));
};

// 3. Let errorSteps optionally given an exception exception be to queue a fetch task to run processBodyError given
// exception, with taskDestination.
auto error_steps = [&realm, process_body_error, task_destination_object](JS::Value exception) {
queue_fetch_task(*task_destination_object, GC::create_function(realm.heap(), [process_body_error, exception]() {
auto error_steps = [&realm, process_body_error, task_destination](JS::Value exception) {
queue_fetch_task(task_destination, GC::create_function(realm.heap(), [process_body_error, exception]() {
process_body_error->function()(exception);
}));
};
Expand Down
15 changes: 9 additions & 6 deletions Libraries/LibWeb/Fetch/Infrastructure/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@
namespace Web::Fetch::Infrastructure {

// https://fetch.spec.whatwg.org/#queue-a-fetch-task
HTML::TaskID queue_fetch_task(JS::Object& task_destination, GC::Ref<GC::Function<void()>> algorithm)
HTML::TaskID queue_fetch_task(TaskDestination task_destination, GC::Ref<GC::Function<void()>> algorithm)
{
// FIXME: 1. If taskDestination is a parallel queue, then enqueue algorithm to taskDestination.

// 2. Otherwise, queue a global task on the networking task source with taskDestination and algorithm.
return HTML::queue_global_task(HTML::Task::Source::Networking, task_destination, algorithm);

if (auto* destination = task_destination.get_pointer<GC::Ref<JS::Object>>())
return HTML::queue_global_task(HTML::Task::Source::Networking, *destination, algorithm);

return HTML::queue_a_task(HTML::Task::Source::Networking, nullptr, nullptr, algorithm);
}

// AD-HOC: This overload allows tracking the queued task within the fetch controller so that we may cancel queued tasks
// when the spec indicates that we must stop an ongoing fetch.
HTML::TaskID queue_fetch_task(GC::Ref<FetchController> fetch_controller, JS::Object& task_destination, GC::Ref<GC::Function<void()>> algorithm)
HTML::TaskID queue_fetch_task(GC::Ref<FetchController> fetch_controller, TaskDestination task_destination, GC::Ref<GC::Function<void()>> algorithm)
{
auto fetch_task_id = fetch_controller->next_fetch_task_id();

auto& heap = task_destination.heap();
auto html_task_id = queue_fetch_task(task_destination, GC::create_function(heap, [fetch_controller, fetch_task_id, algorithm]() {
auto& heap = fetch_controller->heap();
auto html_task_id = queue_fetch_task(move(task_destination), GC::create_function(heap, [fetch_controller, fetch_task_id, algorithm]() {
fetch_controller->fetch_task_complete(fetch_task_id);
algorithm->function()();
}));
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibWeb/Fetch/Infrastructure/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Web::Fetch::Infrastructure {
// FIXME: 'or a parallel queue'
using TaskDestination = Variant<Empty, GC::Ref<JS::Object>>;

HTML::TaskID queue_fetch_task(JS::Object&, GC::Ref<GC::Function<void()>>);
HTML::TaskID queue_fetch_task(GC::Ref<FetchController>, JS::Object&, GC::Ref<GC::Function<void()>>);
HTML::TaskID queue_fetch_task(TaskDestination, GC::Ref<GC::Function<void()>>);
HTML::TaskID queue_fetch_task(GC::Ref<FetchController>, TaskDestination, GC::Ref<GC::Function<void()>>);

}
Loading
Loading