mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
LibWeb: Implement fire a download request navigate event
This commit is contained in:
parent
67bc3629a9
commit
0f8ae12d44
2 changed files with 32 additions and 0 deletions
|
@ -1294,4 +1294,35 @@ bool Navigation::fire_a_push_replace_reload_navigate_event(
|
|||
return inner_navigate_event_firing_algorithm(navigation_type, destination, user_involvement, move(form_data_entry_list), {}, move(classic_history_api_state));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#fire-a-download-request-navigate-event
|
||||
bool Navigation::fire_a_download_request_navigate_event(AK::URL destination_url, UserNavigationInvolvement user_involvement, String filename)
|
||||
{
|
||||
auto& realm = relevant_realm(*this);
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 1. Let event be the result of creating an event given NavigateEvent, in navigation's relevant realm.
|
||||
// 2. Set event's classic history API state to classicHistoryAPIState.
|
||||
// AD-HOC: These are handled in the inner algorithm
|
||||
|
||||
// 3. Let destination be a new NavigationDestination created in navigation's relevant realm.
|
||||
auto destination = NavigationDestination::create(realm);
|
||||
|
||||
// 4. Set destination's URL to destinationURL.
|
||||
destination->set_url(destination_url);
|
||||
|
||||
// 5. Set destination's entry to null.
|
||||
destination->set_entry(nullptr);
|
||||
|
||||
// 6. Set destination's state to StructuredSerializeForStorage(null).
|
||||
destination->set_state(MUST(structured_serialize_for_storage(vm, JS::js_null())));
|
||||
|
||||
// 7. Set destination's is same document to false.
|
||||
destination->set_is_same_document(false);
|
||||
|
||||
// 8. Return the result of performing the inner navigate event firing algorithm given navigation,
|
||||
// "push", event, destination, userInvolvement, null, and filename.
|
||||
// AD-HOC: We don't pass the event, but we do pass the classic_history_api state at the end to be set later
|
||||
return inner_navigate_event_firing_algorithm(Bindings::NavigationType::Push, destination, user_involvement, {}, move(filename), {});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue