mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb/Storage: Return undefined for non-existent key/index access
All tests at now pass: http://wpt.live/webstorage/defineProperty.window.html
This commit is contained in:
parent
c10cb8ac8d
commit
7a66316297
Notes:
github-actions[bot]
2024-10-23 17:32:41 +00:00
Author: https://github.com/BroadbentJim Commit: https://github.com/LadybirdBrowser/ladybird/commit/7a663162975 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1889 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/gmta
3 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
|||
undefined
|
||||
null
|
||||
value
|
||||
value
|
||||
other
|
||||
other
|
||||
undefined
|
||||
null
|
||||
foo
|
||||
foo
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
|
||||
println(localStorage["test"])
|
||||
println(localStorage.getItem("test"))
|
||||
|
||||
localStorage["test"] = "value";
|
||||
println(localStorage["test"]);
|
||||
println(localStorage.getItem("test"));
|
||||
|
@ -10,6 +14,9 @@
|
|||
println(localStorage.getItem("test"));
|
||||
|
||||
// Ensure indexed properties work
|
||||
println(localStorage[0])
|
||||
println(localStorage.getItem(0))
|
||||
|
||||
localStorage[0] = "foo";
|
||||
println(localStorage[0]);
|
||||
println(localStorage.getItem("0"));
|
||||
|
|
|
@ -182,7 +182,9 @@ JS::Value Storage::named_item_value(FlyString const& name) const
|
|||
{
|
||||
auto value = get_item(name);
|
||||
if (!value.has_value())
|
||||
return JS::js_null();
|
||||
// AD-HOC: Spec leaves open to a description at: https://html.spec.whatwg.org/multipage/webstorage.html#the-storage-interface
|
||||
// However correct behavior expected here: https://github.com/whatwg/html/issues/8684
|
||||
return JS::js_undefined();
|
||||
return JS::PrimitiveString::create(vm(), value.release_value());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue