diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2020-02-18 13:21:39 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2020-02-21 09:30:54 +0100 |
commit | 7cc93a0953e5f923699c1945b17706364f0f2160 (patch) | |
tree | 32dc133a50f3459471a2c96fdfb662e56d0c0c60 /tests | |
parent | ecfaca151b4db1fee4f8aa817467b487586e7200 (diff) |
Fix CustomURLLoader not supporting responses over 64k bytes
Mojo data pipes are non-blocking, meaning we have to wait until there's room in
a buffer before we can transfer data from the QIODevice to the pipe.
Use mojo::SimpleWatcher to monitor the pipe for readiness and use the two-phase
BeginWriteData/EndWriteData API to let the QIODevice write directly into the
pipe's internal buffer, avoiding a copy.
Fixes: QTBUG-82244
Change-Id: I65e69ce72d0e99bc047c57b5a22531c0891c553a
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index eed9c071a..1dd8a38c8 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -67,6 +67,7 @@ private Q_SLOTS: void urlSchemeHandlerInstallation(); void urlSchemeHandlerXhrStatus(); void urlSchemeHandlerScriptModule(); + void urlSchemeHandlerLongReply(); void customUserAgent(); void httpAcceptLanguage(); void downloadItem(); @@ -294,7 +295,7 @@ protected: memcpy(data, m_data.constData() + m_bytesRead, len); m_bytesAvailable -= len; m_bytesRead += len; - } else if (m_data.size() > 0) + } else if (atEnd()) return -1; return len; @@ -714,6 +715,31 @@ void tst_QWebEngineProfile::urlSchemeHandlerScriptModule() QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("test")).toString(), QStringLiteral("SUCCESS")); } +class LongReplyUrlSchemeHandler : public QWebEngineUrlSchemeHandler +{ +public: + LongReplyUrlSchemeHandler(QObject *parent = nullptr) : QWebEngineUrlSchemeHandler(parent) {} + ~LongReplyUrlSchemeHandler() {} + + void requestStarted(QWebEngineUrlRequestJob *job) + { + QBuffer *buffer = new QBuffer(job); + buffer->setData(QByteArray(128 * 1024, ' ') + + "<html><head><title>Minify this!</title></head></html>"); + job->reply("text/html", buffer); + } +}; + +void tst_QWebEngineProfile::urlSchemeHandlerLongReply() +{ + LongReplyUrlSchemeHandler handler; + QWebEngineProfile profile; + profile.installUrlSchemeHandler("aviancarrier", &handler); + QWebEnginePage page(&profile); + page.load(QUrl("aviancarrier:/")); + QTRY_COMPARE(page.title(), QString("Minify this!")); +} + void tst_QWebEngineProfile::customUserAgent() { QString defaultUserAgent = QWebEngineProfile::defaultProfile()->httpUserAgent(); |