Quellcode durchsuchen

LibWeb: Add missing set_delaying_load_events(false) in navigate()

If navigation early returns before reaching "finalize a cross document
navigation" then we have to make sure delaying load events is disabled.

See spec issue https://github.com/whatwg/html/issues/10252
Aliaksandr Kalenik vor 1 Jahr
Ursprung
Commit
aefed21927
1 geänderte Dateien mit 6 neuen und 1 gelöschten Zeilen
  1. 6 1
      Userland/Libraries/LibWeb/HTML/Navigable.cpp

+ 6 - 1
Userland/Libraries/LibWeb/HTML/Navigable.cpp

@@ -1359,8 +1359,10 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
     // 20. In parallel, run these steps:
     // 20. In parallel, run these steps:
     Platform::EventLoopPlugin::the().deferred_invoke([this, source_snapshot_params, target_snapshot_params, csp_navigation_type, document_resource, url, navigation_id, referrer_policy, initiator_origin_snapshot, response, history_handling, initiator_base_url_snapshot] {
     Platform::EventLoopPlugin::the().deferred_invoke([this, source_snapshot_params, target_snapshot_params, csp_navigation_type, document_resource, url, navigation_id, referrer_policy, initiator_origin_snapshot, response, history_handling, initiator_base_url_snapshot] {
         // NOTE: Not in the spec but subsequent steps will fail because destroyed navigable does not have active document.
         // NOTE: Not in the spec but subsequent steps will fail because destroyed navigable does not have active document.
-        if (has_been_destroyed())
+        if (has_been_destroyed()) {
+            set_delaying_load_events(false);
             return;
             return;
+        }
 
 
         // FIXME: 1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for navigable's active document's inclusive descendant navigables.
         // FIXME: 1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for navigable's active document's inclusive descendant navigables.
 
 
@@ -1369,6 +1371,7 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
             // FIXME: 1. Invoke WebDriver BiDi navigation failed with targetBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
             // FIXME: 1. Invoke WebDriver BiDi navigation failed with targetBrowsingContext and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.
 
 
             // 2. Abort these steps.
             // 2. Abort these steps.
+            set_delaying_load_events(false);
             return;
             return;
         }
         }
 
 
@@ -1424,10 +1427,12 @@ WebIDL::ExceptionOr<void> Navigable::navigate(NavigateParams params)
             traversable_navigable()->append_session_history_traversal_steps([this, history_entry, history_handling, navigation_id] {
             traversable_navigable()->append_session_history_traversal_steps([this, history_entry, history_handling, navigation_id] {
                 if (this->has_been_destroyed()) {
                 if (this->has_been_destroyed()) {
                     // NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
                     // NOTE: This check is not in the spec but we should not continue navigation if navigable has been destroyed.
+                    set_delaying_load_events(false);
                     return;
                     return;
                 }
                 }
                 if (this->ongoing_navigation() != navigation_id) {
                 if (this->ongoing_navigation() != navigation_id) {
                     // NOTE: This check is not in the spec but we should not continue navigation if ongoing navigation id has changed.
                     // NOTE: This check is not in the spec but we should not continue navigation if ongoing navigation id has changed.
+                    set_delaying_load_events(false);
                     return;
                     return;
                 }
                 }
                 finalize_a_cross_document_navigation(*this, to_history_handling_behavior(history_handling), history_entry);
                 finalize_a_cross_document_navigation(*this, to_history_handling_behavior(history_handling), history_entry);