diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index f5866d7666..ac4c3dc01a 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -306,6 +306,9 @@ void BrowserWindow::build_menus() if (tab.on_dump_cookies) tab.on_dump_cookies(); })); + debug_menu.add_action(GUI::Action::create("Dump &Local Storage", [this](auto&) { + active_tab().m_web_content_view->debug_request("dump-local-storage"); + })); debug_menu.add_separator(); auto line_box_borders_action = GUI::Action::create_checkable( "Line &Box Borders", [this](auto& action) { diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index 533c95b928..f17b05bfb8 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -146,4 +146,14 @@ Vector Storage::supported_property_names() const return m_map.keys(); } +void Storage::dump() const +{ + dbgln("Storage ({} key(s))", m_map.size()); + size_t i = 0; + for (auto const& it : m_map) { + dbgln("[{}] \"{}\": \"{}\"", i, it.key, it.value); + ++i; + } +} + } diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index d8cf2c63e7..091b2c0b75 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -32,6 +32,8 @@ public: Vector supported_property_names() const; + void dump() const; + private: Storage(); diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index fcefebfbaf..a3789a8d4d 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -222,6 +224,11 @@ void ClientConnection::debug_request(const String& request, const String& argume if (request == "same-origin-policy") { m_page_host->page().set_same_origin_policy_enabled(argument == "on"); } + + if (request == "dump-local-storage") { + if (auto* doc = page().top_level_browsing_context().active_document()) + doc->window().local_storage()->dump(); + } } void ClientConnection::get_source()