Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser(webkit): install page group preferences to new pages #2118

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1218
1219
5 changes: 2 additions & 3 deletions browser_patches/webkit/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -12636,10 +12636,10 @@ index 0000000000000000000000000000000000000000..30e6ae3bdc8c1695189885afae949071
+} // namespace WebKit
diff --git a/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..544442b75afcba6e121ab202ad32dcdfaf923e2e
index 0000000000000000000000000000000000000000..9ea75b043513fe4c56b3af33d2082375971a75f7
--- /dev/null
+++ b/Source/WebKit/UIProcess/win/InspectorPlaywrightAgentClientWin.cpp
@@ -0,0 +1,83 @@
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2020 Microsoft Corporation.
+ *
Expand Down Expand Up @@ -12695,7 +12695,6 @@ index 0000000000000000000000000000000000000000..544442b75afcba6e121ab202ad32dcdf
+RefPtr<WebPageProxy> InspectorPlaywrightAgentClientWin::createPage(WTF::String& error, const BrowserContext& context)
+{
+ auto conf = API::PageConfiguration::create();
+ auto prefs = WebPreferences::create(String(), "WebKit2Automation.", "WebKit2Automation.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this line?

+ conf->setProcessPool(context.processPool.get());
+ conf->setWebsiteDataStore(context.dataStore.get());
+ return toImpl(m_createPage(toAPI(&conf.get())));
Expand Down
17 changes: 4 additions & 13 deletions browser_patches/webkit/src/Tools/Playwright/win/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,18 @@ void MainWindow::rescaleToolbar()
m_toolbarItemsWidth = rect.right;
}

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

auto pageGroup = adoptWK(WKPageGroupCreateWithIdentifier(createWKString("WinPlaywright").get()));
WKPageConfigurationSetPageGroup(conf.get(), pageGroup.get());
WKPageConfigurationSetPageGroup(conf, pageGroup.get());
WKPageConfigurationSetPreferences(conf, prefs.get());
WKPageGroupSetPreferences(pageGroup.get(), prefs.get());

WKPreferencesSetMediaCapabilitiesEnabled(prefs.get(), false);
WKPreferencesSetDeveloperExtrasEnabled(prefs.get(), true);
WKPageConfigurationSetPreferences(conf.get(), prefs.get());

WKPageConfigurationSetContext(conf.get(), context);
WKPageConfigurationSetWebsiteDataStore(conf.get(), dataStore);

return init(hInstance, conf.get());
}

bool MainWindow::init(HINSTANCE hInstance, WKPageConfigurationRef conf)
{
m_configuration = conf;

registerClass(hInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class MainWindow : public BrowserWindowClient {
MainWindow();

~MainWindow();
bool init(HINSTANCE hInstance, WKContextRef, WKWebsiteDataStoreRef);
bool init(HINSTANCE hInstance, WKPageConfigurationRef);

void resizeSubViews();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ void WebKitBrowserWindow::handleJavaScriptDialog(WKPageRef page, bool accept, WK

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

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

WKPageRef WebKitBrowserWindow::createNewPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef, WKWindowFeaturesRef, const void*)
{
// This comes from the client for popups, configuration is inherited from main page.
// Retain popups as per API contract.
WKRetainPtr<WKPageRef> newPage = createViewCallback(configuration, false);
return newPage.leakRef();
Expand Down
5 changes: 4 additions & 1 deletion browser_patches/webkit/src/Tools/Playwright/win/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
WKContextSetPrimaryDataStore(context.get(), dataStore.get());

auto* mainWindow = new MainWindow();
HRESULT hr = mainWindow->init(hInst, context.get(), dataStore.get());
auto conf = adoptWK(WKPageConfigurationCreate());
WKPageConfigurationSetContext(conf.get(), context.get());
WKPageConfigurationSetWebsiteDataStore(conf.get(), dataStore.get());
HRESULT hr = mainWindow->init(hInst, conf.get());
if (FAILED(hr))
goto exit;

Expand Down