Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/inspector/dom_storage_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "util.h"
#include "v8-exception.h"
#include "v8-isolate.h"
#if HAVE_SQLITE
#include "node_webstorage.h"
#endif // HAVE_SQLITE

namespace node {
namespace inspector {
Expand Down Expand Up @@ -98,6 +101,7 @@ protocol::DispatchResponse DOMStorageAgent::getDOMStorageItems(
bool is_local_storage = storageId->getIsLocalStorage();
const StorageMap* storage_map =
is_local_storage ? &local_storage_map_ : &session_storage_map_;
#if HAVE_SQLITE
std::optional<StorageMap> storage_map_fallback;
if (storage_map->empty()) {
auto web_storage_obj = getWebStorage(is_local_storage);
Expand Down Expand Up @@ -139,6 +143,12 @@ protocol::DispatchResponse DOMStorageAgent::getDOMStorageItems(
}
storage_map = &storage_map_fallback.value();
}
#else
if (storage_map->empty()) {
return protocol::DispatchResponse::ServerError(
"Could not read DOM storage items: storage is unavailable");
}
#endif // HAVE_SQLITE

auto result =
std::make_unique<protocol::Array<protocol::Array<protocol::String>>>();
Expand Down Expand Up @@ -317,6 +327,7 @@ void DOMStorageAgent::registerStorage(Local<Context> context,
}
}

#if HAVE_SQLITE
std::optional<node::webstorage::Storage*> DOMStorageAgent::getWebStorage(
bool is_local_storage) {
v8::Isolate* isolate = env_->isolate();
Expand All @@ -339,6 +350,7 @@ std::optional<node::webstorage::Storage*> DOMStorageAgent::getWebStorage(
return storage;
}
}
#endif // HAVE_SQLITE

bool DOMStorageAgent::canEmit(const std::string& domain) {
return domain == "DOMStorage";
Expand Down
5 changes: 4 additions & 1 deletion src/inspector/dom_storage_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#include <string>
#include "env.h"
#include "node/inspector/protocol/DOMStorage.h"
#include "node_webstorage.h"
#include "notification_emitter.h"
#include "v8.h"

namespace node {
namespace webstorage {
class Storage;
} // namespace webstorage

namespace inspector {

class DOMStorageAgent : public protocol::DOMStorage::Backend,
Expand Down
Loading