From 89e5a7b1d874dda5b118017bfc6f16eee6a8493b Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Wed, 10 Apr 2019 15:58:15 +0200 Subject: Profile test: fix waiting for load finished signal Change-Id: I797b596b73d62e420592ef9e96601c35ea7ecad6 Reviewed-by: Michal Klocek --- tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 98b4fa6a8..9b396af3f 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -573,14 +573,15 @@ void tst_QWebEngineProfile::initiator() void tst_QWebEngineProfile::qtbug_72299() { QWebEngineView view; + QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool))); view.setUrl(QUrl("https://www.qt.io")); view.show(); - QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool))); view.page()->profile()->clearHttpCache(); view.page()->profile()->setHttpCacheType(QWebEngineProfile::NoCache); view.page()->profile()->cookieStore()->deleteAllCookies(); view.page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies); QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000); + QVERIFY(loadSpy.front().front().toBool()); } -- cgit v1.2.3 From 03b5eb203a18dcd97d6ddf5dd4dfc980eca8200e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 10 Apr 2019 12:30:04 +0200 Subject: Fix resolving relative URLs with custom schemes Pull in 3rdparty patch and add test. Fixes: QTBUG-74864 Change-Id: I5440f58ff55297c2a51f896d43f479404ff6ca2f Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/origins/tst_origins.cpp | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp index 59cbdae13..21afead1d 100644 --- a/tests/auto/widgets/origins/tst_origins.cpp +++ b/tests/auto/widgets/origins/tst_origins.cpp @@ -172,6 +172,7 @@ private Q_SLOTS: void cleanupTestCase(); void jsUrlCanon(); + void jsUrlRelative(); void jsUrlOrigin(); void subdirWithAccess(); void subdirWithoutAccess(); @@ -281,6 +282,54 @@ void tst_Origins::jsUrlCanon() QVariant(QSL("hostportanduserinformationsyntax://a:b@foo/bar"))); } +// Test relative URL resolution. +void tst_Origins::jsUrlRelative() +{ + QVERIFY(load(QSL("about:blank"))); + + // Schemes with hosts, like http, work as expected. + QCOMPARE(eval(QSL("new URL('bar', 'http://foo').href")), QVariant(QSL("http://foo/bar"))); + QCOMPARE(eval(QSL("new URL('baz', 'http://foo/bar').href")), QVariant(QSL("http://foo/baz"))); + QCOMPARE(eval(QSL("new URL('baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/bar/baz"))); + QCOMPARE(eval(QSL("new URL('/baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz"))); + QCOMPARE(eval(QSL("new URL('./baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/bar/baz"))); + QCOMPARE(eval(QSL("new URL('../baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz"))); + QCOMPARE(eval(QSL("new URL('../../baz', 'http://foo/bar/').href")), QVariant(QSL("http://foo/baz"))); + QCOMPARE(eval(QSL("new URL('//baz', 'http://foo/bar/').href")), QVariant(QSL("http://baz/"))); + + // In the case of schemes without hosts, relative URLs only work if the URL + // starts with a single slash -- and canonicalization does not guarantee + // this. The following cases all fail with TypeErrors. + QCOMPARE(eval(QSL("new URL('bar', 'tst:foo').href")), QVariant()); + QCOMPARE(eval(QSL("new URL('baz', 'tst:foo/bar').href")), QVariant()); + QCOMPARE(eval(QSL("new URL('bar', 'tst://foo').href")), QVariant()); + QCOMPARE(eval(QSL("new URL('bar', 'tst:///foo').href")), QVariant()); + + // However, registered custom schemes have been patched to allow relative + // URLs even without an initial slash. + QCOMPARE(eval(QSL("new URL('bar', 'qrc:foo').href")), QVariant(QSL("qrc:bar"))); + QCOMPARE(eval(QSL("new URL('baz', 'qrc:foo/bar').href")), QVariant(QSL("qrc:foo/baz"))); + QCOMPARE(eval(QSL("new URL('bar', 'qrc://foo').href")), QVariant()); + QCOMPARE(eval(QSL("new URL('bar', 'qrc:///foo').href")), QVariant()); + + // With a slash it works the same as http except 'foo' is part of the path and not the host. + QCOMPARE(eval(QSL("new URL('bar', 'qrc:/foo').href")), QVariant(QSL("qrc:/bar"))); + QCOMPARE(eval(QSL("new URL('bar', 'qrc:/foo/').href")), QVariant(QSL("qrc:/foo/bar"))); + QCOMPARE(eval(QSL("new URL('baz', 'qrc:/foo/bar').href")), QVariant(QSL("qrc:/foo/baz"))); + QCOMPARE(eval(QSL("new URL('baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/bar/baz"))); + QCOMPARE(eval(QSL("new URL('/baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz"))); + QCOMPARE(eval(QSL("new URL('./baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/bar/baz"))); + QCOMPARE(eval(QSL("new URL('../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/foo/baz"))); + QCOMPARE(eval(QSL("new URL('../../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz"))); + QCOMPARE(eval(QSL("new URL('../../../baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc:/baz"))); + + // If the relative URL begins with >= 2 slashes, then the scheme is treated + // not as a Syntax::Path scheme but as a Syntax::HostPortAndUserInformation + // scheme. + QCOMPARE(eval(QSL("new URL('//baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc://baz/"))); + QCOMPARE(eval(QSL("new URL('///baz', 'qrc:/foo/bar/').href")), QVariant(QSL("qrc://baz/"))); +} + // Test origin serialization in Blink, implemented by blink::KURL and // blink::SecurityOrigin as opposed to GURL and url::Origin. void tst_Origins::jsUrlOrigin() -- cgit v1.2.3 From 96fb3a30457c8925431b67c0f35abb2833b7fb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 12 Apr 2019 11:33:16 +0200 Subject: Fix QWebEngineView::setPage not deleting old page Also fix QWebEnginePage::setView not deleting old page Also fix wrong page being deleted if it's parented to the view. Fixes: QTBUG-75131 Fixes: QTBUG-75175 Change-Id: Ie4dfb15b3182de7aa3a94cddcac54ea40a86121b Reviewed-by: Allan Sandfeld Jensen --- .../widgets/qwebengineview/tst_qwebengineview.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 5f05f70ab..6ab63b54e 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -195,6 +195,10 @@ private Q_SLOTS: void deletePage(); void closeOpenerTab(); void switchPage(); + void setPageDeletesImplicitPage(); + void setViewDeletesImplicitPage(); + void setPagePreservesExplicitPage(); + void setViewPreservesExplicitPage(); }; // This will be called before the first test function is executed. @@ -3196,5 +3200,47 @@ void tst_QWebEngineView::switchPage() QTRY_COMPARE(webView.grab().toImage().pixelColor(QPoint(150,150)), Qt::black); } +void tst_QWebEngineView::setPageDeletesImplicitPage() +{ + QWebEngineView view; + QPointer implicitPage = view.page(); + QWebEnginePage explicitPage; + view.setPage(&explicitPage); + QCOMPARE(view.page(), &explicitPage); + QVERIFY(!implicitPage); // should be deleted +} + +void tst_QWebEngineView::setViewDeletesImplicitPage() +{ + QWebEngineView view; + QPointer implicitPage = view.page(); + QWebEnginePage explicitPage; + explicitPage.setView(&view); + QCOMPARE(view.page(), &explicitPage); + QVERIFY(!implicitPage); // should be deleted +} + +void tst_QWebEngineView::setPagePreservesExplicitPage() +{ + QWebEngineView view; + QPointer explicitPage1 = new QWebEnginePage(&view); + QPointer explicitPage2 = new QWebEnginePage(&view); + view.setPage(explicitPage1.data()); + view.setPage(explicitPage2.data()); + QCOMPARE(view.page(), explicitPage2.data()); + QVERIFY(explicitPage1); // should not be deleted +} + +void tst_QWebEngineView::setViewPreservesExplicitPage() +{ + QWebEngineView view; + QPointer explicitPage1 = new QWebEnginePage(&view); + QPointer explicitPage2 = new QWebEnginePage(&view); + explicitPage1->setView(&view); + explicitPage2->setView(&view); + QCOMPARE(view.page(), explicitPage2.data()); + QVERIFY(explicitPage1); // should not be deleted +} + QTEST_MAIN(tst_QWebEngineView) #include "tst_qwebengineview.moc" -- cgit v1.2.3 From 73a0749fdae3afe3f42606895ac7c133b6f14425 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Tue, 23 Apr 2019 11:23:45 +0200 Subject: Profile test: fix buffer for request job being deleted on main thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I894946ce7c9dcf4f787c5c928e3737cd80a7dc52 Reviewed-by: Jüri Valdmann --- tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 9b396af3f..d9505cbfd 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -211,9 +211,8 @@ public: void requestStarted(QWebEngineUrlRequestJob *job) { - QBuffer *buffer = new QBuffer; + QBuffer *buffer = new QBuffer(job); buffer->setData(job->requestUrl().toString().toUtf8()); - connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater); m_buffers.append(buffer); job->reply("text/plain;charset=utf-8", buffer); } -- cgit v1.2.3