1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:18:12 +00:00

LibWeb/MimeSniff: Add sniffing in a browsing context

This commit is contained in:
Kemal Zebari 2023-11-30 12:44:27 -08:00 committed by Andrew Kaster
parent f6d3ea33fa
commit ea15501f37
3 changed files with 29 additions and 2 deletions

View file

@ -31,7 +31,7 @@ TEST_CASE(determine_computed_mime_type_given_no_sniff_is_unset)
EXPECT_EQ(xml_mime_type, MUST(computed_mime_type.serialized()));
}
TEST_CASE(compute_unknown_mime_type)
TEST_CASE(determine_computed_mime_type_in_both_none_and_browsing_sniffing_context)
{
HashMap<StringView, Vector<StringView>> mime_type_to_headers_map;
@ -84,8 +84,14 @@ TEST_CASE(compute_unknown_mime_type)
auto mime_type = mime_type_to_headers.key;
for (auto const& header : mime_type_to_headers.value) {
// Test in a non-specific sniffing context.
auto computed_mime_type = MUST(Web::MimeSniff::Resource::sniff(header.bytes()));
EXPECT_EQ(mime_type, computed_mime_type.essence());
// Test sniffing in a browsing context.
computed_mime_type = MUST(Web::MimeSniff::Resource::sniff(header.bytes(), Web::MimeSniff::SniffingConfiguration { .sniffing_context = Web::MimeSniff::SniffingContext::Browsing }));
EXPECT_EQ(mime_type, computed_mime_type.essence());
}
}
}