Skip to content

Commit

Permalink
DOM: Check for navigable destruction in declarative refresh timer
Browse files Browse the repository at this point in the history
If the Document's navigable has been destroyed since we started this
timer, or it's no longer the active document of its navigable, we
shouldn't navigate to it.
  • Loading branch information
ADKaster committed Jun 5, 2024
1 parent 8641e78 commit 5a16d34
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Userland/Libraries/LibWeb/DOM/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4062,8 +4062,11 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtr<HTML
if (has_meta_element && has_flag(active_sandboxing_flag_set(), HTML::SandboxingFlagSet::SandboxedAutomaticFeatures))
return;

VERIFY(navigable());
MUST(navigable()->navigate({ .url = url_record, .source_document = *this }));
auto navigable = this->navigable();
if (!navigable || navigable->has_been_destroyed())
return;

MUST(navigable->navigate({ .url = url_record, .source_document = *this, .history_handling = Bindings::NavigationHistoryBehavior::Replace }));
});

// For the purposes of the previous paragraph, a refresh is said to have come due as soon as the later of the
Expand Down

0 comments on commit 5a16d34

Please sign in to comment.