Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
browser(webkit): make wpe compile (#410)
Pavel Feldmanec50a8b9dccb
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBERindex b9650fd8e4..48c6edb20c 100644--- a/browser_patches/webkit/BUILD_NUMBER+++ b/browser_patches/webkit/BUILD_NUMBER@@ -1 +1 @@-1068+1069diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diffindex ac6e01f55d..45f47c0ac6 100644--- a/browser_patches/webkit/patches/bootstrap.diff+++ b/browser_patches/webkit/patches/bootstrap.diff@@ -4158,6 +4158,18 @@ index fcb9e8ddb8c3a804aa27339cab1b0039eb136f53..633a4efd58ac5c6a8999fa8d75d88342const String& host = challenge.protectionSpace().host();NSArray *certificates = [NSURLRequest allowsSpecificHTTPSCertificateForHost:host];if (!certificates)+diff --git a/Source/WebKit/PlatformWPE.cmake b/Source/WebKit/PlatformWPE.cmake+index a8a95f4b0db4a50a8ef5b72039c51cc5818ed304..324504696770fb095a70153aa830a87b46b77327 100644+--- a/Source/WebKit/PlatformWPE.cmake++++ b/Source/WebKit/PlatformWPE.cmake+@@ -248,6 +248,7 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES+ "${WEBKIT_DIR}/UIProcess/API/wpe"+ "${WEBKIT_DIR}/UIProcess/CoordinatedGraphics"+ "${WEBKIT_DIR}/UIProcess/geoclue"++ "${WEBKIT_DIR}/UIProcess/glib"+ "${WEBKIT_DIR}/UIProcess/gstreamer"+ "${WEBKIT_DIR}/UIProcess/linux"+ "${WEBKIT_DIR}/UIProcess/soup"diff --git a/Source/WebKit/Shared/API/c/wpe/WebKit.h b/Source/WebKit/Shared/API/c/wpe/WebKit.hindex 898e30b370db8176e886fbbde0cd960e38a64818..74945e06fac0eb14936578de6a599a123364a63a 100644--- a/Source/WebKit/Shared/API/c/wpe/WebKit.h@@ -4907,10 +4919,64 @@ index f769407fdc660c6f6fef77af90a43bd5dca9d544..ba010ed593bdedc0d70e4f4d3139e73dbool canRunBeforeUnloadConfirmPanel() const final { return true; }diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp-index 33a9b7d5ad060f275dcf7156a8cff3f37644e736..406c6431bd84a9193f75a7689553fe79eb5d864b 100644+index 33a9b7d5ad060f275dcf7156a8cff3f37644e736..128a5c75807848de10aed628618fc7d149a42792 100644--- a/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp-@@ -385,6 +385,11 @@ static void webkitWebContextConstructed(GObject* object)+@@ -119,9 +119,7 @@ enum {+ PROP_LOCAL_STORAGE_DIRECTORY,+ #endif+ PROP_WEBSITE_DATA_MANAGER,+-#if PLATFORM(GTK)+ PROP_PSON_ENABLED+-#endif+ };++ enum {+@@ -202,9 +200,7 @@ struct _WebKitWebContextPrivate {++ RefPtr<WebProcessPool> processPool;+ bool clientsDetached;+-#if PLATFORM(GTK)+ bool psonEnabled;+-#endif++ GRefPtr<WebKitFaviconDatabase> faviconDatabase;+ GRefPtr<WebKitSecurityManager> securityManager;+@@ -329,11 +325,9 @@ static void webkitWebContextGetProperty(GObject* object, guint propID, GValue* v+ case PROP_WEBSITE_DATA_MANAGER:+ g_value_set_object(value, webkit_web_context_get_website_data_manager(context));+ break;+-#if PLATFORM(GTK)+ case PROP_PSON_ENABLED:+ g_value_set_boolean(value, context->priv->psonEnabled);+ break;+-#endif+ default:+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propID, paramSpec);+ }+@@ -354,11 +348,9 @@ static void webkitWebContextSetProperty(GObject* object, guint propID, const GVa+ context->priv->websiteDataManager = manager ? WEBKIT_WEBSITE_DATA_MANAGER(manager) : nullptr;+ break;+ }+-#if PLATFORM(GTK)+ case PROP_PSON_ENABLED:+ context->priv->psonEnabled = g_value_get_boolean(value);+ break;+-#endif+ default:+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propID, paramSpec);+ }+@@ -375,9 +367,7 @@ static void webkitWebContextConstructed(GObject* object)++ API::ProcessPoolConfiguration configuration;+ configuration.setInjectedBundlePath(FileSystem::stringFromFileSystemRepresentation(bundleFilename.get()));+-#if PLATFORM(GTK)+ configuration.setProcessSwapsOnNavigation(priv->psonEnabled);+-#endif++ if (!priv->websiteDataManager)+ priv->websiteDataManager = adoptGRef(webkit_website_data_manager_new("local-storage-directory", priv->localStorageDirectory.data(), nullptr));+@@ -385,6 +375,11 @@ static void webkitWebContextConstructed(GObject* object)if (!webkit_website_data_manager_is_ephemeral(priv->websiteDataManager.get()))WebKit::LegacyGlobalSettings::singleton().setHSTSStorageDirectory(FileSystem::stringFromFileSystemRepresentation(webkit_website_data_manager_get_hsts_cache_directory(priv->websiteDataManager.get())));@@ -4922,6 +4988,22 @@ index 33a9b7d5ad060f275dcf7156a8cff3f37644e736..406c6431bd84a9193f75a7689553fe79priv->processPool = WebProcessPool::create(configuration);priv->processPool->setPrimaryDataStore(webkitWebsiteDataManagerGetDataStore(priv->websiteDataManager.get()));priv->processPool->setUserMessageHandler([webContext](UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler) {+@@ -496,7 +491,6 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass+ WEBKIT_TYPE_WEBSITE_DATA_MANAGER,+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));++-#if PLATFORM(GTK)+ /**+ * WebKitWebContext:process-swap-on-cross-site-navigation-enabled:+ *+@@ -519,7 +513,6 @@ static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass+ _("Whether swap Web processes on cross-site navigations is enabled"),+ FALSE,+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));+-#endif++ /**+ * WebKitWebContext::download-started:diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cppindex 646e45adc2818287f47d00340567822c210a16ed..1caff042a6783addd52355527ea9797fb4e4c513 100644--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp@@ -5066,10 +5148,10 @@ index 930b17b6629e04d0dfa2222bbc3217877c6e1812..395462e5f01c195231e9296d1204167c#include <webkit2/WebKitContextMenuItem.h>diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.h b/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.hnew file mode 100644-index 0000000000000000000000000000000000000000..773cbab35accf562349a133fe14ac84c22d32cc6+index 0000000000000000000000000000000000000000..b9392bc9f232f1f8a5be1e9668ec31e11bd8e3f8--- /dev/null+++ b/Source/WebKit/UIProcess/API/wpe/WebKitBrowserInspector.h-@@ -0,0 +1,76 @@+@@ -0,0 +1,79 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -5143,6 +5225,9 @@ index 0000000000000000000000000000000000000000..773cbab35accf562349a133fe14ac84c+WEBKIT_API WebKitBrowserInspector *+webkit_browser_inspector_get_default (void);+++WEBKIT_API void++webkit_browser_inspector_initialize_pipe (void);+++G_END_DECLS++#endif@@ -8979,10 +9064,10 @@ index 0000000000000000000000000000000000000000..fbe0bfb31966980500d4b39d10a39aa8+#endifdiff --git a/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp b/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cppnew file mode 100644-index 0000000000000000000000000000000000000000..db8eb05b6e9e738e61e04823929bbdf44373c5b0+index 0000000000000000000000000000000000000000..5dc76aa302cb574307059e66a1b73730efe920da--- /dev/null+++ b/Source/WebKit/UIProcess/wpe/WebPageInspectorEmulationAgentWPE.cpp-@@ -0,0 +1,40 @@+@@ -0,0 +1,41 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -9016,19 +9101,20 @@ index 0000000000000000000000000000000000000000..db8eb05b6e9e738e61e04823929bbdf4++namespace WebKit {+-+void WebPageInspectorEmulationAgent::platformSetSize(String& error, int width, int height)++void WebPageInspectorEmulationAgent::platformSetSize(int width, int height, Function<void (const String& error)>&& callback)+{+ struct wpe_view_backend* backend = m_page.viewBackend();+ wpe_view_backend_dispatch_set_size(backend, width, height);++ callback(String());+}++} // namespace WebKitdiff --git a/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cppnew file mode 100644-index 0000000000000000000000000000000000000000..3850c53812149aac3258f9d5c7fc852b02231c1e+index 0000000000000000000000000000000000000000..be4d3436bd66359d3de795bf368359bad0fe785d--- /dev/null+++ b/Source/WebKit/UIProcess/wpe/WebPageInspectorInputAgentWPE.cpp-@@ -0,0 +1,98 @@+@@ -0,0 +1,94 @@+/*+ * Copyright (C) 2019 Microsoft Corporation.+ *@@ -9064,10 +9150,6 @@ index 0000000000000000000000000000000000000000..3850c53812149aac3258f9d5c7fc852b++namespace WebKit {+-+void WebPageInspectorInputAgent::platformDispatchKeyEvent(String& error, const String& type, const String& keyRef)-+{-+}-++static unsigned toWPEButton(WebMouseEvent::Button button)+{+ switch (button) {@@ -9543,26 +9625,28 @@ index 1570d65effb5d601ee3c44a2a7461436f4691c2c..456f96cf589320efa70a76f76e230b67typedef struct _BrowserWindow BrowserWindow;diff --git a/Tools/MiniBrowser/gtk/main.c b/Tools/MiniBrowser/gtk/main.c-index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..bc895f379e5dcca90464b63ebebcc756c479c47e 100644+index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..be501274061102f805c43df37a67e4a1cf6d5494 100644--- a/Tools/MiniBrowser/gtk/main.c+++ b/Tools/MiniBrowser/gtk/main.c-@@ -53,6 +53,7 @@ static const char *cookiesFile;+@@ -53,6 +53,8 @@ static const char *cookiesFile;static const char *cookiesPolicy;static const char *proxy;static gboolean darkMode;+static gboolean inspectorPipe;++static gboolean headless;static gboolean printVersion;typedef enum {-@@ -121,6 +122,7 @@ static const GOptionEntry commandLineOptions[] =+@@ -121,6 +123,8 @@ static const GOptionEntry commandLineOptions[] ={ "ignore-tls-errors", 0, 0, G_OPTION_ARG_NONE, &ignoreTLSErrors, "Ignore TLS errors", NULL },{ "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },{ "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WebKitGTK version", NULL },+ { "inspector-pipe", 0, 0, G_OPTION_ARG_NONE, &inspectorPipe, "Open pipe connection to the remote inspector", NULL },++ { "headless", 0, 0, G_OPTION_ARG_NONE, &headless, "Noop headless operation", NULL },{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URL…]" },{ 0, 0, 0, 0, 0, 0, 0 }};-@@ -498,6 +500,29 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResul+@@ -498,6 +502,29 @@ static void filterSavedCallback(WebKitUserContentFilterStore *store, GAsyncResulg_main_loop_quit(data->mainLoop);}@@ -9592,7 +9676,7 @@ index 4c5147dcd38a53e2feaeaae0fce38f92dc60eba6..bc895f379e5dcca90464b63ebebcc756int main(int argc, char *argv[]){#if ENABLE_DEVELOPER_MODE-@@ -541,10 +566,22 @@ int main(int argc, char *argv[])+@@ -541,10 +568,22 @@ int main(int argc, char *argv[])return 0;}@@ -10151,11 +10235,39 @@ index 031edd533ae1b791bc6862c631b909ae99dac886..0eee1f2071e5e6800f4889a561e94951+}+@end+diff --git a/Tools/MiniBrowser/wpe/CMakeLists.txt b/Tools/MiniBrowser/wpe/CMakeLists.txt+index 245f319abf2595e154d03e1ee8b3250d7f46aafd..9cae87b23deade7c163f34aade2b2aed91d47fc8 100644+--- a/Tools/MiniBrowser/wpe/CMakeLists.txt++++ b/Tools/MiniBrowser/wpe/CMakeLists.txt+@@ -13,6 +13,7 @@ set(MiniBrowser_INCLUDE_DIRECTORIES++ set(MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES+ ${ATK_INCLUDE_DIRS}++ ${GLIB_INCLUDE_DIRS}+ ${WPE_INCLUDE_DIRS}+ ${WPEBACKEND_FDO_INCLUDE_DIRS}+ )diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp-index 2d183d394123bd84545dc51f53eb9be796fb8873..d94d4f06fc5be9ab9cd732ceb612a1676089ab82 100644+index 2d183d394123bd84545dc51f53eb9be796fb8873..c59a705dfe586c1ed1f08a173715cf3c35bc49de 100644--- a/Tools/MiniBrowser/wpe/main.cpp+++ b/Tools/MiniBrowser/wpe/main.cpp-@@ -172,6 +172,41 @@ static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationActi+@@ -43,6 +43,7 @@ static gboolean headlessMode;+ static gboolean privateMode;+ static gboolean automationMode;+ static gboolean ignoreTLSErrors;++static gboolean inspectorPipe;+ static const char* contentFilter;+ static const char* cookiesFile;+ static const char* cookiesPolicy;+@@ -63,6 +64,7 @@ static const GOptionEntry commandLineOptions[] =+ { "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },+ { "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color. Default: white", "COLOR" },+ { "version", 'v', 0, G_OPTION_ARG_NONE, &printVersion, "Print the WPE version", nullptr },++ { "inspector-pipe", 'v', 0, G_OPTION_ARG_NONE, &inspectorPipe, "Expose remote debugging protocol over pipe", nullptr },+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" },+ { nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }+ };+@@ -172,6 +174,41 @@ static WebKitWebView* createWebView(WebKitWebView* webView, WebKitNavigationActireturn newWebView;}@@ -10186,23 +10298,24 @@ index 2d183d394123bd84545dc51f53eb9be796fb8873..d94d4f06fc5be9ab9cd732ceb612a167+ g_main_loop_quit(mainLoop);+}+-+static void configureBrowserInspector(GMainLoop* mainLoop, WebKitWebView *firstWebView)++static void configureBrowserInspector()+{+ WebKitBrowserInspector* browserInspector = webkit_browser_inspector_get_default();+ g_signal_connect(browserInspector, "create-new-page", G_CALLBACK(createNewPage), NULL);+ // FIXME: This signal is received only when closeAll is called. We should not rely on that.-+ g_signal_connect(firstWebView, "close", G_CALLBACK(closeAll), mainLoop);++ webkit_browser_inspector_initialize_pipe();+}+int main(int argc, char *argv[]){#if ENABLE_DEVELOPER_MODE-@@ -301,6 +336,8 @@ int main(int argc, char *argv[])- g_signal_connect(webView, "permission-request", G_CALLBACK(decidePermissionRequest), nullptr);- g_signal_connect(webView, "create", G_CALLBACK(createWebView), nullptr);+@@ -280,6 +317,9 @@ int main(int argc, char *argv[])+ delete static_cast<WPEToolingBackends::ViewBackend*>(data);+ }, backend.release());-+ configureBrowserInspector(loop, webView);++ if (inspectorPipe)++ configureBrowserInspector();+- if (ignoreTLSErrors)- webkit_web_context_set_tls_errors_policy(webContext, WEBKIT_TLS_ERRORS_POLICY_IGNORE);-+ auto* webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,+ "backend", viewBackend,+ "web-context", webContext,