WebContent: Do not crash on dumping unavailable localStorage
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Be a bit more defensive about this so we don't crash when trying to dump
unavailable local storage, such as on about:newtab.
This commit is contained in:
Jelle Raaijmakers 2025-07-17 23:45:04 +02:00 committed by Tim Ledbetter
commit d1abd11b78
Notes: github-actions[bot] 2025-07-17 22:41:24 +00:00

View file

@ -251,6 +251,7 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
if (request == "dump-session-history") {
auto const& traversable = page->page().top_level_traversable();
Web::dump_tree(*traversable);
return;
}
if (request == "dump-display-list") {
@ -393,8 +394,13 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
}
if (request == "dump-local-storage") {
if (auto* document = page->page().top_level_browsing_context().active_document())
document->window()->local_storage().release_value_but_fixme_should_propagate_errors()->dump();
if (auto* document = page->page().top_level_browsing_context().active_document()) {
auto storage_or_error = document->window()->local_storage();
if (storage_or_error.is_error())
dbgln("Failed to retrieve local storage: {}", storage_or_error.release_error());
else
storage_or_error.release_value()->dump();
}
return;
}