diff --git a/Tests/LibWeb/Text/expected/localStorage.txt b/Tests/LibWeb/Text/expected/localStorage.txt
new file mode 100644
index 00000000000..a5ea54de542
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/localStorage.txt
@@ -0,0 +1,6 @@
+value
+value
+other
+other
+foo
+foo
diff --git a/Tests/LibWeb/Text/input/localStorage.html b/Tests/LibWeb/Text/input/localStorage.html
new file mode 100644
index 00000000000..32715a3ecf2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/localStorage.html
@@ -0,0 +1,17 @@
+
+
diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp
index 4242a04bccf..fd884f8f1aa 100644
--- a/Userland/Libraries/LibWeb/HTML/Storage.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp
@@ -23,10 +23,13 @@ Storage::Storage(JS::Realm& realm)
: Bindings::PlatformObject(realm)
{
m_legacy_platform_object_flags = LegacyPlatformObjectFlags {
+ .supports_indexed_properties = true,
.supports_named_properties = true,
+ .has_indexed_property_setter = true,
.has_named_property_setter = true,
.has_named_property_deleter = true,
.has_legacy_override_built_ins_interface_extended_attribute = true,
+ .indexed_property_setter_has_identifier = true,
.named_property_setter_has_identifier = true,
.named_property_deleter_has_identifier = true,
};
@@ -168,6 +171,13 @@ Vector Storage::supported_property_names() const
return names;
}
+Optional Storage::item_value(size_t index) const
+{
+ // Handle index as a string since that's our key type
+ auto key = String::number(index);
+ return named_item_value(key);
+}
+
JS::Value Storage::named_item_value(FlyString const& name) const
{
auto value = get_item(name);
@@ -182,6 +192,13 @@ WebIDL::ExceptionOr Storage::delete_v
return DidDeletionFail::NotRelevant;
}
+WebIDL::ExceptionOr Storage::set_value_of_indexed_property(u32 index, JS::Value unconverted_value)
+{
+ // Handle index as a string since that's our key type
+ auto key = String::number(index);
+ return set_value_of_named_property(key, unconverted_value);
+}
+
WebIDL::ExceptionOr Storage::set_value_of_named_property(String const& key, JS::Value unconverted_value)
{
// NOTE: Since PlatformObject does not know the type of value, we must convert it ourselves.
diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h
index 1c24c26d75a..fe505ba0e9c 100644
--- a/Userland/Libraries/LibWeb/HTML/Storage.h
+++ b/Userland/Libraries/LibWeb/HTML/Storage.h
@@ -38,9 +38,11 @@ private:
virtual void initialize(JS::Realm&) override;
// ^PlatformObject
+ virtual Optional item_value(size_t index) const override;
virtual JS::Value named_item_value(FlyString const&) const override;
virtual WebIDL::ExceptionOr delete_value(String const&) override;
virtual Vector supported_property_names() const override;
+ virtual WebIDL::ExceptionOr set_value_of_indexed_property(u32, JS::Value) override;
virtual WebIDL::ExceptionOr set_value_of_named_property(String const& key, JS::Value value) override;
void reorder();