[webkit-changes] [WebKit/WebKit] 926721: [GTK][WPE] Support asynchronously returning values...
Siwei Li
noreply at github.com
Fri Nov 25 02:48:34 PST 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9267215ef0d1b1b2f0233ff63940fa293eb51d30
https://github.com/WebKit/WebKit/commit/9267215ef0d1b1b2f0233ff63940fa293eb51d30
Author: Siwei Li <siwei.li at live.com>
Date: 2022-11-25 (Fri, 25 Nov 2022)
Changed paths:
M Source/WebKit/Shared/API/APISerializedScriptValue.h
M Source/WebKit/UIProcess/API/glib/APISerializedScriptValueGLib.cpp
M Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp
M Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.h.in
M Source/WebKit/UIProcess/API/glib/WebKitUserContentManagerPrivate.h
M Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp
Log Message:
-----------
[GTK][WPE] Support asynchronously returning values from user script messages
https://bugs.webkit.org/show_bug.cgi?id=243492
Reviewed by Carlos Garcia Campos.
Expose WebKit's functionality of responding asynchronously
to user script messages in the public API, by means of a
returned Promise object.
A new helper class "WebKitUserScriptMessgeReply" is added to
Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp;
it holds the returned JS value or the error message from executing
the user script message, which will be sent to the user by the
"didPostMessageWithAsyncReply()" method in the "ScriptMessageClientGtk"
class.
If asynchronous handling is wished for, the new
"webkit_user_content_manager_register_script_message_handler_with_reply()"
method should be used to register the message handler, its associated signal
being "WebKitUserContentManager::script-message-with-reply-received".
The user should ideally provide a callback reply in the script message,
otherwise an undefined value will be returned.
* Source/WebKit/Shared/API/APISerializedScriptValue.h:
* Source/WebKit/UIProcess/API/glib/APISerializedScriptValueGLib.cpp:
(API::SerializedScriptValue::createFromJSCValue):
* Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp:
(_WebKitScriptMessageReply::_WebKitScriptMessageReply):
(_WebKitScriptMessageReply::sendValue):
(_WebKitScriptMessageReply::sendErrorMessage):
(_WebKitScriptMessageReply::~_WebKitScriptMessageReply):
(webkit_script_message_reply_ref):
(webkit_script_message_reply_unref):
(webKitScriptMessageReplyCreate):
(webkit_script_message_reply_return_value):
(webkit_script_message_reply_return_error_message):
(webkit_user_content_manager_register_script_message_handler):
(webkit_user_content_manager_register_script_message_handler_with_reply):
(webkit_user_content_manager_register_script_message_handler_in_world):
* Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.h.in:
* Source/WebKit/UIProcess/API/glib/WebKitUserContentManagerPrivate.h:
* Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp:
(UserScriptMessageTest::UserScriptMessageTest):
(UserScriptMessageTest::~UserScriptMessageTest):
(UserScriptMessageTest::registerHandler):
(UserScriptMessageTest::scriptMessageReceived):
(UserScriptMessageTest::waitUntilMessageReceived):
(UserScriptMessageTest::asyncScriptMessageReceived):
(UserScriptMessageTest::waitUntilPromiseResolved):
(UserScriptMessageTest::runAsyncJavaScriptFinished):
(UserScriptMessageTest::postMessageAndWaitForPromiseResolved):
(testUserContentManagerScriptMessageWithReplyReceived):
(beforeAll):
Canonical link: https://commits.webkit.org/257016@main
More information about the webkit-changes
mailing list