diff options
22 files changed, 223 insertions, 94 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 1a0f3a263..3dac9b0b7 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,27 +1,5 @@ TEMPLATE=subdirs -qtHaveModule(webengine) { - SUBDIRS += \ - webengine/customdialogs \ - webengine/minimal \ - webengine/quicknanobrowser -} +qtHaveModule(webengine): SUBDIRS += webengine -qtHaveModule(webenginewidgets) { - SUBDIRS += \ - webenginewidgets/minimal \ - webenginewidgets/contentmanipulation \ - webenginewidgets/cookiebrowser \ - webenginewidgets/demobrowser \ - webenginewidgets/markdowneditor \ - webenginewidgets/simplebrowser - - contains(WEBENGINE_CONFIG, use_spellchecker):!cross_compile { - !contains(WEBENGINE_CONFIG, use_native_spellchecker) { - SUBDIRS += webenginewidgets/spellchecker - } else { - message("Spellcheck example will not be built because it depends on usage of Hunspell dictionaries.") - } - } - -} +qtHaveModule(webenginewidgets): SUBDIRS += webenginewidgets diff --git a/examples/webengine/webengine.pro b/examples/webengine/webengine.pro new file mode 100644 index 000000000..969681e9d --- /dev/null +++ b/examples/webengine/webengine.pro @@ -0,0 +1,6 @@ +TEMPLATE=subdirs + +SUBDIRS += \ + customdialogs \ + minimal \ + quicknanobrowser diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro new file mode 100644 index 000000000..353104d6a --- /dev/null +++ b/examples/webenginewidgets/webenginewidgets.pro @@ -0,0 +1,17 @@ +TEMPLATE=subdirs + +SUBDIRS += \ + minimal \ + contentmanipulation \ + cookiebrowser \ + demobrowser \ + markdowneditor \ + simplebrowser + +contains(WEBENGINE_CONFIG, use_spellchecker):!cross_compile { + !contains(WEBENGINE_CONFIG, use_native_spellchecker) { + SUBDIRS += spellchecker + } else { + message("Spellcheck example will not be built because it depends on usage of Hunspell dictionaries.") + } +} diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 59417997a..b91e795ca 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -21,7 +21,9 @@ GYP_CONFIG += \ use_gnome_keyring=0 \ use_kerberos=0 \ use_pango=0 \ - use_openssl=1 + use_openssl=1 \ + use_allocator=none \ + use_experimental_allocator_shim=0 use?(nss) { GYP_CONFIG += \ diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 91da7fb60..77469a8ea 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -119,7 +119,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i suggestedFilename = toQt(item->GetTargetFilePath().AsUTF8Unsafe()); if (suggestedFilename.isEmpty()) - suggestedFilename = toQt(item->GetURL().ExtractFileName()); + suggestedFilename = QUrl::fromPercentEncoding(toQByteArray(item->GetURL().ExtractFileName())); if (suggestedFilename.isEmpty()) { suggestedFilename = QStringLiteral("qwe_download"); diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp index be8d17725..214fd5fa7 100644 --- a/src/core/favicon_manager.cpp +++ b/src/core/favicon_manager.cpp @@ -138,11 +138,9 @@ void FaviconManagerPrivate::storeIcon(int id, const QIcon &icon) Q_Q(FaviconManager); // Icon download has been interrupted - if (m_inProgressRequests.isEmpty()) + if (!m_inProgressRequests.contains(id)) return; - Q_ASSERT(m_inProgressRequests.contains(id)); - QUrl requestUrl = m_inProgressRequests[id]; FaviconInfo &faviconInfo = q->m_faviconInfoMap[requestUrl]; diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 228c37010..9de2085ba 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1171,6 +1171,12 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD d->currentDropAction = Qt::IgnoreAction; QDrag *drag = new QDrag(dragSource); // will be deleted by Qt's DnD implementation + bool dValid = true; + QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ + dValid = false; + QDrag::cancel(); + }); + drag->setMimeData(mimeDataFromDropData(*d->currentDropData)); if (!pixmap.isNull()) { drag->setPixmap(pixmap); @@ -1182,9 +1188,15 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD drag->exec(allowedActions); } - content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); - rvh->DragSourceSystemDragEnded(); - d->currentDropData.reset(); + QObject::disconnect(onDestroyed); + if (dValid) { + if (d->webContents) { + content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); + if (rvh) + rvh->DragSourceSystemDragEnded(); + } + d->currentDropData.reset(); + } } static blink::WebDragOperationsMask toWeb(const Qt::DropActions action) diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index ed6fdabff..0c4cf29d3 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -95,8 +95,11 @@ void WebContentsViewQt::RenderViewCreated(content::RenderViewHost* host) { // The render process is done creating the RenderView and it's ready to be routed // messages at this point. - if (m_client) - m_webContents->GetRenderWidgetHostView()->SetBackgroundColor(toSk(m_client->backgroundColor())); + if (m_client && m_webContents) { + content::RenderWidgetHostView* rwhv = m_webContents->GetRenderWidgetHostView(); + if (rwhv) + rwhv->SetBackgroundColor(toSk(m_client->backgroundColor())); + } } void WebContentsViewQt::CreateView(const gfx::Size& initial_size, gfx::NativeView context) diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 57813a82f..58f0a3e2c 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -299,6 +299,11 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p { // Override for now prefs->touch_enabled = isTouchScreenAvailable(); + if (prefs->viewport_enabled) { + // We should enable viewport and viewport-meta together, but since 5.7 we + // no longer have a command-line flag for viewport-meta. + prefs->viewport_meta_enabled = true; + } // Attributes mapping. prefs->loads_images_automatically = testAttribute(AutoLoadImages); diff --git a/src/webengine/api/qquickwebenginedialogrequests.cpp b/src/webengine/api/qquickwebenginedialogrequests.cpp index 641793e12..c57f4c76f 100644 --- a/src/webengine/api/qquickwebenginedialogrequests.cpp +++ b/src/webengine/api/qquickwebenginedialogrequests.cpp @@ -312,11 +312,10 @@ QString QQuickWebEngineJavaScriptDialogRequest::message() const } /*! - \qmlproperty string JavaScriptDialogRequest::defaultPrompt + \qmlproperty string JavaScriptDialogRequest::defaultText \readonly - The default text if the requested dialog box is of - the \l type PromptDialog. + The default prompt text, if the requested dialog is a prompt. */ @@ -811,7 +810,7 @@ QString QQuickWebEngineFormValidationMessageRequest::subText() const } /*! - \qmlproperty enumeration ValidationMessageRequest::type + \qmlproperty enumeration FormValidationMessageRequest::type \readonly The type of the form validation message request. diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 58116116c..ac320a9e6 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -222,6 +222,8 @@ quint32 QQuickWebEngineDownloadItem::id() const Download is in progress. \value WebEngineDownloadItem.DownloadCompleted Download completed successfully. + \value WebEngineDownloadItem.DownloadCancelled + Download was cancelled by the user. \value WebEngineDownloadItem.DownloadInterrupted Download has been interrupted (by the server or because of lost connectivity). */ diff --git a/src/webengine/api/qquickwebengineloadrequest.cpp b/src/webengine/api/qquickwebengineloadrequest.cpp index 47ec17c16..b3422c516 100644 --- a/src/webengine/api/qquickwebengineloadrequest.cpp +++ b/src/webengine/api/qquickwebengineloadrequest.cpp @@ -120,6 +120,26 @@ QString QQuickWebEngineLoadRequest::errorString() const return d->errorString; } +/*! + \qmlproperty enumeration WebEngineLoadRequest::errorDomain + This enumeration holds the type of a load request error: + + \value WebEngineView.NoErrorDomain + Error type is not known. + \value WebEngineView.InternalErrorDomain + Content cannot be interpreted by Qt WebEngine. + \value WebEngineView.ConnectionErrorDomain + Error results from a faulty network connection. + \value WebEngineView.CertificateErrorDomain + Error is related to the SSL/TLS certificate. + \value WebEngineView.HttpErrorDomain + Error is related to the HTTP connection. + \value WebEngineView.FtpErrorDomain + Error is related to the FTP connection. + \value WebEngineView.DnsErrorDomain + Error is related to the DNS connection. +*/ + QQuickWebEngineView::ErrorDomain QQuickWebEngineLoadRequest::errorDomain() const { Q_D(const QQuickWebEngineLoadRequest); diff --git a/src/webengine/api/qquickwebenginenavigationrequest.cpp b/src/webengine/api/qquickwebenginenavigationrequest.cpp index a738ece80..a6e253561 100644 --- a/src/webengine/api/qquickwebenginenavigationrequest.cpp +++ b/src/webengine/api/qquickwebenginenavigationrequest.cpp @@ -63,6 +63,20 @@ public: bool isMainFrame; }; +/*! + \qmltype WebEngineNavigationRequest + \instantiates QQuickWebEngineNavigationRequest + \inqmlmodule QtWebEngine + \since QtWebEngine 1.0 + + \brief Represents a request for navigating to a web page as part of + \l{WebEngineView::navigationRequested()}. + + To accept or reject a request, set \l action to + \c WebEngineNavigationRequest.AcceptRequest or + \c WebEngineNavigationRequest.IgnoreRequest. +*/ + QQuickWebEngineNavigationRequest::QQuickWebEngineNavigationRequest(const QUrl& url, QQuickWebEngineView::NavigationType navigationType, bool mainFrame, QObject* parent) : QObject(parent) , d_ptr(new QQuickWebEngineNavigationRequestPrivate(url, navigationType, mainFrame)) @@ -73,6 +87,17 @@ QQuickWebEngineNavigationRequest::~QQuickWebEngineNavigationRequest() { } +/*! + \qmlproperty enumeration WebEngineNavigationRequest::action + + Whether to accept or ignore the navigation request. + + \value WebEngineNavigationRequest.AcceptRequest + Accepts a navigation request. + \value WebEngineNavigationRequest.IgnoreRequest + Ignores a navigation request. +*/ + void QQuickWebEngineNavigationRequest::setAction(QQuickWebEngineView::NavigationRequestAction action) { Q_D(QQuickWebEngineNavigationRequest); @@ -83,6 +108,13 @@ void QQuickWebEngineNavigationRequest::setAction(QQuickWebEngineView::Navigation emit actionChanged(); } +/*! + \qmlproperty url WebEngineNavigationRequest::url + \readonly + + The URL of the web page to go to. +*/ + QUrl QQuickWebEngineNavigationRequest::url() const { Q_D(const QQuickWebEngineNavigationRequest); @@ -95,12 +127,39 @@ QQuickWebEngineView::NavigationRequestAction QQuickWebEngineNavigationRequest::a return d->action; } +/*! + \qmlproperty enumeration WebEngineNavigationRequest::navigationType + \readonly + + The method used to navigate to a web page. + + \value WebEngineNavigationRequest.LinkClickedNavigation + Clicking a link. + \value WebEngineNavigationRequest.TypedNavigation + Entering an URL on the address bar. + \value WebEngineNavigationRequest.FormSubmittedNavigation + Submitting a form. + \value WebEngineNavigationRequest.BackForwardNavigation + Using navigation history to go to the previous or next page. + \value WebEngineNavigationRequest.ReloadNavigation + Reloading the page. + \value WebEngineNavigationRequest.OtherNavigation + Using some other method to go to a page. +*/ + QQuickWebEngineView::NavigationType QQuickWebEngineNavigationRequest::navigationType() const { Q_D(const QQuickWebEngineNavigationRequest); return d->navigationType; } +/*! + \qmlproperty bool WebEngineNavigationRequest::isMainFrame + \readonly + + Whether the navigation issue is requested for a top level page. +*/ + bool QQuickWebEngineNavigationRequest::isMainFrame() const { Q_D(const QQuickWebEngineNavigationRequest); diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index ac01d9cd6..8a3c6c24f 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -267,7 +267,7 @@ bool QQuickWebEngineSettings::webGLEnabled() const \qmlproperty bool WebEngineSettings::accelerated2dCanvasEnabled \since QtWebEngine 1.3 - Specifies whether the HTML 5 2D canvas should be a OpenGL framebuffer. + Specifies whether the HTML 5 2D canvas should be an OpenGL framebuffer. This makes many painting operations faster, but slows down pixel access. Enabled by default if available. diff --git a/src/webengine/doc/src/qtwebengine-deploying.qdoc b/src/webengine/doc/src/qtwebengine-deploying.qdoc index 25b6d218c..351ef49de 100644 --- a/src/webengine/doc/src/qtwebengine-deploying.qdoc +++ b/src/webengine/doc/src/qtwebengine-deploying.qdoc @@ -31,7 +31,7 @@ The way to package and deploy applications varies between operating systems. For Windows and \macos, \l{The Windows Deployment Tool}{windeployqt} and - \l{Deploying Applications on OS X}{macdeployqt} automate the steps to + \l{Deploying Applications on macOS}{macdeployqt} automate the steps to generate a stand-alone application package. When manually deploying applications that depend on Qt WebEngine, all the diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc index 8135cad53..160cb4415 100644 --- a/src/webengine/doc/src/webengineview.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -387,8 +387,8 @@ \qmlmethod void WebEngineView::runJavaScript(string script, variant callback) Runs the specified \a script in the content of the web view. - In case a callback function is provided, it will be invoked after the script - finishes running. + The \a callback parameter is optional. If a callback function is provided, + it will be invoked after the script finishes running. \code runJavaScript("document.title", function(result) { console.log(result); }); @@ -513,28 +513,8 @@ This signal is emitted when a page load begins, ends, or fails. When handling the signal with \c onLoadingChanged, various read-only - parameters are available on the \a loadRequest: - - \table - \header - \li Property - \li Description - \row - \li url - \li The location of the resource that is loading. - \row - \li status - \li The \l{LoadStatus}{load status} of the page. - \row - \li errorString - \li The description of load error. - \row - \li errorCode - \li The HTTP error code. - \row - \li errorDomain - \li The high-level \l{ErrorDomain}{error type}. - \endtable + parameters are available on the WebEngineLoadRequest specified by + \a loadRequest. \sa loading, LoadStatus, ErrorDomain */ @@ -576,7 +556,7 @@ */ /*! - \qmlsignal WebEngineView::newViewRequested(WebEngineViewRequest request) + \qmlsignal WebEngineView::newViewRequested(WebEngineNewViewRequest request) \since QtWebEngine 1.1 This signal is emitted when a page load is requested to happen in a separate @@ -652,7 +632,7 @@ \value WebEngineView.ConnectionErrorDomain Error results from faulty network connection. \value WebEngineView.CertificateErrorDomain - Error related to the SSL/TLS certficate. + Error related to the SSL/TLS certificate. \value WebEngineView.HttpErrorDomain Error related to the HTTP connection. \value WebEngineView.FtpErrorDomain @@ -681,6 +661,9 @@ \value WebEngineView.LoadStartedStatus Page is currently loading. + \value WebEngineView.LoadStoppedStatus + Loading the page was stopped by the stop() method or by the loader + code or network stack in Chromium. \value WebEngineView.LoadSucceededStatus Page has successfully loaded, and is not currently loading. \value WebEngineView.LoadFailedStatus @@ -1021,8 +1004,13 @@ */ /*! + \qmlproperty url WebEngineFullScreenRequest::origin + \readonly + The URL of the web page that issued the fullscreen request. +*/ + +/*! \qmlproperty bool WebEngineFullScreenRequest::toggleOn - \since QtWebEngine 1.1 \readonly Returns \c{true} if the application should toggle fullscreen mode on, \c{false} otherwise. @@ -1032,7 +1020,6 @@ /*! \qmlmethod void WebEngineFullScreenRequest::accept() - \since QtWebEngine 1.1 Call this method to accept the fullscreen request. It sets the WebEngineView::isFullScreen property to be equal to toggleOn. @@ -1056,6 +1043,11 @@ */ /*! + \qmlmethod void WebEngineFullScreenRequest::reject() + Rejects a fullscreen request. +*/ + +/*! \qmlproperty bool WebEngineView::audioMuted \brief The state of whether the current page audio is muted. \since QtWebEngine 1.3 @@ -1122,7 +1114,7 @@ */ /*! - \qmlmethod void WebEngineView::printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) + \qmlmethod void WebEngineView::printToPdf(const string filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) \since QtWebEngine 1.3 Prints the WebEngineView's current content to a PDF document and stores it @@ -1133,6 +1125,9 @@ PDF and returns immediately. To be informed about the result of the request, connect to the signal pdfPrintingFinished(). + If you leave out \a pageSizeID, it defaults to \c A4. If you leave out + \a orientation, it defaults to \c Portrait. + \sa pdfPrintingFinished() */ @@ -1145,6 +1140,9 @@ The \a resultCallback must take a string parameter. This string will contain the document's data upon successful printing and an empty string otherwise. + + If you leave out \a pageSizeID, it defaults to \c A4. If you leave out + \a orientation, it defaults to \c Portrait. */ /*! @@ -1155,7 +1153,7 @@ */ /*! - \qmlsignal void WebEngineView::wasRecentlyAudibleChanged(bool wasRecentlyAudible) + \qmlsignal WebEngineView::wasRecentlyAudibleChanged(bool wasRecentlyAudible) \since QtWebEngine 1.3 This signal is emitted when the page's audible state is changed, due to audio @@ -1249,3 +1247,7 @@ \note Signal handlers need to call \c{request.accepted = true} to prevent a default context menu from showing up. */ + +/*! \qmlsignal WebEngineView::navigationRequested(WebEngineNavigationRequest request) + This signal is emitted when the navigation request \a request is issued. +*/ diff --git a/tests/auto/Info.plist.in b/tests/auto/Info.plist.in new file mode 100644 index 000000000..e7f314042 --- /dev/null +++ b/tests/auto/Info.plist.in @@ -0,0 +1,18 @@ +<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> +<dict> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleExecutable</key> + <string>$${TARGET}</string> + <key>CFBundleIdentifier</key> + <string>org.qt-project.qt.tests.$${TARGET_HYPHENATED}</string> + <key>CFBundleName</key> + <string>$${TARGET}</string> + <key>LSUIElement</key> + <string>0</string> +</dict> +</plist> diff --git a/tests/auto/core/tests.pri b/tests/auto/core/tests.pri index 606ed2a8c..19f53f12d 100644 --- a/tests/auto/core/tests.pri +++ b/tests/auto/core/tests.pri @@ -12,4 +12,5 @@ INCLUDEPATH += $$PWD exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc QT += testlib network webenginewidgets widgets -osx: CONFIG -= app_bundle + +include(../embed_info_plist.pri) diff --git a/tests/auto/embed_info_plist.pri b/tests/auto/embed_info_plist.pri new file mode 100644 index 000000000..cca93c35e --- /dev/null +++ b/tests/auto/embed_info_plist.pri @@ -0,0 +1,13 @@ +macos { + CONFIG -= app_bundle + + # QTBUG-57354 embed Info.plist so that certain fonts can be found in non-bundle apps + out_info = $$OUT_PWD/Info.plist + embed_info_plist.input = $$PWD/Info.plist.in + embed_info_plist.output = $$out_info + TARGET_HYPHENATED = $$replace(TARGET, [^a-zA-Z0-9-.], -) + QMAKE_SUBSTITUTES += embed_info_plist + QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$shell_quote($$out_info) + PRE_TARGETDEPS += $$out_info + QMAKE_DISTCLEAN += $$out_info +} diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri index efe9ff9d0..e00537b9e 100644 --- a/tests/auto/quick/tests.pri +++ b/tests/auto/quick/tests.pri @@ -13,11 +13,11 @@ INCLUDEPATH += \ QT += testlib network quick webengine -macx: CONFIG -= app_bundle - # This define is used by some tests to look up resources in the source tree DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" isQMLTestSupportApiEnabled() { DEFINES += ENABLE_QML_TESTSUPPORT_API } + +include(../embed_info_plist.pri) diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index d7fff3a66..5467ce39e 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -3989,16 +3989,10 @@ void tst_QWebEnginePage::setHtmlWithImageResource() void tst_QWebEnginePage::setHtmlWithStylesheetResource() { -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - // By default, only security origins of local files can load local resources. - // So we should specify baseUrl to be a local file in order to be able to download the local stylesheet. - const char* htmlData = "<html>" "<head>" - "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />" + "<link rel='stylesheet' href='qrc:/resources/style.css' type='text/css' />" "</head>" "<body>" "<p id='idP'>some text</p>" @@ -4006,22 +4000,21 @@ void tst_QWebEnginePage::setHtmlWithStylesheetResource() "</html>"; QLatin1String html(htmlData); QWebEnginePage page; - QWebEngineElement webElement; - - page.setHtml(html, QUrl(QLatin1String("qrc:///file"))); QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished); - QVERIFY(spyFinished.wait(200)); - webElement = page.documentElement().findFirst("p"); - QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QLatin1String("red")); - // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. + // We allow access to qrc resources from any security origin, including local and anonymous + page.setHtml(html, QUrl("file:///path/to/file")); + QVERIFY(spyFinished.wait()); + QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)")); + + page.setHtml(html, QUrl(QLatin1String("qrc:/"))); + QVERIFY(spyFinished.wait()); + QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)")); - page.setHtml(html, QUrl(QLatin1String("http://www.example.com/"))); - QVERIFY(spyFinished.wait(200)); - webElement = page.documentElement().findFirst("p"); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); - QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QString()); -#endif + // Now we test the opposite: without a baseUrl as a local file, we can still request qrc resources. + page.setHtml(html); + QVERIFY(spyFinished.wait()); + QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)")); } void tst_QWebEnginePage::setHtmlWithBaseURL() diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri index 14074cd08..d77cd5af5 100644 --- a/tests/auto/widgets/tests.pri +++ b/tests/auto/widgets/tests.pri @@ -13,7 +13,8 @@ RESOURCES += ../resources/tests.qrc exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc QT += testlib network webenginewidgets widgets quick quickwidgets -macx: CONFIG -= app_bundle # This define is used by some tests to look up resources in the source tree DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" + +include(../embed_info_plist.pri) |