diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-08-31 13:33:38 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-09-03 15:21:53 +0000 |
commit | b5c9226856330772b239f4ca91fc252a55d0d83a (patch) | |
tree | 7624112f2bd23bfaa51abe5583d2fbcac795fcdf | |
parent | d85a349f4136554cfaa5349303270ad37b121941 (diff) |
Fix selectAll on data url
SelectAll only works when there is a focused frame, so we must ensure
a frame is focused when the web-contents requests focus.
Change-Id: I00d670321b29342fcd447b4b07251df776019f1c
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
-rw-r--r-- | src/core/web_contents_adapter.cpp | 1 | ||||
-rw-r--r-- | src/core/web_contents_view_qt.cpp | 2 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 10 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index ab4a02836..6fb2f5c97 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -484,6 +484,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT params.can_load_local_resources = true; params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API); d->webContents->GetController().LoadURLWithParams(params); + d->webContents->Focus(); } QUrl WebContentsAdapter::activeUrl() const diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index c32753435..67addacd5 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -113,6 +113,8 @@ void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const void WebContentsViewQt::Focus() { + if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView()) + rwhv->Focus(); m_client->focusContainer(); } diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 4ed79e0c0..ba5366460 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -3120,13 +3120,16 @@ void tst_QWebEnginePage::testStopScheduledPageRefresh() void tst_QWebEnginePage::findText() { - m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>")); -#if defined(QWEBENGINEPAGE_TRIGGERACTION_SELECTALL) + QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); + m_page->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>")); + QTRY_COMPARE(loadSpy.count(), 1); m_page->triggerAction(QWebEnginePage::SelectAll); - QVERIFY(!m_page->selectedText().isEmpty()); + QTRY_COMPARE(m_page->hasSelection(), true); +#if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(!m_page->selectedHtml().isEmpty()); #endif m_page->findText(""); + QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue); QVERIFY(m_page->selectedText().isEmpty()); #if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(m_page->selectedHtml().isEmpty()); @@ -3140,6 +3143,7 @@ void tst_QWebEnginePage::findText() QVERIFY(m_page->selectedHtml().contains(subString)); #endif m_page->findText(""); + QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue); QVERIFY(m_page->selectedText().isEmpty()); #if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(m_page->selectedHtml().isEmpty()); |