Skip to content

Commit 38a78bf

Browse files
authored
browser(webkit): install page group preferences to new pages (#2118)
1 parent 193924f commit 38a78bf

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1218
1+
1219

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12636,10 +12636,10 @@ index 0000000000000000000000000000000000000000..30e6ae3bdc8c1695189885afae949071
1263612636
+} // namespace WebKit
1263712637
diff --git a/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
1263812638
new file mode 100644
12639-
index 0000000000000000000000000000000000000000..544442b75afcba6e121ab202ad32dcdfaf923e2e
12639+
index 0000000000000000000000000000000000000000..9ea75b043513fe4c56b3af33d2082375971a75f7
1264012640
--- /dev/null
1264112641
+++ b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
12642-
@@ -0,0 +1,83 @@
12642+
@@ -0,0 +1,82 @@
1264312643
+/*
1264412644
+ * Copyright (C) 2020 Microsoft Corporation.
1264512645
+ *
@@ -12695,7 +12695,6 @@ index 0000000000000000000000000000000000000000..544442b75afcba6e121ab202ad32dcdf
1269512695
+RefPtr<WebPageProxy> InspectorPlaywrightAgentClientWin::createPage(WTF::String& error, const BrowserContext& context)
1269612696
+{
1269712697
+ auto conf = API::PageConfiguration::create();
12698-
+ auto prefs = WebPreferences::create(String(), "WebKit2Automation.", "WebKit2Automation.");
1269912698
+ conf->setProcessPool(context.processPool.get());
1270012699
+ conf->setWebsiteDataStore(context.dataStore.get());
1270112700
+ return toImpl(m_createPage(toAPI(&conf.get())));

browser_patches/webkit/src/Tools/Playwright/win/MainWindow.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,18 @@ void MainWindow::rescaleToolbar()
173173
m_toolbarItemsWidth = rect.right;
174174
}
175175

176-
bool MainWindow::init(HINSTANCE hInstance, WKContextRef context, WKWebsiteDataStoreRef dataStore)
176+
bool MainWindow::init(HINSTANCE hInstance, WKPageConfigurationRef conf)
177177
{
178-
auto conf = adoptWK(WKPageConfigurationCreate());
178+
auto pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(createWKString("WinPlaywright").get()));
179179
auto prefs = adoptWK(WKPreferencesCreate());
180180

181-
auto pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(createWKString("WinPlaywright").get()));
182-
WKPageConfigurationSetPageGroup(conf.get(), pageGroup.get());
181+
WKPageConfigurationSetPageGroup(conf, pageGroup.get());
182+
WKPageConfigurationSetPreferences(conf, prefs.get());
183183
WKPageGroupSetPreferences(pageGroup.get(), prefs.get());
184184

185185
WKPreferencesSetMediaCapabilitiesEnabled(prefs.get(), false);
186186
WKPreferencesSetDeveloperExtrasEnabled(prefs.get(), true);
187-
WKPageConfigurationSetPreferences(conf.get(), prefs.get());
188-
189-
WKPageConfigurationSetContext(conf.get(), context);
190-
WKPageConfigurationSetWebsiteDataStore(conf.get(), dataStore);
191187

192-
return init(hInstance, conf.get());
193-
}
194-
195-
bool MainWindow::init(HINSTANCE hInstance, WKPageConfigurationRef conf)
196-
{
197188
m_configuration = conf;
198189

199190
registerClass(hInstance);

browser_patches/webkit/src/Tools/Playwright/win/MainWindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class MainWindow : public BrowserWindowClient {
4040
MainWindow();
4141

4242
~MainWindow();
43-
bool init(HINSTANCE hInstance, WKContextRef, WKWebsiteDataStoreRef);
4443
bool init(HINSTANCE hInstance, WKPageConfigurationRef);
4544

4645
void resizeSubViews();

browser_patches/webkit/src/Tools/Playwright/win/WebKitBrowserWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ void WebKitBrowserWindow::handleJavaScriptDialog(WKPageRef page, bool accept, WK
340340

341341
WKPageRef WebKitBrowserWindow::createPageCallback(WKPageConfigurationRef configuration)
342342
{
343+
// This comes from the Playwright agent, configuration is a pool+data pair.
343344
return WebKitBrowserWindow::createViewCallback(configuration, true);
344345
}
345346

@@ -357,6 +358,7 @@ WKPageRef WebKitBrowserWindow::createViewCallback(WKPageConfigurationRef configu
357358

358359
WKPageRef WebKitBrowserWindow::createNewPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef, WKWindowFeaturesRef, const void*)
359360
{
361+
// This comes from the client for popups, configuration is inherited from main page.
360362
// Retain popups as per API contract.
361363
WKRetainPtr<WKPageRef> newPage = createViewCallback(configuration, false);
362364
return newPage.leakRef();

browser_patches/webkit/src/Tools/Playwright/win/WinMain.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
110110
WKContextSetPrimaryDataStore(context.get(), dataStore.get());
111111

112112
auto* mainWindow = new MainWindow();
113-
HRESULT hr = mainWindow->init(hInst, context.get(), dataStore.get());
113+
auto conf = adoptWK(WKPageConfigurationCreate());
114+
WKPageConfigurationSetContext(conf.get(), context.get());
115+
WKPageConfigurationSetWebsiteDataStore(conf.get(), dataStore.get());
116+
HRESULT hr = mainWindow->init(hInst, conf.get());
114117
if (FAILED(hr))
115118
goto exit;
116119

0 commit comments

Comments
 (0)