Skip to content

Commit

Permalink
[AVIF Downlevels] AVIF image can't be opened as an ImageDocument
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247759
rdar://102210682

Reviewed by Myles C. Maxfield.

On down levels macOS, we need to explicitly set the mime type for the requested
URL given its extension. We should not rely on NSURLResponse to tell us the correct
mime type since AVIF is only supported on macOS Ventura.

* LayoutTests/fast/images/avif-image-document-expected.html: Added.
* LayoutTests/fast/images/avif-image-document.html: Added.
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/win/TestExpectations:
* Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm:
(WebCore::ResourceResponse::platformLazyInit):

Canonical link: https://commits.webkit.org/256796@main
  • Loading branch information
shallawa authored and Said Abou-Hallawa committed Nov 17, 2022
1 parent 79f5dfa commit 45f050d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
16 changes: 16 additions & 0 deletions LayoutTests/fast/images/avif-image-document-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<style>
iframe {
width: 400px;
height: 400px;
}
</style>
<body>
<script>
const iframe = document.createElement("iframe");
iframe.srcdoc = `<!DOCTYPE html>
<body style="margin: 0; overflow: hidden;">
<img src="resources/green-400x400.avif">
</body>`;
document.body.appendChild(iframe);
</script>
</body>
7 changes: 7 additions & 0 deletions LayoutTests/fast/images/avif-image-document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<style>
iframe {
width: 400px;
height: 400px;
}
</style>
<iframe src="resources/green-400x400.avif">
3 changes: 3 additions & 0 deletions LayoutTests/platform/mac-wk1/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,9 @@ fast/images/decoding-attribute-async-small-image.html [ Skip ]
fast/images/decoding-attribute-dynamic-async-small-image.html [ Skip ]
fast/images/sprite-sheet-image-draw.html [ Skip ]

# AVIF tests
fast/images/avif-image-document.html [ Skip ]

# <rdar://problem/42627562>
media/video-restricted-invisible-autoplay-not-allowed-source.html [ Skip ]
media/video-restricted-invisible-autoplay-not-allowed.html [ Skip ]
Expand Down
1 change: 1 addition & 0 deletions LayoutTests/platform/win/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ fast/images/avif-as-image.html [ Skip ]
fast/images/avif-heif-container-as-image.html [ Skip ]
fast/images/animated-avif.html [ Skip ]
http/tests/images/avif-partial-load-crash.html [ Skip ]
fast/images/avif-image-document.html [ Skip ]

# TODO The following tests requires the DRT's dumpUserGestureInFrameLoadCallbacks
# method. But that method is not implemented in win port since win port can't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ static inline AtomString extractHTTPStatusText(CFHTTPMessageRef messageRef)

if (m_initLevel < CommonFieldsOnly) {
m_url = [m_nsResponse URL];
m_mimeType = [m_nsResponse MIMEType];
#if USE(AVIF)
if (m_url.string().endsWithIgnoringASCIICase(".avif"_s) || m_url.string().endsWithIgnoringASCIICase(".avifs"_s))
m_mimeType = "image/avif"_s;
else
#endif
m_mimeType = [m_nsResponse MIMEType];
m_expectedContentLength = [m_nsResponse expectedContentLength];
// Stripping double quotes as a workaround for <rdar://problem/8757088>, can be removed once that is fixed.
m_textEncodingName = stripLeadingAndTrailingDoubleQuote([m_nsResponse textEncodingName]);
Expand Down

0 comments on commit 45f050d

Please sign in to comment.