summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-14 12:29:28 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-10-14 12:29:54 +0200
commit9be23eb946580519b2b0600cc854ec8050b90659 (patch)
tree63ccf0e565f346a0788d937b004e01d2ec029b5e /tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
parent4f2e66f9d898e9c11a7ad6e552d0d47bb15d4051 (diff)
parent981e38d2dc82c047c6ad8ec19427d3ac7434dc3c (diff)
Merge remote-tracking branch 'origin/5.6' into devwip/47-based
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 6e3976766..9559f3cf5 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -40,6 +40,7 @@
#include <qpa/qplatforminputcontext.h>
#include <qwebenginehistory.h>
#include <qwebenginepage.h>
+#include <qwebengineprofile.h>
#include <qwebenginesettings.h>
#include <qwebengineview.h>
#include <qimagewriter.h>
@@ -2810,28 +2811,16 @@ void tst_QWebEnginePage::userAgentApplicationName()
#endif
}
-class CustomUserAgentWebPage : public QWebEnginePage
-{
-public:
- static const QLatin1String filteredUserAgent;
-protected:
- virtual QString userAgentForUrl(const QUrl& url) const
- {
- Q_UNUSED(url);
- return QString("My User Agent\nX-New-Http-Header: Oh Noes!");
- }
-};
-const QLatin1String CustomUserAgentWebPage::filteredUserAgent("My User AgentX-New-Http-Header: Oh Noes!");
-
void tst_QWebEnginePage::userAgentNewlineStripping()
{
-#if !defined(QWEBENGINEPAGE_USERAGENTFORURL)
- QSKIP("QWEBENGINEPAGE_USERAGENTFORURL");
-#else
- CustomUserAgentWebPage page;
- page.setHtml("<html><body></body></html>");
- QCOMPARE(evaluateJavaScriptSync(&page, "navigator.userAgent").toString(), CustomUserAgentWebPage::filteredUserAgent);
-#endif
+ QWebEngineProfile profile;
+ QWebEnginePage page(&profile);
+
+ profile.setHttpUserAgent(QStringLiteral("My User Agent\nX-New-Http-Header: Oh Noes!"));
+ // The user agent will be updated after a page load.
+ page.load(QUrl("about:blank"));
+
+ QCOMPARE(evaluateJavaScriptSync(&page, "navigator.userAgent").toString(), QStringLiteral("My User Agent X-New-Http-Header: Oh Noes!"));
}
void tst_QWebEnginePage::crashTests_LazyInitializationOfMainFrame()