mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 16:58:52 +00:00
LibWeb: Update revokeObjectURL for reported spec bugs
The spec intends to pass through a URL record object as it needs to be serialized on removal. This has no functional impact on our implementation other than the double parsing of every URL being revoked. It is also missing an error check for an invalid URL being passed through. This does not impact our implementation currently as we just end up using an empty URL which is not part of the blob entry map. This will cause problems once DOMURL::parse is updated to return an Optional<URL::URL> however.
This commit is contained in:
parent
228750a9d2
commit
b81d6945dc
Notes:
github-actions[bot]
2025-01-22 12:35:04 +00:00
Author: https://github.com/shannonbooth
Commit: b81d6945dc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3339
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 9 additions and 4 deletions
|
@ -132,6 +132,10 @@ void DOMURL::revoke_object_url(JS::VM&, StringView url)
|
||||||
// 1. Let url record be the result of parsing url.
|
// 1. Let url record be the result of parsing url.
|
||||||
auto url_record = parse(url);
|
auto url_record = parse(url);
|
||||||
|
|
||||||
|
// Spec Bug: https://github.com/w3c/FileAPI/issues/207, missing check for URL failure parsing.
|
||||||
|
if (!url_record.is_valid())
|
||||||
|
return;
|
||||||
|
|
||||||
// 2. If url record’s scheme is not "blob", return.
|
// 2. If url record’s scheme is not "blob", return.
|
||||||
if (url_record.scheme() != "blob"sv)
|
if (url_record.scheme() != "blob"sv)
|
||||||
return;
|
return;
|
||||||
|
@ -151,7 +155,8 @@ void DOMURL::revoke_object_url(JS::VM&, StringView url)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 7. Remove an entry from the Blob URL Store for url.
|
// 7. Remove an entry from the Blob URL Store for url.
|
||||||
FileAPI::remove_entry_from_blob_url_store(url);
|
// FIXME: Spec bug: https://github.com/w3c/FileAPI/issues/207, urlRecord should instead be passed through.
|
||||||
|
FileAPI::remove_entry_from_blob_url_store(url_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-url-canparse
|
// https://url.spec.whatwg.org/#dom-url-canparse
|
||||||
|
|
|
@ -115,13 +115,13 @@ Optional<URL::BlobURLEntry::Object> obtain_a_blob_object(URL::BlobURLEntry const
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#removeTheEntry
|
// https://w3c.github.io/FileAPI/#removeTheEntry
|
||||||
void remove_entry_from_blob_url_store(StringView url)
|
void remove_entry_from_blob_url_store(URL::URL const& url)
|
||||||
{
|
{
|
||||||
// 1. Let store be the user agent’s blob URL store;
|
// 1. Let store be the user agent’s blob URL store;
|
||||||
auto& store = blob_url_store();
|
auto& store = blob_url_store();
|
||||||
|
|
||||||
// 2. Let url string be the result of serializing url.
|
// 2. Let url string be the result of serializing url.
|
||||||
auto url_string = URL::URL { url }.to_string();
|
auto url_string = url.serialize();
|
||||||
|
|
||||||
// 3. Remove store[url string].
|
// 3. Remove store[url string].
|
||||||
store.remove(url_string);
|
store.remove(url_string);
|
||||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<String> add_entry_to_blob_url_store(GC::Ref<Blob> object);
|
||||||
bool check_for_same_partition_blob_url_usage(URL::BlobURLEntry const&, GC::Ref<HTML::Environment>);
|
bool check_for_same_partition_blob_url_usage(URL::BlobURLEntry const&, GC::Ref<HTML::Environment>);
|
||||||
struct NavigationEnvironment { };
|
struct NavigationEnvironment { };
|
||||||
Optional<URL::BlobURLEntry::Object> obtain_a_blob_object(URL::BlobURLEntry const&, Variant<GC::Ref<HTML::Environment>, NavigationEnvironment> environment);
|
Optional<URL::BlobURLEntry::Object> obtain_a_blob_object(URL::BlobURLEntry const&, Variant<GC::Ref<HTML::Environment>, NavigationEnvironment> environment);
|
||||||
void remove_entry_from_blob_url_store(StringView url);
|
void remove_entry_from_blob_url_store(URL::URL const& url);
|
||||||
Optional<BlobURLEntry const&> resolve_a_blob_url(URL::URL const&);
|
Optional<BlobURLEntry const&> resolve_a_blob_url(URL::URL const&);
|
||||||
|
|
||||||
void run_unloading_cleanup_steps(GC::Ref<DOM::Document>);
|
void run_unloading_cleanup_steps(GC::Ref<DOM::Document>);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue