1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Scripts: Register window.external to all frames

It seems that only one QWebChannel connection per page
is supported, so we need to forward window.external to
all subframes.
This commit is contained in:
David Rosca 2015-08-31 12:28:44 +02:00
parent fa2779e6b9
commit 19f1ed6bfb
2 changed files with 16 additions and 4 deletions

View File

@ -459,7 +459,7 @@ function init()
if (window.external) {
init();
} else {
document.addEventListener('qz_external_created', init);
document.addEventListener('_qupzilla_external_created', init);
}
</script>

View File

@ -25,12 +25,24 @@ QString Scripts::setupWebChannel()
{
QString source = QL1S("(function() {"
"%1"
"new QWebChannel(qt.webChannelTransport, function(channel) {"
" window.external = channel.objects.qz_object;"
"function registerExternal(e) {"
" window.external = e;"
" if (window.external) {"
" var event = new Event('qz_external_created');"
" var event = new Event('_qupzilla_external_created');"
" document.dispatchEvent(event);"
" }"
"}"
"if (self !== top) {"
" if (top.external)"
" registerExternal(top.external);"
" else"
" top.document.addEventListener('_qupzilla_external_created', function() {"
" registerExternal(top.external);"
" });"
" return;"
"}"
"new QWebChannel(qt.webChannelTransport, function(channel) {"
" registerExternal(channel.objects.qz_object);"
"});"
"})()");