It’s seems that, in either GJS or Python, it’s not currently possible to register message handlers in the default world in WebKit-6.0, as it doesn’t accept null / None as the second argument.
const webView = new WebKit.WebView()
const manager = webView.get_user_content_manager()
manager.register_script_message_handler('test', null)
// Error: Argument world_name may not be null
I also tried passing '' as the world name, but that seems to result in the handler being registered in a different world.
Um, there’s also this bug which will break the signal even if you do manage to register the handler, although many distros have manually applied that patch already.