diff options
-rw-r--r-- | src/plugins/windows/qwebview2webview.cpp | 149 | ||||
-rw-r--r-- | src/plugins/windows/qwebview2webview_p.h | 4 | ||||
-rw-r--r-- | tests/auto/qml/qquickwebview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/qml/qquickwebview/tst_qquickwebview.cpp | 15 | ||||
-rw-r--r-- | tests/auto/webview/qwebview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/webview/qwebview/tst_qwebview.cpp | 30 |
6 files changed, 104 insertions, 98 deletions
diff --git a/src/plugins/windows/qwebview2webview.cpp b/src/plugins/windows/qwebview2webview.cpp index 255c5ab..027df95 100644 --- a/src/plugins/windows/qwebview2webview.cpp +++ b/src/plugins/windows/qwebview2webview.cpp @@ -61,15 +61,7 @@ bool QWebview2WebViewSettingsPrivate::localStorageEnabled() const bool QWebview2WebViewSettingsPrivate::javaScriptEnabled() const { - if (!m_webview) - return false; - ComPtr<ICoreWebView2Settings> settings; - HRESULT hr = m_webview->get_Settings(&settings); - Q_ASSERT_SUCCEEDED(hr); - BOOL isEnabled; - hr = settings->get_IsScriptEnabled(&isEnabled); - Q_ASSERT_SUCCEEDED(hr); - return isEnabled; + return m_javaScriptEnabled; } bool QWebview2WebViewSettingsPrivate::localContentCanAccessFileUrls() const @@ -90,6 +82,7 @@ void QWebview2WebViewSettingsPrivate::setLocalContentCanAccessFileUrls(bool enab void QWebview2WebViewSettingsPrivate::setJavaScriptEnabled(bool enabled) { + m_javaScriptEnabled = enabled; if (!m_webview) return; @@ -142,24 +135,28 @@ QWebView2WebViewPrivate::QWebView2WebViewPrivate(QObject *parent) connect(m_window, &QWindow::screenChanged, this, &QWebView2WebViewPrivate::updateWindowGeometry, Qt::QueuedConnection); + QPointer<QWebView2WebViewPrivate> thisPtr = this; CreateCoreWebView2EnvironmentWithOptions(nullptr, nullptr, nullptr, Microsoft::WRL::Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>( - [hWnd, this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT { + [hWnd, thisPtr, this](HRESULT result, ICoreWebView2Environment* env) -> HRESULT { env->CreateCoreWebView2Controller(hWnd, Microsoft::WRL::Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>( - [this](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT { + [thisPtr, this](HRESULT result, ICoreWebView2Controller* controller) -> HRESULT { + if (thisPtr.isNull()) + return S_FALSE; + + if (!controller) + return S_FALSE; HRESULT hr; - if (controller != nullptr) { - m_webviewController = controller; - hr = m_webviewController->get_CoreWebView2(&m_webview); - Q_ASSERT_SUCCEEDED(hr); + m_webviewController = controller; + hr = m_webviewController->get_CoreWebView2(&m_webview); + Q_ASSERT_SUCCEEDED(hr); - ComPtr<ICoreWebView2_2> webview2; - HRESULT hr = m_webview->QueryInterface(IID_PPV_ARGS(&webview2)); - Q_ASSERT_SUCCEEDED(hr); - hr = webview2->get_CookieManager(&m_cookieManager); - Q_ASSERT_SUCCEEDED(hr); - } + ComPtr<ICoreWebView2_2> webview2; + hr = m_webview->QueryInterface(IID_PPV_ARGS(&webview2)); + Q_ASSERT_SUCCEEDED(hr); + hr = webview2->get_CookieManager(&m_cookieManager); + Q_ASSERT_SUCCEEDED(hr); m_settings->init(m_webviewController.Get()); @@ -167,7 +164,7 @@ QWebView2WebViewPrivate::QWebView2WebViewPrivate(QObject *parent) ComPtr<ICoreWebView2Settings> settings; hr = m_webview->get_Settings(&settings); Q_ASSERT_SUCCEEDED(hr); - hr = settings->put_IsScriptEnabled(TRUE); + hr = settings->put_IsScriptEnabled(m_settings->javaScriptEnabled()); Q_ASSERT_SUCCEEDED(hr); hr = settings->put_AreDefaultScriptDialogsEnabled(TRUE); Q_ASSERT_SUCCEEDED(hr); @@ -181,16 +178,27 @@ QWebView2WebViewPrivate::QWebView2WebViewPrivate(QObject *parent) if (!m_url.isEmpty() && m_url.isValid() && !m_url.scheme().isEmpty()) { hr = m_webview->Navigate((wchar_t*)m_url.toString().utf16()); Q_ASSERT_SUCCEEDED(hr); - } else if (m_initData != nullptr && !m_initData->m_html.isEmpty()) { - hr = m_webview->NavigateToString((wchar_t*)m_initData->m_html.utf16()); + } else if (!m_initData.m_html.isEmpty()) { + hr = m_webview->NavigateToString((wchar_t*)m_initData.m_html.utf16()); Q_ASSERT_SUCCEEDED(hr); } - if (m_initData != nullptr && m_initData->m_cookies.size() > 0) { - for (auto it = m_initData->m_cookies.constBegin(); - it != m_initData->m_cookies.constEnd(); ++it) + if (m_initData.m_cookies.size() > 0) { + for (auto it = m_initData.m_cookies.constBegin(); + it != m_initData.m_cookies.constEnd(); ++it) setCookie(it->domain, it->name, it.value().value); } - m_initData.release(); + if (!m_initData.m_httpUserAgent.isEmpty()) { + ComPtr<ICoreWebView2Settings2> settings2; + hr = settings->QueryInterface(IID_PPV_ARGS(&settings2)); + if (settings2) { + hr = settings2->put_UserAgent((wchar_t*)m_initData.m_httpUserAgent.utf16()); + if (SUCCEEDED(hr)) + QTimer::singleShot(0, thisPtr, [thisPtr]{ + if (!thisPtr.isNull()) + emit thisPtr->httpUserAgentChanged(thisPtr->m_initData.m_httpUserAgent); + }); + } + } EventRegistrationToken token; hr = m_webview->add_NavigationStarting( @@ -224,10 +232,10 @@ QWebView2WebViewPrivate::QWebView2WebViewPrivate(QObject *parent) }).Get(), &token); Q_ASSERT_SUCCEEDED(hr); - ComPtr<ICoreWebView2_22> webview2; - hr = m_webview->QueryInterface(IID_PPV_ARGS(&webview2)); + ComPtr<ICoreWebView2_22> webview22; + hr = m_webview->QueryInterface(IID_PPV_ARGS(&webview22)); Q_ASSERT_SUCCEEDED(hr); - hr = webview2->AddWebResourceRequestedFilterWithRequestSourceKinds( + hr = webview22->AddWebResourceRequestedFilterWithRequestSourceKinds( L"file://*", COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL, COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL); Q_ASSERT_SUCCEEDED(hr); @@ -241,8 +249,8 @@ QWebView2WebViewPrivate::~QWebView2WebViewPrivate() { m_webViewWindow->destroy(); m_window->destroy(); - m_webviewController = nullptr; m_webViewWindow = nullptr; + m_webviewController = nullptr; m_webview = nullptr; } @@ -263,9 +271,10 @@ QString QWebView2WebViewPrivate::httpUserAgent() const CoTaskMemFree(userAgent); return userAgentString; } + qWarning() << "No http user agent available."; + return ""; } - qWarning() << "No http user agent available."; - return ""; + return m_initData.m_httpUserAgent; } void QWebView2WebViewPrivate::setHttpUserAgent(const QString &userAgent) @@ -279,12 +288,15 @@ void QWebView2WebViewPrivate::setHttpUserAgent(const QString &userAgent) hr = settings->QueryInterface(IID_PPV_ARGS(&settings2)); if (settings2) { hr = settings2->put_UserAgent((wchar_t*)userAgent.utf16()); - Q_ASSERT_SUCCEEDED(hr); - emit httpUserAgentChanged(userAgent); + if (SUCCEEDED(hr)) + emit httpUserAgentChanged(userAgent); return; + } else { + qWarning() << "No http user agent setting available."; } + } else { + m_initData.m_httpUserAgent = userAgent; } - qWarning() << "No http user agent setting available."; } void QWebView2WebViewPrivate::setUrl(const QUrl &url) @@ -293,10 +305,10 @@ void QWebView2WebViewPrivate::setUrl(const QUrl &url) if (m_webview) { HRESULT hr = m_webview->Navigate((wchar_t*)url.toString().utf16()); if (FAILED(hr)) { + emit loadProgressChanged(100); emit loadingChanged(QWebViewLoadRequestPrivate(url, QWebView::LoadFailedStatus, QString())); - emit loadProgressChanged(100); } } } @@ -386,9 +398,7 @@ void QWebView2WebViewPrivate::loadHtml(const QString &html, const QUrl &baseUrl) if (m_webview) { Q_ASSERT_SUCCEEDED(m_webview->NavigateToString((wchar_t*)html.utf16())); } else { - if (m_initData == nullptr) - m_initData = std::make_unique<QWebViewInitData>(); - m_initData->m_html = html; + m_initData.m_html = html; } } @@ -410,56 +420,54 @@ void QWebView2WebViewPrivate::setCookie(const QString &domain, emit cookieAdded(domain, name); } } else { - if (m_initData == nullptr) - m_initData = std::make_unique<QWebViewInitData>(); - m_initData->m_cookies.insert(domain + "/" + name, {domain, name, value}); + m_initData.m_cookies.insert(domain + "/" + name, {domain, name, value}); } } -void QWebView2WebViewPrivate::deleteCookie(const QString &domain, const QString &cookieName) +void QWebView2WebViewPrivate::deleteCookie(const QString &domainName, const QString &cookieName) { if (m_webview) { if (m_cookieManager) { - QString uri = domain; + QString uri = domainName; if (!uri.startsWith("http")) uri = "https://" + uri; HRESULT hr = m_cookieManager->GetCookies((wchar_t*)uri.utf16(), Microsoft::WRL::Callback<ICoreWebView2GetCookiesCompletedHandler>( - [cookieName, domain, this](HRESULT result, ICoreWebView2CookieList* cookieList)->HRESULT + [cookieName, domainName, this] + (HRESULT result, ICoreWebView2CookieList* cookieList)->HRESULT { UINT count = 0; cookieList->get_Count(&count); - bool cookieFound = false; - for (UINT i = 0; i < count; ++i) { ComPtr<ICoreWebView2Cookie> cookie; if (SUCCEEDED(cookieList->GetValueAtIndex(i, &cookie))) { + wchar_t *domainPtr; wchar_t *namePtr; - if (SUCCEEDED(cookie->get_Name(&namePtr))) { + if (SUCCEEDED(cookie->get_Domain(&domainPtr)) && + SUCCEEDED(cookie->get_Name(&namePtr))) { + QString domain(domainPtr); QString name(namePtr); CoTaskMemFree(namePtr); - if (cookieName == name) { - cookieFound = true; - break; + CoTaskMemFree(domainPtr); + if (domainName == domain && cookieName == name) { + emit cookieRemoved(domain, cookieName); + return S_OK; } } } } - - if (cookieFound) { - HRESULT hr = m_cookieManager->DeleteCookiesWithDomainAndPath((wchar_t*)cookieName.utf16(), - (wchar_t*)domain.utf16(), - L""); - Q_ASSERT_SUCCEEDED(hr); - emit cookieRemoved(domain, cookieName); - } - return S_OK; }).Get()); Q_ASSERT_SUCCEEDED(hr); + hr = m_cookieManager->DeleteCookiesWithDomainAndPath((wchar_t*)cookieName.utf16(), + (wchar_t*)domainName.utf16(), + L""); + Q_ASSERT_SUCCEEDED(hr); + + } - } else if (m_initData != nullptr) { - m_initData->m_cookies.remove(domain + "/" + cookieName); + } else { + m_initData.m_cookies.remove(domainName + "/" + cookieName); } } @@ -493,8 +501,8 @@ void QWebView2WebViewPrivate::deleteAllCookies() hr = m_cookieManager->DeleteAllCookies(); Q_ASSERT_SUCCEEDED(hr); } - } else if (m_initData != nullptr) { - m_initData->m_cookies.clear(); + } else { + m_initData.m_cookies.clear(); } } @@ -527,11 +535,11 @@ HRESULT QWebView2WebViewPrivate::onNavigationCompleted(ICoreWebView2* webview, I Q_ASSERT_SUCCEEDED(hr); if (errorStatus != COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED) { const QString errorStr = isSuccess ? "" : WebErrorStatusToString(errorStatus); + emit titleChanged(title()); + emit loadProgressChanged(100); emit loadingChanged(QWebViewLoadRequestPrivate(m_url, status, errorStr)); - emit titleChanged(title()); - emit loadProgressChanged(100); } else { emit loadingChanged(QWebViewLoadRequestPrivate(m_url, QWebView::LoadStoppedStatus, @@ -592,11 +600,10 @@ void QWebView2WebViewPrivate::updateWindowGeometry() void QWebView2WebViewPrivate::runJavaScriptPrivate(const QString &script, int callbackId) { - QEventLoop loop; if (m_webview) Q_ASSERT_SUCCEEDED(m_webview->ExecuteScript((wchar_t*)script.utf16(), Microsoft::WRL::Callback<ICoreWebView2ExecuteScriptCompletedHandler>( - [&loop, this, &callbackId](HRESULT errorCode, LPCWSTR resultObjectAsJson) -> HRESULT { + [this, callbackId](HRESULT errorCode, LPCWSTR resultObjectAsJson) -> HRESULT { QString resultStr = QString::fromWCharArray(resultObjectAsJson); QJsonParseError parseError; @@ -619,10 +626,8 @@ void QWebView2WebViewPrivate::runJavaScriptPrivate(const QString &script, int ca emit javaScriptResult(callbackId, qt_error_string(errorCode)); else emit javaScriptResult(callbackId, resultVariant); - loop.quit(); return errorCode; }).Get())); - loop.exec(); } QAbstractWebViewSettings *QWebView2WebViewPrivate::getSettings() const diff --git a/src/plugins/windows/qwebview2webview_p.h b/src/plugins/windows/qwebview2webview_p.h index 89442b3..653526d 100644 --- a/src/plugins/windows/qwebview2webview_p.h +++ b/src/plugins/windows/qwebview2webview_p.h @@ -40,6 +40,7 @@ private: ComPtr<ICoreWebView2> m_webview; bool m_allowFileAccess = false; bool m_localContentCanAccessFileUrls = false; + bool m_javaScriptEnabled = true; }; // This is used to store informations before webview2 is initialized @@ -52,6 +53,7 @@ struct QWebViewInitData{ QString value; }; QMap<QString, CookieData > m_cookies; + QString m_httpUserAgent; }; class QWebView2WebViewPrivate : public QAbstractWebView @@ -102,7 +104,7 @@ private: QPointer<QWindow> m_webViewWindow; bool m_isLoading; QUrl m_url; - std::unique_ptr<QWebViewInitData> m_initData = nullptr; + QWebViewInitData m_initData; }; QT_END_NAMESPACE diff --git a/tests/auto/qml/qquickwebview/CMakeLists.txt b/tests/auto/qml/qquickwebview/CMakeLists.txt index 6b4ace5..06565d7 100644 --- a/tests/auto/qml/qquickwebview/CMakeLists.txt +++ b/tests/auto/qml/qquickwebview/CMakeLists.txt @@ -48,5 +48,5 @@ qt_internal_add_resource(tst_qquickwebview "testdata1" qt_internal_extend_target(tst_qquickwebview CONDITION TARGET Qt::WebEngineQuick AND NOT APPLE DEFINES - QT_WEBVIEW_WEBENGINE_BACKEND + QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED ) diff --git a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp index 20e0f4b..51dc736 100644 --- a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp +++ b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp @@ -129,13 +129,12 @@ void tst_QQuickWebView::stopEnabledAfterLoadStarted() { QCOMPARE(webView()->isLoading(), false); - LoadStartedCatcher catcher(webView()); + LoadStartedCatcher loadStartedCatcher(webView()); + LoadSpy loadSpy(webView()); webView()->setUrl(getTestFilePath("basic_page.html")); - waitForSignal(&catcher, SIGNAL(finished())); - QCOMPARE(webView()->isLoading(), true); - - QVERIFY(waitForLoadSucceeded(webView())); + waitForSignal(&loadStartedCatcher, SIGNAL(finished())); + waitForSignal(&loadSpy, SIGNAL(loadSucceeded())); } void tst_QQuickWebView::baseUrl() @@ -322,7 +321,7 @@ void tst_QQuickWebView::titleUpdate() // Load page with no title webView()->setUrl(getTestFilePath("basic_page2.html")); QVERIFY(waitForLoadSucceeded(webView())); -#if defined(QT_WEBVIEW_WEBENGINE_BACKEND) || defined(Q_OS_ANDROID) +#if defined(QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED) || defined(Q_OS_ANDROID) || defined(Q_OS_WIN) // on some platforms if the page has no <title> element, then the URL is used instead QCOMPARE(titleSpy.size(), 1); #else @@ -333,7 +332,7 @@ void tst_QQuickWebView::titleUpdate() // No titleChanged signal for failed load webView()->setUrl(getTestFilePath("file_that_does_not_exist.html")); QVERIFY(waitForLoadFailed(webView())); -#if defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) || (!defined(QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED) && defined(Q_OS_WIN)) // error page with "Webpage not available" QTRY_COMPARE(titleSpy.size(), 1); #else @@ -360,7 +359,7 @@ void tst_QQuickWebView::setAndDeleteCookies() QSignalSpy cookieAddedSpy(webView(), SIGNAL(cookieAdded(const QString &, const QString &))); QSignalSpy cookieRemovedSpy(webView(), SIGNAL(cookieRemoved(const QString &, const QString &))); -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED webView()->setUrl(QUrl("qrc:///cookies.html")); QVERIFY(waitForLoadSucceeded(webView())); diff --git a/tests/auto/webview/qwebview/CMakeLists.txt b/tests/auto/webview/qwebview/CMakeLists.txt index 253cee6..ca5f626 100644 --- a/tests/auto/webview/qwebview/CMakeLists.txt +++ b/tests/auto/webview/qwebview/CMakeLists.txt @@ -23,7 +23,7 @@ qt_internal_extend_target(tst_qwebview CONDITION TARGET Qt::WebViewQuick qt_internal_extend_target(tst_qwebview CONDITION TARGET Qt::WebEngineQuick AND NOT APPLE DEFINES - QT_WEBVIEW_WEBENGINE_BACKEND + QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED LIBRARIES Qt::WebEngineQuickPrivate Qt::Qml diff --git a/tests/auto/webview/qwebview/tst_qwebview.cpp b/tests/auto/webview/qwebview/tst_qwebview.cpp index 5b447ca..5db32de 100644 --- a/tests/auto/webview/qwebview/tst_qwebview.cpp +++ b/tests/auto/webview/qwebview/tst_qwebview.cpp @@ -14,9 +14,9 @@ #include <QtWebViewQuick/private/qquickwebview_p.h> #endif // QT_NO_QQUICKWEBVIEW_TESTS -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED #include <QtWebEngineQuick> -#endif // QT_WEBVIEW_WEBENGINE_BACKEND +#endif // QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) #include <QtCore/private/qjnihelpers_p.h> @@ -49,9 +49,9 @@ void tst_QWebView::initTestCase() { if (!qEnvironmentVariableIsEmpty("QEMU_LD_PREFIX")) QSKIP("This test is unstable on QEMU, so it will be skipped."); -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QtWebEngineQuick::initialize(); -#endif // QT_WEBVIEW_WEBENGINE_BACKEND +#endif // QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED if (!QFileInfo(m_cacheLocation).isDir()) { QDir dir; QVERIFY(dir.mkpath(m_cacheLocation)); @@ -68,7 +68,7 @@ void tst_QWebView::load() const QString fileName = file.fileName(); file.close(); -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QQmlEngine engine; QQmlContext *rootContext = engine.rootContext(); QQuickWebView qview; @@ -76,9 +76,9 @@ void tst_QWebView::load() QWebView &view = qview.webView(); #else QWebView view; +#endif view.getSettings()->setAllowFileAccess(true); view.getSettings()->setLocalContentCanAccessFileUrls(true); -#endif QCOMPARE(view.loadProgress(), 0); const QUrl url = QUrl::fromLocalFile(fileName); view.setUrl(url); @@ -93,7 +93,7 @@ void tst_QWebView::load() void tst_QWebView::runJavaScript() { #ifdef QT_QQUICKWEBVIEW_TESTS -#ifndef QT_WEBVIEW_WEBENGINE_BACKEND +#ifndef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED ANDROID_REQUIRES_API_LEVEL(19) #endif const QString tstProperty = QString(QLatin1String("Qt.tst_data")); @@ -120,7 +120,7 @@ void tst_QWebView::runJavaScript() void tst_QWebView::loadHtml() { -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QQmlEngine engine; QQmlContext *rootContext = engine.rootContext(); QQuickWebView qview; @@ -164,7 +164,7 @@ void tst_QWebView::loadRequest() file.write("<html><head><title>FooBar</title></head><body/></html>"); const QString fileName = file.fileName(); file.close(); -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QQmlEngine engine; QQmlContext *rootContext = engine.rootContext(); QQuickWebView qview; @@ -172,9 +172,9 @@ void tst_QWebView::loadRequest() QWebView &view = qview.webView(); #else QWebView view; +#endif view.getSettings()->setAllowFileAccess(true); view.getSettings()->setLocalContentCanAccessFileUrls(true); -#endif QCOMPARE(view.loadProgress(), 0); const QUrl url = QUrl::fromLocalFile(fileName); QSignalSpy loadChangedSingalSpy(&view, SIGNAL(loadingChanged(const QWebViewLoadRequestPrivate &))); @@ -198,7 +198,7 @@ void tst_QWebView::loadRequest() // LoadFailed { -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QQmlEngine engine; QQmlContext *rootContext = engine.rootContext(); QQuickWebView qview; @@ -206,9 +206,9 @@ void tst_QWebView::loadRequest() QWebView &view = qview.webView(); #else QWebView view; +#endif view.getSettings()->setAllowFileAccess(true); view.getSettings()->setLocalContentCanAccessFileUrls(true); -#endif QCOMPARE(view.loadProgress(), 0); QSignalSpy loadChangedSingalSpy(&view, SIGNAL(loadingChanged(const QWebViewLoadRequestPrivate &))); view.setUrl(QUrl(QStringLiteral("file:///file_that_does_not_exist.html"))); @@ -224,7 +224,7 @@ void tst_QWebView::loadRequest() const QWebViewLoadRequestPrivate &lr = loadStartedArgs.at(0).value<QWebViewLoadRequestPrivate>(); QCOMPARE(lr.m_status, QWebView::LoadFailedStatus); } -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QCOMPARE(view.loadProgress(), 0); // darwin plugin returns 100 #endif } @@ -232,7 +232,7 @@ void tst_QWebView::loadRequest() void tst_QWebView::setAndDeleteCookie() { -#ifdef QT_WEBVIEW_WEBENGINE_BACKEND +#ifdef QT_WEBVIEW_WEBENGINE_BACKEND_IS_COMPILED QQmlEngine engine; QQmlContext * rootContext = engine.rootContext(); QQuickWebView qview; @@ -240,10 +240,10 @@ void tst_QWebView::setAndDeleteCookie() QWebView & view = qview.webView(); #else QWebView view; +#endif view.getSettings()->setLocalStorageEnabled(true); view.getSettings()->setAllowFileAccess(true); view.getSettings()->setLocalContentCanAccessFileUrls(true); -#endif QSignalSpy cookieAddedSpy(&view, SIGNAL(cookieAdded(const QString &, const QString &))); QSignalSpy cookieRemovedSpy(&view, SIGNAL(cookieRemoved(const QString &, const QString &))); |