summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-13 11:13:28 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-15 11:14:15 +0200
commit423b399a3336ed5832ac12fe0bb9c4c3eebc1c82 (patch)
tree5b4abc470dbeec3948cfe18bff91f48b06b9937f /tests
parenteb7e970eb03dfcc73c39544f4eca3a72782f4a08 (diff)
Fix uncalled callbacks with findText
Calling findText successively might prevent the previous pending FindReply to be sent, which would leak the callback on the application side. This would cause a crash in qupzilla since we empty all pending callbacks in the QWebEnginePage's destructor to catch this kind of issue. This also renames lastRequestId to nextRequestId to make it clear that this is the ID generator for everything, including findText, and that lastFindRequestId is only a tracker. Change-Id: Ia78d553a58ed31af7237aad8772fa9828560c6d4 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index ca374071..70fbba12 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -175,6 +175,7 @@ private Q_SLOTS:
void testStopScheduledPageRefresh();
void findText();
void findTextResult();
+ void findTextSuccessiveShouldCallAllCallbacks();
void supportedContentType();
// [Qt] tst_QWebEnginePage::infiniteLoopJS() timeouts with DFG JIT
// https://bugs.webkit.org/show_bug.cgi?id=79040
@@ -3254,6 +3255,29 @@ void tst_QWebEnginePage::findTextResult()
QCOMPARE(findTextSync(m_page, ""), false);
}
+void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
+{
+ CallbackSpy<bool> spy1;
+ CallbackSpy<bool> spy2;
+ CallbackSpy<bool> spy3;
+ CallbackSpy<bool> spy4;
+ CallbackSpy<bool> spy5;
+ QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
+ m_view->setHtml(QString("<html><head></head><body><div>abcdefg abcdefg abcdefg abcdefg abcdefg</div></body></html>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ m_page->findText("abcde", 0, spy1.ref());
+ m_page->findText("abcd", 0, spy2.ref());
+ m_page->findText("abc", 0, spy3.ref());
+ m_page->findText("ab", 0, spy4.ref());
+ m_page->findText("a", 0, spy5.ref());
+ spy5.waitForResult();
+ QVERIFY(spy1.wasCalled());
+ QVERIFY(spy2.wasCalled());
+ QVERIFY(spy3.wasCalled());
+ QVERIFY(spy4.wasCalled());
+ QVERIFY(spy5.wasCalled());
+}
+
static QString getMimeTypeForExtension(const QString &ext)
{
QMimeType mimeType = QMimeDatabase().mimeTypeForFile(QStringLiteral("filename.") + ext.toLower(), QMimeDatabase::MatchExtension);