diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2021-09-20 09:29:30 +0200 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2021-09-27 10:16:53 +0200 |
commit | 70abc0b2eebc777309d372203df5ca1e785402d8 (patch) | |
tree | 5833e0320c839927d16577f5a865245a7d1c7f06 /src/core/renderer | |
parent | baf1f70c917e31e44a3b2e08d3ee36bbce825750 (diff) |
Fix WebChannel when JavaScript is disabled
WebChannel was not working in ApplicationWorld with JavaScript disabled
in MainWorld, because WebChannelIPCTransport::DidClearWindowObject() is
called only when the window object was cleared in the main world. Moving
the WebChannelTransport installation logic to DidCreateScriptContext()
works in other worlds, so fixes the problem.
Task-number: QTBUG-88875
Pick-to: 6.2
Change-Id: Ia75613b66a1e049f617f0664684b153b6875e9de
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/renderer')
-rw-r--r-- | src/core/renderer/web_channel_ipc_transport.cpp | 16 | ||||
-rw-r--r-- | src/core/renderer/web_channel_ipc_transport.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp index fff3eb70f..8525c3619 100644 --- a/src/core/renderer/web_channel_ipc_transport.cpp +++ b/src/core/renderer/web_channel_ipc_transport.cpp @@ -259,21 +259,21 @@ void WebChannelIPCTransport::DispatchWebChannelMessage(const std::vector<uint8_t frame->CallFunctionEvenIfScriptDisabled(callback, webChannelObject, 1, argv); } -void WebChannelIPCTransport::WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) -{ - if (static_cast<uint>(worldId) == m_worldId) - m_canUseContext = false; -} - -void WebChannelIPCTransport::DidClearWindowObject() +void WebChannelIPCTransport::DidCreateScriptContext(v8::Local<v8::Context> context, int32_t worldId) { - if (!m_canUseContext) { + if (static_cast<uint>(worldId) == m_worldId && !m_canUseContext) { m_canUseContext = true; if (m_worldInitialized) WebChannelTransport::Install(render_frame()->GetWebFrame(), m_worldId); } } +void WebChannelIPCTransport::WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) +{ + if (static_cast<uint>(worldId) == m_worldId) + m_canUseContext = false; +} + void WebChannelIPCTransport::OnDestruct() { delete this; diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h index 276167a67..f048a26d8 100644 --- a/src/core/renderer/web_channel_ipc_transport.h +++ b/src/core/renderer/web_channel_ipc_transport.h @@ -64,8 +64,8 @@ private: void DispatchWebChannelMessage(const std::vector<uint8_t> &json, uint32_t worldId) override; // RenderFrameObserver + void DidCreateScriptContext(v8::Local<v8::Context> context, int32_t worldId) override; void WillReleaseScriptContext(v8::Local<v8::Context> context, int worldId) override; - void DidClearWindowObject() override; void OnDestruct() override; void BindReceiver(mojo::PendingAssociatedReceiver<qtwebchannel::mojom::WebChannelTransportRender> receiver); |