From f2d938962fe9a029ec0baf37ca7f478051125780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 14 Aug 2017 10:25:56 +0200 Subject: Fix QWebEngineDownloadItem::type() Task-number: QTBUG-62640 Change-Id: I2b16f24533b38c20a7071319723382ba240e35f3 Reviewed-by: Peter Varga --- .../auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index c25e82d41..aba5bdeb1 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -86,7 +86,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // SaveLink should always trigger a download, also for text files. QTest::newRow("save link to text file") @@ -99,7 +99,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... adding the "download" attribute should have no effect. QTest::newRow("save link to text file (attribute)") @@ -112,7 +112,7 @@ void tst_QWebEngineDownloads::downloadLink_data() /* fileDisposition */ << QByteArrayLiteral("") /* fileHasReferer */ << true /* fileAction */ << FileIsDownloaded - /* downloadType */ << QWebEngineDownloadItem::DownloadAttribute; + /* downloadType */ << QWebEngineDownloadItem::UserRequested; // ... adding the "attachment" content disposition should also have no effect. QTest::newRow("save link to text file (attachment)") @@ -508,7 +508,7 @@ void tst_QWebEngineDownloads::downloadTwoLinks() QCOMPARE(item->totalBytes(), -1); QCOMPARE(item->receivedBytes(), 0); QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason); - QCOMPARE(item->type(), QWebEngineDownloadItem::DownloadAttribute); + QCOMPARE(item->type(), QWebEngineDownloadItem::Attachment); QCOMPARE(item->mimeType(), QStringLiteral("text/plain")); QCOMPARE(item->path(), standardDir + QByteArrayLiteral("/file2")); QCOMPARE(item->savePageFormat(), QWebEngineDownloadItem::UnknownSaveFormat); -- cgit v1.2.3 From 14b58276822c12e8d21580f61869b5a9bbf43f22 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Thu, 14 Dec 2017 12:37:28 +0100 Subject: Deselect text on each fourth click Triple click selects the entire paragraph and it should be deselected on a quadra click. Task-number: QTBUG-65649 Change-Id: I87c9405a202d8b6eacd7c19dbbcb051756c41220 Reviewed-by: Viktor Engelmann Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/data/tst_mouseClick.qml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/tst_mouseClick.qml b/tests/auto/quick/qmltests/data/tst_mouseClick.qml index bd6625a90..d81e690fd 100644 --- a/tests/auto/quick/qmltests/data/tst_mouseClick.qml +++ b/tests/auto/quick/qmltests/data/tst_mouseClick.qml @@ -57,6 +57,10 @@ TestWebEngineView { function mouseTripleClick(item, x, y) { mouseMultiClick(item, x, y, 3); } + + function mouseQuadraClick(item, x, y) { + mouseMultiClick(item, x, y, 4); + } } @@ -109,5 +113,18 @@ TestWebEngineView { mouseClick(webEngineView, center.x, center.y); tryVerify(function() { return getTextSelection() == "" }); } + + function test_quadraClick() { + webEngineView.settings.focusOnNavigationEnabled = true; + webEngineView.loadHtml("" + + "
" + + ""); + verify(webEngineView.waitForLoadSucceeded()); + + var center = getElementCenter("input"); + webEngineView.testSupport.mouseQuadraClick(webEngineView, center.x, center.y); + verifyElementHasFocus("input"); + tryVerify(function() { return getTextSelection() == "" }); + } } } -- cgit v1.2.3 From 3d53f2a26676d0c3f5e306f8b0f7d7ed413fc7cb Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 22 Jan 2018 16:22:02 +0100 Subject: Remove full blacklist of osx 10.11 It was added for a single test failure that was caused by a screen locker on the CI, a problem that has since been solved. This CI configuration is the only one that's running qmltests on osx. Change-Id: Ia6f11649ce2f63000488aa18080c5d149d04eac0 Reviewed-by: Alexandru Croitor --- tests/auto/quick/qmltests/BLACKLIST | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index f449f4949..f2ab9788d 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -1,4 +1,3 @@ -osx-10.11 ci [WebViewGeopermission::test_deniedGeolocationByUser] osx -- cgit v1.2.3 From dabc1069d6c39bd8342b446361226b63bd571cf9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jan 2018 17:09:03 +0100 Subject: Re-enable setUrltoEmpty and setUrlHistory tests Have been skipped for years but appears to work. Change-Id: I461459b64fe3731b2fb50a3cc9c9d4ab75b135d4 Reviewed-by: Alexandru Croitor --- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 54cf27066..060645733 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -3750,8 +3750,6 @@ void tst_QWebEnginePage::setUrlWithPendingLoads() void tst_QWebEnginePage::setUrlToEmpty() { - QSKIP("FIXME: [0908/090526:FATAL:navigation_controller_impl.cc(927)] Check failed: active_entry->site_instance() == rfh->GetSiteInstance()."); - int expectedLoadFinishedCount = 0; const QUrl aboutBlank("about:blank"); const QUrl url("qrc:/resources/test2.html"); @@ -3759,7 +3757,8 @@ void tst_QWebEnginePage::setUrlToEmpty() QWebEnginePage page; QCOMPARE(page.url(), QUrl()); QCOMPARE(page.requestedUrl(), QUrl()); - QCOMPARE(baseUrlSync(&page), QUrl()); +// Chromium now returns about:blank as the base url here: +// QCOMPARE(baseUrlSync(&page), QUrl()); QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); @@ -3926,8 +3925,6 @@ static QStringList collectHistoryUrls(QWebEngineHistory *history) void tst_QWebEnginePage::setUrlHistory() { - QSKIP("FIXME: [0908/090526:FATAL:navigation_controller_impl.cc(927)] Check failed: active_entry->site_instance() == rfh->GetSiteInstance()."); - const QUrl aboutBlank("about:blank"); QUrl url; int expectedLoadFinishedCount = 0; @@ -3943,10 +3940,10 @@ void tst_QWebEnginePage::setUrlHistory() // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); - url = QUrl("http://non.existent/"); + url = QUrl("http://url.invalid/"); m_page->setUrl(url); expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), expectedLoadFinishedCount, 20000); // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored. // We expect the url of the previously loaded page here. QCOMPARE(m_page->url(), aboutBlank); -- cgit v1.2.3 From 72103a55b1ac514fa0acbb9131610b26ee87d083 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jan 2018 16:23:40 +0100 Subject: Remove dead tests we will not be reusing We have no plans of implement QtWebKit still plugins. Change-Id: I9f7bb94cc240e2f0eda8c85c03fa5860435d52a3 Reviewed-by: Peter Varga --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 360 --------------------- 1 file changed, 360 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 060645733..abebec03f 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -104,20 +104,12 @@ private Q_SLOTS: void modified(); void contextMenuCrash(); void updatePositionDependentActionsCrash(); - void createPluginWithPluginsEnabled(); - void createPluginWithPluginsDisabled(); void callbackSpyDeleted(); - void destroyPlugin_data(); - void destroyPlugin(); - void createViewlessPlugin_data(); - void createViewlessPlugin(); - void graphicsWidgetPlugin(); void multiplePageGroupsAndLocalStorage(); void cursorMovements(); void textSelection(); void textEditing(); void backActionUpdate(); - void protectBindingsRuntimeObjectsFromCollector(); void testOptionalJSObjects(); void testLocalStorageVisibility(); void testEnablePersistentStorage(); @@ -817,332 +809,6 @@ void tst_QWebEnginePage::contextMenuCrash() #endif } -#if defined(QWEBENGINEPAGE_CREATEPLUGIN) -class PluginPage : public QWebEnginePage -{ -public: - PluginPage(QObject *parent = 0) - : QWebEnginePage(parent) {} - - struct CallInfo - { - CallInfo(const QString &c, const QUrl &u, - const QStringList &pn, const QStringList &pv, - QObject *r) - : classid(c), url(u), paramNames(pn), - paramValues(pv), returnValue(r) - {} - QString classid; - QUrl url; - QStringList paramNames; - QStringList paramValues; - QObject *returnValue; - }; - - QList calls; - -protected: - virtual QObject *createPlugin(const QString &classid, const QUrl &url, - const QStringList ¶mNames, - const QStringList ¶mValues) - { - QObject *result = 0; - if (classid == "pushbutton") - result = new QPushButton(); -#ifndef QT_NO_INPUTDIALOG - else if (classid == "lineedit") - result = new QLineEdit(); -#endif - else if (classid == "graphicswidget") - result = new QGraphicsWidget(); - if (result) - result->setObjectName(classid); - calls.append(CallInfo(classid, url, paramNames, paramValues, result)); - return result; - } -}; - -static void createPlugin(QWebEngineView *view) -{ - QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(view); - view->setPage(newPage); - - // type has to be application/x-qt-plugin - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } - // test JS bindings - QCOMPARE(evaluateJavaScriptSync(newPage, "document.getElementById('mybutton').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mybutton.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(evaluateJavaScriptSync(newPage, "typeof mybutton.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mybutton.objectName").toString(), - QString::fromLatin1("pushbutton")); - QCOMPARE(evaluateJavaScriptSync(newPage, "typeof mybutton.clicked").toString(), - QString::fromLatin1("function")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mybutton.clicked.toString()").toString(), - QString::fromLatin1("function clicked() {\n [native code]\n}")); - - view->setHtml(QString("" - "" - "" - "
"), QUrl("http://foo.bar.baz")); - QTRY_COMPARE(loadSpy.count(), 3); - QCOMPARE(newPage->calls.count(), 2); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("lineedit")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("lineedit")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("myedit")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QLineEdit")); - } - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("pushbutton")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("pushbutton")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mybutton")); - QVERIFY(ci.returnValue != 0); - QVERIFY(ci.returnValue->inherits("QPushButton")); - } -} -#endif - -void tst_QWebEnginePage::graphicsWidgetPlugin() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - m_view->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); - QGraphicsWebView webView; - - QSignalSpy loadSpy(&webView, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(&webView); - webView.setPage(newPage); - - // type has to be application/x-qt-plugin - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(newPage->calls.count(), 0); - - webView.setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 1); - { - PluginPage::CallInfo ci = newPage->calls.takeFirst(); - QCOMPARE(ci.classid, QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.url, QUrl()); - QCOMPARE(ci.paramNames.count(), 3); - QCOMPARE(ci.paramValues.count(), 3); - QCOMPARE(ci.paramNames.at(0), QString::fromLatin1("type")); - QCOMPARE(ci.paramValues.at(0), QString::fromLatin1("application/x-qt-plugin")); - QCOMPARE(ci.paramNames.at(1), QString::fromLatin1("classid")); - QCOMPARE(ci.paramValues.at(1), QString::fromLatin1("graphicswidget")); - QCOMPARE(ci.paramNames.at(2), QString::fromLatin1("id")); - QCOMPARE(ci.paramValues.at(2), QString::fromLatin1("mygraphicswidget")); - QVERIFY(ci.returnValue); - QVERIFY(ci.returnValue->inherits("QGraphicsWidget")); - } - // test JS bindings - QCOMPARE(evaluateJavaScriptSync(newPage, "document.getElementById('mygraphicswidget').toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mygraphicswidget.toString()").toString(), - QString::fromLatin1("[object HTMLObjectElement]")); - QCOMPARE(evaluateJavaScriptSync(newPage, "typeof mygraphicswidget.objectName").toString(), - QString::fromLatin1("string")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mygraphicswidget.objectName").toString(), - QString::fromLatin1("graphicswidget")); - QCOMPARE(evaluateJavaScriptSync(newPage, "typeof mygraphicswidget.geometryChanged").toString(), - QString::fromLatin1("function")); - QCOMPARE(evaluateJavaScriptSync(newPage, "mygraphicswidget.geometryChanged.toString()").toString(), - QString::fromLatin1("function geometryChanged() {\n [native code]\n}")); -#endif -} - -void tst_QWebEnginePage::createPluginWithPluginsEnabled() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - m_view->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); - createPlugin(m_view); -#endif -} - -void tst_QWebEnginePage::createPluginWithPluginsDisabled() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - // Qt Plugins should be loaded by QtWebEngine even when PluginsEnabled is - // false. The client decides whether a Qt plugin is enabled or not when - // it decides whether or not to instantiate it. - m_view->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false); - createPlugin(m_view); -#endif -} - -#if defined(QWEBENGINEPAGE_CREATEPLUGIN) -// Standard base class for template PluginTracerPage. In tests it is used as interface. -class PluginCounterPage : public QWebEnginePage { -public: - int m_count; - QPointer m_widget; - QObject* m_pluginParent; - PluginCounterPage(QObject* parent = 0) - : QWebEnginePage(parent) - , m_count(0) - , m_pluginParent(0) - { - settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); - } - ~PluginCounterPage() - { - if (m_pluginParent) - m_pluginParent->deleteLater(); - } -}; - -template -class PluginTracerPage : public PluginCounterPage { -public: - PluginTracerPage(QObject* parent = 0) - : PluginCounterPage(parent) - { - // this is a dummy parent object for the created plugin - m_pluginParent = new T; - } - virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) - { - m_count++; - m_widget = new T; - // need a cast to the specific type, as QObject::setParent cannot be called, - // because it is not virtual. Instead it is necessary to call QWidget::setParent, - // which also takes a QWidget* instead of a QObject*. Therefore we need to - // upcast to T*, which is a QWidget. - static_cast(m_widget.data())->setParent(static_cast(m_pluginParent)); - return m_widget.data(); - } -}; - -class PluginFactory { -public: - enum FactoredType {QWidgetType, QGraphicsWidgetType}; - static PluginCounterPage* create(FactoredType type, QObject* parent = 0) - { - PluginCounterPage* result = 0; - switch (type) { - case QWidgetType: - result = new PluginTracerPage(parent); - break; - case QGraphicsWidgetType: - result = new PluginTracerPage(parent); - break; - default: {/*Oops*/}; - } - return result; - } - - static void prepareTestData() - { - QTest::addColumn("type"); - QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType; - QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType; - } -}; -#endif - -void tst_QWebEnginePage::destroyPlugin_data() -{ -#if defined(QWEBENGINEPAGE_CREATEPLUGIN) - PluginFactory::prepareTestData(); -#endif -} - -void tst_QWebEnginePage::destroyPlugin() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view); - m_view->setPage(page); - - // we create the plugin, so the widget should be constructed - QString content(""); - m_view->setHtml(content); - QVERIFY(page->m_widget); - QCOMPARE(page->m_count, 1); - - // navigate away, the plugin widget should be destructed - m_view->setHtml("Hi"); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!page->m_widget); -#endif -} - -void tst_QWebEnginePage::createViewlessPlugin_data() -{ -#if defined(QWEBENGINEPAGE_CREATEPLUGIN) - PluginFactory::prepareTestData(); -#endif -} - -void tst_QWebEnginePage::createViewlessPlugin() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - QFETCH(int, type); - PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type); - QString content(""); - page->setHtml(content); - QCOMPARE(page->m_count, 1); - QVERIFY(page->m_widget); - QVERIFY(page->m_pluginParent); - QVERIFY(page->m_widget.data()->parent() == page->m_pluginParent); - delete page; -#endif -} - void tst_QWebEnginePage::multiplePageGroupsAndLocalStorage() { #if !defined(QWEBENGINESETTINGS_SETLOCALSTORAGEPATH) @@ -1660,32 +1326,6 @@ void tst_QWebEnginePage::backActionUpdate() QVERIFY(action->isEnabled()); } -void tst_QWebEnginePage::protectBindingsRuntimeObjectsFromCollector() -{ -#if !defined(QWEBENGINEPAGE_CREATEPLUGIN) - QSKIP("QWEBENGINEPAGE_CREATEPLUGIN"); -#else - QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); - - PluginPage* newPage = new PluginPage(m_view); - m_view->setPage(newPage); - - m_view->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); - - m_view->setHtml(QString("")); - QTRY_COMPARE(loadSpy.count(), 1); - - newPage->runJavaScript("function testme(text) { var lineedit = document.getElementById('mylineedit'); lineedit.setText(text); lineedit.selectAll(); }"); - - evaluateJavaScriptSync(newPage, "testme('foo')"); - - DumpRenderTreeSupportQt::garbageCollectorCollect(); - - // don't crash! - evaluateJavaScriptSync(newPage, "testme('bar')"); -#endif -} - #if defined(QWEBENGINEPAGE_SETTINGS) static inline bool testFlag(QWebEnginePage& webPage, QWebEngineSettings::WebAttribute settingAttribute, const QString& jsObjectName, bool settingValue) { -- cgit v1.2.3 From 3387809ba9e159f5179e3df5b9408bc34966cd4a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jan 2018 16:24:55 +0100 Subject: Remove test relying on WebKit internals This test makes little sense for QtWebEngine Change-Id: I0177fb59ea23383a3c8135853f7e62b26ce5708a Reviewed-by: Peter Varga --- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index abebec03f..279ce3902 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -100,7 +100,6 @@ private Q_SLOTS: void userStyleSheet(); void userStyleSheetFromLocalFileUrl(); void userStyleSheetFromQrcUrl(); - void loadHtml5Video(); void modified(); void contextMenuCrash(); void updatePositionDependentActionsCrash(); @@ -689,20 +688,6 @@ void tst_QWebEnginePage::userStyleSheetFromQrcUrl() #endif } -void tst_QWebEnginePage::loadHtml5Video() -{ -#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA - QByteArray url("http://does.not/exist?a=1%2Cb=2"); - m_view->setHtml("

"); - QTest::qWait(2000); - QUrl mUrl = DumpRenderTreeSupportQt::mediaContentUrlByElementId(m_page->mainFrame()->handle(), "video"); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=65452", Continue); - QCOMPARE(mUrl.toEncoded(), url); -#else - W_QSKIP("This test requires Qt Multimedia", SkipAll); -#endif -} - void tst_QWebEnginePage::modified() { #if !defined(QWEBENGINEPAGE_ISMODIFIED) -- cgit v1.2.3 From 7911a4f0480e3e5371515f211601b69606e32d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 13 Nov 2017 12:49:02 +0100 Subject: Fix thread synchronization issue in tst_qwebengineprofile Change-Id: I7b7c4a6501387b1d657e55f222908365990b8fef Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 6961f3b6d..c443ee114 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -200,9 +200,13 @@ public: } bool isSequential() const override { return true; } qint64 bytesAvailable() const override - { return m_bytesAvailable; } + { + QMutexLocker lock(&m_mutex); + return m_bytesAvailable; + } bool atEnd() const override { + QMutexLocker lock(&m_mutex); return (m_data.size() >= 1000 && m_bytesRead >= 1000); } protected: @@ -237,7 +241,7 @@ protected: } private: - QMutex m_mutex; + mutable QMutex m_mutex{QMutex::Recursive}; QByteArray m_data; QBasicTimer m_timer; int m_bytesRead; -- cgit v1.2.3 From 156024d840dee530def5c8ebe788978548b87c7d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Jan 2018 16:30:30 +0100 Subject: Rewrite and activate multiplePageGroupsAndLocalStorage Convert it to QtWebEngine. Change-Id: I7a453cd7544a20a9c461c3bb29b3a2fb78016d44 Reviewed-by: Joerg Bornemann --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 81 +++++++++++----------- 1 file changed, 39 insertions(+), 42 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 279ce3902..098ac11e8 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -104,7 +104,7 @@ private Q_SLOTS: void contextMenuCrash(); void updatePositionDependentActionsCrash(); void callbackSpyDeleted(); - void multiplePageGroupsAndLocalStorage(); + void multipleProfilesAndLocalStorage(); void cursorMovements(); void textSelection(); void textEditing(); @@ -794,50 +794,47 @@ void tst_QWebEnginePage::contextMenuCrash() #endif } -void tst_QWebEnginePage::multiplePageGroupsAndLocalStorage() +void tst_QWebEnginePage::multipleProfilesAndLocalStorage() { -#if !defined(QWEBENGINESETTINGS_SETLOCALSTORAGEPATH) - QSKIP("QWEBENGINESETTINGS_SETLOCALSTORAGEPATH"); -#else QDir dir(tmpDirPath()); - dir.mkdir("path1"); - dir.mkdir("path2"); - - QWebEngineView view1; - QWebEngineView view2; - - view1.page()->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true); - view1.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1")); - DumpRenderTreeSupportQt::webPageSetGroupName(view1.page()->handle(), "group1"); - view2.page()->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true); - view2.page()->settings()->setLocalStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2")); - DumpRenderTreeSupportQt::webPageSetGroupName(view2.page()->handle(), "group2"); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view1.page()->handle()), QString("group1")); - QCOMPARE(DumpRenderTreeSupportQt::webPageGroupName(view2.page()->handle()), QString("group2")); - - - view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); - view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); - - evaluateJavaScriptSync(view1.page(), "localStorage.test='value1';"); - evaluateJavaScriptSync(view2.page(), "localStorage.test='value2';"); - - view1.setHtml(QString(" "), QUrl("http://www.myexample.com")); - view2.setHtml(QString(" "), QUrl("http://www.myexample.com")); - - QVariant s1 = evaluateJavaScriptSync(view1.page(), "localStorage.test"); - QCOMPARE(s1.toString(), QString("value1")); - - QVariant s2 = evaluateJavaScriptSync(view2.page(), "localStorage.test"); - QCOMPARE(s2.toString(), QString("value2")); - + bool success = dir.mkpath("path1"); + success = success && dir.mkdir("path2"); + QVERIFY(success); + { + QWebEngineProfile profile1("test1"); + QWebEngineProfile profile2("test2"); + profile1.settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true); + profile2.settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true); + profile1.setPersistentStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path1")); + profile2.setPersistentStoragePath(QDir::toNativeSeparators(tmpDirPath() + "/path2")); + + QWebEnginePage page1(&profile1, nullptr); + QWebEnginePage page2(&profile2, nullptr); + QSignalSpy loadSpy1(&page1, SIGNAL(loadFinished(bool))); + QSignalSpy loadSpy2(&page2, SIGNAL(loadFinished(bool))); + + page1.setHtml(QString(" "), QUrl("http://wwww.example.com")); + page2.setHtml(QString(" "), QUrl("http://wwww.example.com")); + QTRY_COMPARE(loadSpy1.count(), 1); + QTRY_COMPARE(loadSpy2.count(), 1); + + evaluateJavaScriptSync(&page1, "localStorage.setItem('test', 'value1');"); + evaluateJavaScriptSync(&page2, "localStorage.setItem('test', 'value2');"); + + page1.setHtml(QString(" "), QUrl("http://wwww.example.com")); + page2.setHtml(QString(" "), QUrl("http://wwww.example.com")); + QTRY_COMPARE(loadSpy1.count(), 2); + QTRY_COMPARE(loadSpy2.count(), 2); + + QVariant s1 = evaluateJavaScriptSync(&page1, "localStorage.getItem('test')"); + QCOMPARE(s1.toString(), QString("value1")); + QVariant s2 = evaluateJavaScriptSync(&page2, "localStorage.getItem('test')"); + QCOMPARE(s2.toString(), QString("value2")); + } + // Avoid deleting on-disk dbs before the underlying browser-context has been asynchronously deleted QTest::qWait(1000); - - QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path1/http_www.myexample.com_0.localstorage")); - QFile::remove(QDir::toNativeSeparators(tmpDirPath() + "/path2/http_www.myexample.com_0.localstorage")); - dir.rmdir(QDir::toNativeSeparators("./path1")); - dir.rmdir(QDir::toNativeSeparators("./path2")); -#endif + QDir(tmpDirPath() + "/path1").removeRecursively(); + QDir(tmpDirPath() + "/path2").removeRecursively(); } class CursorTrackedPage : public QWebEnginePage -- cgit v1.2.3