[webkit-gtk] window.webkit undefined?

Antonio antonio at vieiro.net
Thu Jan 26 03:47:18 PST 2023

Hi Michael,

Thanks for the response. It was my fault after all! Setting the signal / 
webkit_user_content_manager_register_script_message_handler calls on the 
wrong content manager instance.

Things work as expected now from JS in the web content (I do want the 
web content to be able to post messages to the C counterpart).

Apologies for the noise,

On 25/1/23 19:07, Michael Catanzaro wrote:
> On Wed, Jan 25 2023 at 06:37:11 PM +0100, Antonio <antonio at vieiro.net> 
> wrote:
>> The fact is that I'm trying to receive messages from a <script> in my 
>> webpage through the "window.webkit.messageHandlers.XYZ.postMessage()" 
>> call, as indicated in [1], but "window.webkit" is undefined.
> I think it's only going to be defined for JS executed via WebKit API, 
> not for JS that's defined by your web content? Otherwise random web 
> content would be able to talk to your internal message handlers, and 
> that's probably not good.
> Try webkit_web_view_run_javascript() in the UI process, or 
> jsc_value_object_invoke_method() in the web process.
> Michael

More information about the webkit-gtk mailing list