Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8d764ee4313bf77fd932bb97788e43cb44c9a4f7
      
https://github.com/WebKit/WebKit/commit/8d764ee4313bf77fd932bb97788e43cb44c9a4f7
  Author: Anthony Tarbinian <[email protected]>
  Date:   2026-08-27 (Thu, 27 Aug 2026)

  Changed paths:
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
    M Tools/TestWebKitAPI/Helpers/cocoa/TestCocoaImageAndCocoaColor.h
    M Tools/TestWebKitAPI/Helpers/cocoa/TestCocoaImageAndCocoaColor.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtension.mm

  Log Message:
  -----------
  Decode WebExtension PDF icons in WebContent process
https://bugs.webkit.org/show_bug.cgi?id=321984
rdar://185159613

Reviewed by Timothy Hatcher.

https://commits.webkit.org/315453@main added an allowlist of
WebExtension icon types which were permitted to be decoded in the
UIProcess.

PDFs were not on the allowlist, but they are a supported extension icon
image format.

This patch adds back PDF decoding in the UIProcess for WebExtension
icons via NSPDFImageRep matching how it was decoded with NSImage before
315453@main. Note that this only affects macOS since UIImage never
decoded PDFs.

I couldn't simply add PDFs to the allowlist of supported images since
PDFs are not handled by CGImageSource (which is what the
WebCore::isSupportedImageType allowlist gates). So, I had to explicitly
decode PDFs separately like I did for SVGs in 315453@main.

Adds API tests: PDFIconLoads, PDFActionIconAsStringLoads,
MixedBitmapAndPDFIconsBothResolve and MalformedPDFIconIsReported.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::iconForPath):
    Add a case to decode PDF WebExtension icons with NSPDFImageRep.
* Tools/TestWebKitAPI/Helpers/cocoa/TestCocoaImageAndCocoaColor.h:
* Tools/TestWebKitAPI/Helpers/cocoa/TestCocoaImageAndCocoaColor.mm:
(TestWebKitAPI::Util::makePDFData):
    Helper to construct an array of bytes which represents a PDF.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtension.mm:
(TestWebKitAPI::TEST(WKWebExtension, PDFIconLoads)):
    Test that we can load the PDF icon of a WKWebExtension.
(TestWebKitAPI::TEST(WKWebExtension, MixedBitmapAndPDFIconsBothResolve)):
    Tests that different types of icon formats can be combined with PDFs in the
    extension manifest { "16": "icon-16.pdf", "128": "icon-128.png" }
(TestWebKitAPI::TEST(WKWebExtension, PDFActionIconAsStringLoads)):
    Test for when an icon is described using the "action" manifest key:
        "action": { "default_icon": "action-icon.pdf" }
(TestWebKitAPI::TEST(WKWebExtension, MalformedPDFIconIsReported)):
    Check that a PDF decoding error shows up after the decode fails.

Canonical link: https://commits.webkit.org/319970@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to