Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (262939 => 262940)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2020-06-12 08:42:50 UTC (rev 262939)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2020-06-12 08:49:27 UTC (rev 262940)
@@ -60,6 +60,7 @@
#include "WebKitUserMessagePrivate.h"
#include "WebKitWebContextPrivate.h"
#include "WebKitWebResourcePrivate.h"
+#include "WebKitWebViewInternal.h"
#include "WebKitWebViewPrivate.h"
#include "WebKitWebViewSessionStatePrivate.h"
#include "WebKitWebsiteDataManagerPrivate.h"
@@ -3733,6 +3734,27 @@
reinterpret_cast<GDestroyNotify>(webkit_javascript_result_unref));
}
+static void webkitWebViewRunJavaScriptWithParams(WebKitWebView* webView, const gchar* script, RunJavaScriptParameters&& params, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
+
+ getPage(webView).runJavaScriptInMainFrame(WTFMove(params), [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
+ ExceptionDetails exceptionDetails;
+ if (details)
+ exceptionDetails = *details;
+ webkitWebViewRunJavaScriptCallback(serializedScriptValue, exceptionDetails, task.get());
+ });
+}
+
+void webkitWebViewRunJavascriptWithoutForcedUserGestures(WebKitWebView* webView, const gchar* script, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(script);
+
+ RunJavaScriptParameters params = { String::fromUTF8(script), URL { }, false, WTF::nullopt, false };
+ webkitWebViewRunJavaScriptWithParams(webView, script, WTFMove(params), cancellable, callback, userData);
+}
+
/**
* webkit_web_view_run_javascript:
* @web_view: a #WebKitWebView
@@ -3752,13 +3774,8 @@
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
g_return_if_fail(script);
- GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
- getPage(webView).runJavaScriptInMainFrame({ String::fromUTF8(script), URL { }, false, WTF::nullopt, true }, [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, Optional<ExceptionDetails> details, WebKit::CallbackBase::Error) {
- ExceptionDetails exceptionDetails;
- if (details)
- exceptionDetails = *details;
- webkitWebViewRunJavaScriptCallback(serializedScriptValue, exceptionDetails, task.get());
- });
+ RunJavaScriptParameters params = { String::fromUTF8(script), URL { }, false, WTF::nullopt, true };
+ webkitWebViewRunJavaScriptWithParams(webView, script, WTFMove(params), cancellable, callback, userData);
}
/**
Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewInternal.h (0 => 262940)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewInternal.h 2020-06-12 08:49:27 UTC (rev 262940)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2020 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include <gio/gio.h>
+
+// Private API required by the unit tests.
+
+typedef struct _WebKitWebView WebKitWebView;
+
+void webkitWebViewRunJavascriptWithoutForcedUserGestures(WebKitWebView*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer);