Bug 258558

Summary: `PageGroup`'s `Preferences`are ignored when creating `WKWebView`
Product: WebKit Reporter: Vitaly Dyackhov <vitaly>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Vitaly Dyackhov 2023-06-27 04:55:33 PDT
There are two APIs to create a `WKWebView`:
- `PlatformWebView(WKPageConfigurationRef configuration)`
- `PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)`

If we want to set some preferences, it's quite straightforward using `WKPageConfigurationRef`:
```
auto configuration = adoptWK(WKPageConfigurationCreate());
auto preferences = adoptWK(WKPreferencesCreate());
WKPageConfigurationSetPreferences(configuration.get(), preferences.get());
```

When using the context and the page group, we don't have access to the configuration object.
But it's possible to set preferences to the page group:
```
WKRetainPtr<WKPageGroupRef> pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(Util::toWK("GetUserMedia").get()));
WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup.get());
```

When we then create an instance of `WKWebView` we copy `WKPageConfigruation` into `WKWebViewConfigruation` and pass them as a parameter:
```
auto configuration = adoptNS([WKWebViewConfiguration new]);
if (auto* preferences = WKPageConfigurationGetPreferences(pageConfiguration))
    configuration.get().preferences = (WKPreferences *)preferences;
m_view = [[wkViewSubclass alloc] initWithFrame:rect configuration:configuration.get()];
```
But we ignore pageGroup's preferences.

I must say, that it's really confusing to have two levels of `Preferences`:
WKPageConfiguration
    |-WKPreferences
    |-WKPageGroup
        |-WKPreferences
but for now, we should at least copy pageGroup's preferences to WebViewConfiguration.
Comment 1 Vitaly Dyackhov 2023-06-27 05:00:17 PDT
Pull request: https://github.com/WebKit/WebKit/pull/15325
Comment 2 Radar WebKit Bug Importer 2023-07-04 04:56:16 PDT
<rdar://problem/111737120>