summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2023-04-24 17:33:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2023-04-30 17:46:36 +0000
commit17c64fd5d2778df4a52849e8942104d4d9555a1e (patch)
tree0ef70dc889f3e6b34eb087101e63f71ab399d868 /src
parent6b3e7f2baa17a5bff7051949f743f2ec6926ec06 (diff)
downloadqtwebengine-17c64fd5d2778df4a52849e8942104d4d9555a1e.tar.gz
Fix user script management when subframes are present
Only the main frames should administer scripts associated with it. Pick-to: 6.5 Fixes: QTBUG-113109 Change-Id: Ibda66f55ef99da632134a9de1425797262faba9b Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io> Reviewed-by: Martin Negyokru <negyokru@inf.u-szeged.hu>
Diffstat (limited to 'src')
-rw-r--r--src/core/renderer/user_resource_controller.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp
index c49ecd391..ce942e0c8 100644
--- a/src/core/renderer/user_resource_controller.cpp
+++ b/src/core/renderer/user_resource_controller.cpp
@@ -289,10 +289,11 @@ void UserResourceController::renderFrameDestroyed(content::RenderFrame *renderFr
FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(renderFrame);
if (it == m_frameUserScriptMap.end()) // ASSERT maybe?
return;
- for (uint64_t id : std::as_const(it.value())) {
- m_scripts.remove(id);
+ if (renderFrame->IsMainFrame()) {
+ for (uint64_t id : std::as_const(it.value()))
+ m_scripts.remove(id);
}
- m_frameUserScriptMap.remove(renderFrame);
+ m_frameUserScriptMap.erase(it);
}
void UserResourceController::addScriptForFrame(const QtWebEngineCore::UserScriptData &script,
@@ -304,7 +305,8 @@ void UserResourceController::addScriptForFrame(const QtWebEngineCore::UserScript
if (!(*it).contains(script.scriptId))
(*it).append(script.scriptId);
- m_scripts.insert(script.scriptId, script);
+ if (!frame || frame->IsMainFrame())
+ m_scripts.insert(script.scriptId, script);
}
void UserResourceController::removeScriptForFrame(const QtWebEngineCore::UserScriptData &script,
@@ -315,7 +317,8 @@ void UserResourceController::removeScriptForFrame(const QtWebEngineCore::UserScr
return;
(*it).removeOne(script.scriptId);
- m_scripts.remove(script.scriptId);
+ if (!frame || frame->IsMainFrame())
+ m_scripts.remove(script.scriptId);
}
void UserResourceController::clearScriptsForFrame(content::RenderFrame *frame)
@@ -323,8 +326,10 @@ void UserResourceController::clearScriptsForFrame(content::RenderFrame *frame)
FrameUserScriptMap::iterator it = m_frameUserScriptMap.find(frame);
if (it == m_frameUserScriptMap.end())
return;
- for (uint64_t id : std::as_const(it.value()))
- m_scripts.remove(id);
+ if (!frame || frame->IsMainFrame()) {
+ for (uint64_t id : std::as_const(it.value()))
+ m_scripts.remove(id);
+ }
m_frameUserScriptMap.remove(frame);
}