From 171369203fed7af98fd0233eb8c837f9616f7ae4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 28 Apr 2023 16:39:49 +0200 Subject: [PATCH] Miscellaneous fixes for WebKit2 wxWebView backend See #23497. (cherry picked from commit 8d8f94da641fc95a6d5203276fa2e26abb42e9fc) --- docs/changes.txt | 1 + src/gtk/webview_webkit2.cpp | 2 +- tests/controls/webtest.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 1e17fd875d..d524dbd0ff 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -255,6 +255,7 @@ wxGTK: - Dramatically optimize adding many items to wxChoice (Ian McInerney, #23443). - Improve document wxGLCanvas::CreateSurface() (Dan Gudmundsson, #23366). +- Fix loading WebKit2 extension when using wxWebView (Scott Talbert, #23497). wxMSW: diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index d53d29dff8..191cbcf2cc 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -533,7 +533,7 @@ wxgtk_initialize_web_extensions(WebKitWebContext *context, for ( size_t n = 0; n < WXSIZEOF(directories); ++n ) { - if ( !TrySetWebExtensionsDirectory(context, directories[n]) ) + if ( TrySetWebExtensionsDirectory(context, directories[n]) ) break; } } diff --git a/tests/controls/webtest.cpp b/tests/controls/webtest.cpp index c0eb77f529..98a817c997 100644 --- a/tests/controls/webtest.cpp +++ b/tests/controls/webtest.cpp @@ -232,9 +232,11 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]") // With WebKit SelectAll() sends a request to perform the selection to // another process via proxy and there doesn't seem to be any way to // wait until this request is actually handled, so loop here for some a - // bit before giving up. - for ( wxStopWatch sw; !m_browser->HasSelection() && sw.Time() < 50; ) - wxMilliSleep(1); + // bit before giving up. Avoid calling HasSelection() right away + // without wxYielding a bit because this seems to cause the extension + // to hang with webkit 2.40.0+. + for ( wxStopWatch sw; sw.Time() < 50; ) + wxYield(); #endif // wxUSE_WEBVIEW_WEBKIT2 CHECK(m_browser->HasSelection());