mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Fix infinite loop in Storage::internal_own_property_keys
Since `Storage::item_value` never returns an empty Optional, and since `PlatformObject::is_supported_property_index` only returns false when `item_value` returns an empty Optional, the loop in `PlatformObject::internal_own_property_keys` will never terminate when executed on a `Storage` instance. This fix allows youtube.com to load successfully :^)
This commit is contained in:
parent
3536ba9a88
commit
cc0fce3983
Notes:
github-actions[bot]
2024-10-25 10:43:24 +00:00
Author: https://github.com/yyny Commit: https://github.com/LadybirdBrowser/ladybird/commit/cc0fce39839 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1931 Reviewed-by: https://github.com/gmta ✅
3 changed files with 13 additions and 1 deletions
1
Tests/LibWeb/Text/expected/iterating-over-storage.txt
Normal file
1
Tests/LibWeb/Text/expected/iterating-over-storage.txt
Normal file
|
@ -0,0 +1 @@
|
|||
PASS (didn't loop forever)
|
8
Tests/LibWeb/Text/input/iterating-over-storage.html
Normal file
8
Tests/LibWeb/Text/input/iterating-over-storage.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
for (_ in window.localStorage);
|
||||
println("PASS (didn't loop forever)");
|
||||
});
|
||||
</script>
|
|
@ -175,7 +175,10 @@ Optional<JS::Value> 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);
|
||||
auto value = get_item(key);
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
return JS::PrimitiveString::create(vm(), value.release_value());
|
||||
}
|
||||
|
||||
JS::Value Storage::named_item_value(FlyString const& name) const
|
||||
|
|
Loading…
Add table
Reference in a new issue