From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1511783-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id F3B5015ACFB
	for <garchives@archives.gentoo.org>; Wed, 26 Apr 2023 03:54:52 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3245CE0871;
	Wed, 26 Apr 2023 03:54:52 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 040B6E0871
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Apr 2023 03:54:52 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 48236340F96
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Apr 2023 03:54:51 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id D2B7EA45
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Apr 2023 03:54:49 +0000 (UTC)
From: "Ionen Wolkens" <ionen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ionen Wolkens" <ionen@gentoo.org>
Message-ID: <1682481270.9b8f2313546c9a4c1c9dd7a3fc59f77b7147d43d.ionen@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtwebengine/files/, dev-qt/qtwebengine/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-qt/qtwebengine/files/qtwebengine-6.5.0-userscripts-loading.patch dev-qt/qtwebengine/qtwebengine-6.5.0-r1.ebuild dev-qt/qtwebengine/qtwebengine-6.5.0-r2.ebuild
X-VCS-Directories: dev-qt/qtwebengine/ dev-qt/qtwebengine/files/
X-VCS-Committer: ionen
X-VCS-Committer-Name: Ionen Wolkens
X-VCS-Revision: 9b8f2313546c9a4c1c9dd7a3fc59f77b7147d43d
X-VCS-Branch: master
Date: Wed, 26 Apr 2023 03:54:49 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: bf8a0084-cb42-4622-bdd2-c4bdfdd18a31
X-Archives-Hash: 7c8a05aa7f23e3d1f7236c318773467b

commit:     9b8f2313546c9a4c1c9dd7a3fc59f77b7147d43d
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 25 23:38:00 2023 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Wed Apr 26 03:54:30 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9b8f2313

dev-qt/qtwebengine: fix qutebrowser's hinting issue (6.5 regression)

Without this, scripts that qutebrowser (or others) inject may
semi-randomly fail leading to e.g. keyword hints not working, or
users' greasemonkey scripts not being loaded.

qutebrowser has opted to not do messy mitigations (at least for now)
and a fix here makes more sense. Albeit fix was not merged upstream
yet, "hopefully" will make it in 6.5.1 if doesn't miss the window.

Given qtwebengine is not used for much in Gentoo beside qutebrowser
so far, should be worth the revbump/rebuild.

Acked-by: Jimi Huotari <chiitoo <AT> gentoo.org>
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../qtwebengine-6.5.0-userscripts-loading.patch    | 112 +++++++++++++++++++++
 ...6.5.0-r1.ebuild => qtwebengine-6.5.0-r2.ebuild} |   5 +-
 2 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/dev-qt/qtwebengine/files/qtwebengine-6.5.0-userscripts-loading.patch b/dev-qt/qtwebengine/files/qtwebengine-6.5.0-userscripts-loading.patch
new file mode 100644
index 000000000000..6a5802829bb4
--- /dev/null
+++ b/dev-qt/qtwebengine/files/qtwebengine-6.5.0-userscripts-loading.patch
@@ -0,0 +1,112 @@
+https://github.com/qutebrowser/qutebrowser/issues/7662
+https://bugreports.qt.io/browse/QTBUG-113109
+
+https://codereview.qt-project.org/c/qt/qtwebengine/+/474114
+From: Allan Sandfeld Jensen <allan.jensen@qt.io>
+Date: Mon, 24 Apr 2023 17:33:17 +0200
+Subject: [PATCH] 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
+--- a/src/core/renderer/user_resource_controller.cpp
++++ b/src/core/renderer/user_resource_controller.cpp
+@@ -289,10 +289,11 @@
+     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 @@
+ 
+     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 @@
+         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 @@
+     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);
+ }
+--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
++++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+@@ -76,6 +76,7 @@
+     void scriptsInNestedIframes();
+     void matchQrcUrl();
+     void injectionOrder();
++    void reloadWithSubframes();
+ };
+ 
+ void tst_QWebEngineScript::domEditing()
+@@ -694,6 +695,38 @@
+     QTRY_COMPARE(page.log, expected);
+ }
+ 
++void tst_QWebEngineScript::reloadWithSubframes()
++{
++    class Page : public QWebEnginePage
++    {
++    public:
++        Page() : QWebEnginePage() {}
++        QVector<QString> log;
++
++    protected:
++        void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel, const QString &message, int,
++                                      const QString &) override
++        {
++            log.append(message);
++        }
++    } page;
++
++    QWebEngineScript s;
++    s.setInjectionPoint(QWebEngineScript::DocumentCreation);
++    s.setSourceCode(QStringLiteral("console.log('Hello');"));
++    page.scripts().insert(s);
++
++    page.setHtml(QStringLiteral("<body>"
++                                "  <h1>Test scripts working on reload </h1>"
++                                "  <iframe src='about://blank'>"
++                                "  </iframe>"
++                                "</body>"));
++    QTRY_COMPARE(page.log.size(), 1);
++
++    page.triggerAction(QWebEnginePage::Reload);
++    QTRY_COMPARE(page.log.size(), 2);
++}
++
+ QTEST_MAIN(tst_QWebEngineScript)
+ 
+ #include "tst_qwebenginescript.moc"

diff --git a/dev-qt/qtwebengine/qtwebengine-6.5.0-r1.ebuild b/dev-qt/qtwebengine/qtwebengine-6.5.0-r2.ebuild
similarity index 98%
rename from dev-qt/qtwebengine/qtwebengine-6.5.0-r1.ebuild
rename to dev-qt/qtwebengine/qtwebengine-6.5.0-r2.ebuild
index f8bac25f51b1..912effe24979 100644
--- a/dev-qt/qtwebengine/qtwebengine-6.5.0-r1.ebuild
+++ b/dev-qt/qtwebengine/qtwebengine-6.5.0-r2.ebuild
@@ -87,7 +87,10 @@ DEPEND="${RDEPEND}
 	media-libs/libglvnd
 "
 
-PATCHES=( "${FILESDIR}/${PN}-6.5.0-gcc-13-build.patch" )
+PATCHES=(
+	"${FILESDIR}/${PN}-6.5.0-gcc-13-build.patch"
+	"${FILESDIR}/${PN}-6.5.0-userscripts-loading.patch"
+)
 
 python_check_deps() {
 	python_has_version "dev-python/html5lib[${PYTHON_USEDEP}]"