Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 546db34. rdar://114288616
[iOS 17+, Sonoma] REGRESSION (267051@main): Safari no longer responds to WebPrivacy list changes https://bugs.webkit.org/show_bug.cgi?id=260569 rdar://114288616 Reviewed by Aditya Keerthi. Several API tests in `TestWebKitAPI.AdvancedPrivacyProtections` began to fail after the changes in 267051@main; in particular, they're failing because I changed the `SOFT_LINK_CONSTANT_FOR_HEADER` around `WPNotificationUserInfoResourceTypeKey` to `SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER`, the latter of which never attempts to load will return `nil` unless we call `PAL::canLoad_WebPrivacy_WPResourceDataChangedNotificationName()` first (the full macro expands to the following): ``` namespace PAL { static NSNotificationName constantWebPrivacyWPResourceDataChangedNotificationName; bool init_WebPrivacy_WPResourceDataChangedNotificationName(); bool init_WebPrivacy_WPResourceDataChangedNotificationName() { void* constant = dlsym(WebPrivacyLibrary(), "WPResourceDataChangedNotificationName"); if (!constant) return false; constantWebPrivacyWPResourceDataChangedNotificationName = *static_cast<NSNotificationName const *>(constant); return true; } PAL_EXPORT bool canLoad_WebPrivacy_WPResourceDataChangedNotificationName(); bool canLoad_WebPrivacy_WPResourceDataChangedNotificationName() { static bool loaded = init_WebPrivacy_WPResourceDataChangedNotificationName(); return loaded; } PAL_EXPORT NSNotificationName get_WebPrivacy_WPResourceDataChangedNotificationName(); NSNotificationName get_WebPrivacy_WPResourceDataChangedNotificationName() { return constantWebPrivacyWPResourceDataChangedNotificationName; } } ``` ...in contrast, the original macro `SOFT_LINK_CONSTANT_FOR_HEADER` expands to: ``` namespace PAL { PAL_EXPORT NSNotificationName get_WebPrivacy_WPResourceDataChangedNotificationName(); NSNotificationName get_WebPrivacy_WPResourceDataChangedNotificationName() { static NSNotificationName constantWebPrivacyWPResourceDataChangedNotificationName; static dispatch_once_t once; dispatch_once(&once, ^{ void* constant = dlsym(WebPrivacyLibrary(), "WPResourceDataChangedNotificationName"); RELEASE_ASSERT_WITH_MESSAGE(constant, "%s", dlerror()); constantWebPrivacyWPResourceDataChangedNotificationName = *static_cast<NSNotificationName const *>(constant); }); return constantWebPrivacyWPResourceDataChangedNotificationName; } } ``` This exposes a real bug caused by 267051@main, where we no longer listen for the resource data changed notification from WebPrivacy in WebKit since the soft-linking helper now always returns `nil`. Fix this by reverting to the original `SOFT_LINK_CONSTANT_FOR_HEADER` for these two symbols, which should be fine (i.e. not `RELEASE_ASSERT`) as long as we only ever call them from inside a `canUseWebPrivacyFramework()` check. * Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.h: * Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.mm: Canonical link: https://commits.webkit.org/267181@main Identifier: 265870.484@safari-7616-branch
- Loading branch information