summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/qt
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-07-08 12:51:48 +0100
committerSteve Block <steveblock@google.com>2010-07-09 15:33:40 +0100
commitca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 (patch)
treebb45155550ec013adc0ad10f4d7d354c6469b022 /WebKitTools/DumpRenderTree/qt
parentd4b24d9a829ed7de70381c8b99fb75a07ab40466 (diff)
downloadexternal_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.zip
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.gz
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.bz2
Merge WebKit at r62496: Initial merge by git
Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt')
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp64
-rw-r--r--WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h11
-rw-r--r--WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp17
-rw-r--r--WebKitTools/DumpRenderTree/qt/EventSenderQt.h1
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp32
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h11
6 files changed, 103 insertions, 33 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
index f5fbb5c..3eb1714 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
@@ -353,6 +353,14 @@ bool WebPage::allowGeolocationRequest(QWebFrame *)
return m_drt->layoutTestController()->geolocationPermission();
}
+void WebPage::setViewGeometry(const QRect& rect)
+{
+ if (WebViewGraphicsBased* v = qobject_cast<WebViewGraphicsBased*>(view()))
+ v->scene()->setSceneRect(QRectF(rect));
+ else if (QWidget *v = view())
+ v->setGeometry(rect);
+}
+
WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent)
: m_item(new QGraphicsWebView)
{
@@ -660,13 +668,35 @@ void DumpRenderTree::hidePage()
m_mainView->hide();
}
+QString DumpRenderTree::dumpFrameScrollPosition(QWebFrame* frame)
+{
+ if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame))
+ return QString();
+
+ QString result;
+ QPoint pos = frame->scrollPosition();
+ if (pos.x() > 0 || pos.y() > 0) {
+ QWebFrame* parent = qobject_cast<QWebFrame *>(frame->parent());
+ if (parent)
+ result.append(QString("frame '%1' ").arg(frame->title()));
+ result.append(QString("scrolled to %1,%2\n").arg(pos.x()).arg(pos.y()));
+ }
+
+ if (m_controller->shouldDumpChildFrameScrollPositions()) {
+ QList<QWebFrame*> children = frame->childFrames();
+ for (int i = 0; i < children.size(); ++i)
+ result += dumpFrameScrollPosition(children.at(i));
+ }
+ return result;
+}
+
QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame)
{
if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame))
return QString();
QString result;
- QWebFrame *parent = qobject_cast<QWebFrame *>(frame->parent());
+ QWebFrame* parent = qobject_cast<QWebFrame*>(frame->parent());
if (parent) {
result.append(QLatin1String("\n--------\nFrame: '"));
result.append(frame->frameName());
@@ -721,16 +751,16 @@ static QString dumpHistoryItem(const QWebHistoryItem& item, int indent, bool cur
result.append(QLatin1String(" **nav target**"));
result.append(QLatin1String("\n"));
- QList<QWebHistoryItem> children = DumpRenderTreeSupportQt::getChildHistoryItems(item);
- for (int i = 0; i < children.size(); ++i)
- result += dumpHistoryItem(children.at(i), 12, false);
+ QMap<QString, QWebHistoryItem> children = DumpRenderTreeSupportQt::getChildHistoryItems(item);
+ foreach (QWebHistoryItem item, children)
+ result += dumpHistoryItem(item, 12, false);
return result;
}
-QString DumpRenderTree::dumpBackForwardList()
+QString DumpRenderTree::dumpBackForwardList(QWebPage* page)
{
- QWebHistory* history = webPage()->history();
+ QWebHistory* history = page->history();
QString result;
result.append(QLatin1String("\n============== Back Forward List ==============\n"));
@@ -794,15 +824,21 @@ void DumpRenderTree::dump()
QString resultString;
if (m_controller->shouldDumpAsText())
resultString = dumpFramesAsText(mainFrame);
- else
+ else {
resultString = mainFrame->renderTreeDump();
-
+ resultString += dumpFrameScrollPosition(mainFrame);
+ }
if (!resultString.isEmpty()) {
fprintf(stdout, "Content-Type: text/plain\n");
fprintf(stdout, "%s", resultString.toUtf8().constData());
- if (m_controller->shouldDumpBackForwardList())
- fprintf(stdout, "%s", dumpBackForwardList().toUtf8().constData());
+ if (m_controller->shouldDumpBackForwardList()) {
+ fprintf(stdout, "%s", dumpBackForwardList(webPage()).toUtf8().constData());
+ foreach (QObject* widget, windows) {
+ QWebPage* page = qobject_cast<QWebPage*>(widget->findChild<QWebPage*>());
+ fprintf(stdout, "%s", dumpBackForwardList(page).toUtf8().constData());
+ }
+ }
} else
printf("ERROR: nil result from %s", methodNameStringForFailedTest(m_controller));
@@ -946,7 +982,13 @@ int DumpRenderTree::windowCount() const
void DumpRenderTree::switchFocus(bool focused)
{
QFocusEvent event((focused) ? QEvent::FocusIn : QEvent::FocusOut, Qt::ActiveWindowFocusReason);
- QApplication::sendEvent(m_mainView, &event);
+ if (!isGraphicsBased())
+ QApplication::sendEvent(m_mainView, &event);
+ else {
+ if (WebViewGraphicsBased* view = qobject_cast<WebViewGraphicsBased*>(m_mainView))
+ view->scene()->sendEvent(view->graphicsView(), &event);
+ }
+
}
void DumpRenderTree::checkPermission(const QUrl& url, NotificationPermission& permission)
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
index 2ec972a..f258189 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h
@@ -133,7 +133,8 @@ private Q_SLOTS:
private:
QString dumpFramesAsText(QWebFrame* frame);
- QString dumpBackForwardList();
+ QString dumpBackForwardList(QWebPage* page);
+ QString dumpFrameScrollPosition(QWebFrame* frame);
LayoutTestController *m_controller;
bool m_dumpPixels;
@@ -198,12 +199,8 @@ protected:
bool isTextOutputEnabled() { return m_drt->isTextOutputEnabled(); }
private slots:
- void setViewGeometry(const QRect &r)
- {
- QWidget *v = view();
- if (v)
- v->setGeometry(r);
- }
+ void setViewGeometry(const QRect&);
+
private:
QWebInspector* m_webInspector;
DumpRenderTree *m_drt;
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
index 5f340e9..1e495b1 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
@@ -368,9 +368,9 @@ void EventSender::contextClick()
void EventSender::scheduleAsynchronousClick()
{
QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::RightButton, Qt::NoModifier);
- QApplication::postEvent(m_page, event);
+ postEvent(m_page, event);
QMouseEvent* event2 = new QMouseEvent(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::RightButton, Qt::NoModifier);
- QApplication::postEvent(m_page, event2);
+ postEvent(m_page, event2);
}
void EventSender::addTouchPoint(int x, int y)
@@ -552,7 +552,7 @@ void EventSender::replaySavedEvents(bool flush)
// First send all the events that are ready to be sent
while (!eventQueue[startOfQueue].m_delay && startOfQueue < endOfQueue) {
QEvent* ev = eventQueue[startOfQueue++].m_event;
- QApplication::postEvent(m_page->view(), ev); // ev deleted by the system
+ postEvent(m_page->view(), ev);
}
if (startOfQueue == endOfQueue) {
// Reset the queue
@@ -643,3 +643,14 @@ void EventSender::sendEvent(QObject* receiver, QEvent* event)
else
QApplication::sendEvent(receiver, event);
}
+
+void EventSender::postEvent(QObject* receiver, QEvent* event)
+{
+ // QGraphicsScene does not have a postEvent method, so send the event in this case
+ // and delete it after that.
+ if (WebCore::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(receiver)) {
+ view->scene()->sendEvent(view->graphicsView(), event);
+ delete event;
+ } else
+ QApplication::postEvent(receiver, event); // event deleted by the system
+}
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
index c2ff746..a17e938 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
@@ -90,6 +90,7 @@ private:
QGraphicsSceneMouseEvent* createGraphicsSceneMouseEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, Qt::MouseButton, Qt::MouseButtons, Qt::KeyboardModifiers);
QGraphicsSceneWheelEvent* createGraphicsSceneWheelEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, int delta, Qt::KeyboardModifiers, Qt::Orientation);
void sendEvent(QObject* receiver, QEvent* event);
+ void postEvent(QObject* receiver, QEvent* event);
private:
void sendTouchEvent(QEvent::Type);
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
index 3cced7d..008190f 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
@@ -35,7 +35,6 @@
#include "WorkQueueItemQt.h"
#include <QDir>
#include <QLocale>
-#include <qwebscriptworld.h>
#include <qwebsettings.h>
LayoutTestController::LayoutTestController(WebCore::DumpRenderTree* drt)
@@ -54,6 +53,7 @@ void LayoutTestController::reset()
m_textDump = false;
m_dumpBackForwardList = false;
m_dumpChildrenAsText = false;
+ m_dumpChildFrameScrollPositions = false;
m_canOpenWindows = false;
m_waitForDone = false;
m_dumpTitleChanges = false;
@@ -65,14 +65,18 @@ void LayoutTestController::reset()
m_handleErrorPages = false;
m_webHistory = 0;
m_globalFlag = false;
+ m_userStyleSheetEnabled = false;
m_desktopNotificationAllowedOrigins.clear();
DumpRenderTreeSupportQt::dumpEditingCallbacks(false);
DumpRenderTreeSupportQt::dumpFrameLoader(false);
DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);
+ DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(false);
DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(false);
DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(false);
DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList());
+ DumpRenderTreeSupportQt::clearScriptWorlds();
+ DumpRenderTreeSupportQt::setCustomPolicyDelegate(false, false);
setIconDatabaseEnabled(false);
emit hidePage();
@@ -225,6 +229,11 @@ void LayoutTestController::dumpResourceLoadCallbacks()
DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(true);
}
+void LayoutTestController::dumpResourceResponseMIMETypes()
+{
+ DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(true);
+}
+
void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(bool enabled)
{
DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(enabled);
@@ -490,6 +499,11 @@ void LayoutTestController::removeOriginAccessWhitelistEntry(const QString& sourc
DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains);
}
+void LayoutTestController::setCustomPolicyDelegate(bool enabled, bool permissive)
+{
+ DumpRenderTreeSupportQt::setCustomPolicyDelegate(enabled, permissive);
+}
+
void LayoutTestController::waitForPolicyDelegate()
{
m_waitForPolicy = true;
@@ -524,6 +538,9 @@ void LayoutTestController::overridePreference(const QString& name, const QVarian
void LayoutTestController::setUserStyleSheetLocation(const QString& url)
{
m_userStyleSheetLocation = QUrl(url);
+
+ if (m_userStyleSheetEnabled)
+ setUserStyleSheetEnabled(true);
}
void LayoutTestController::setCaretBrowsingEnabled(bool value)
@@ -533,6 +550,8 @@ void LayoutTestController::setCaretBrowsingEnabled(bool value)
void LayoutTestController::setUserStyleSheetEnabled(bool enabled)
{
+ m_userStyleSheetEnabled = enabled;
+
if (enabled)
m_drt->webPage()->settings()->setUserStyleSheetUrl(m_userStyleSheetLocation);
else
@@ -665,16 +684,7 @@ void LayoutTestController::setMockGeolocationPosition(double latitude, double lo
void LayoutTestController::evaluateScriptInIsolatedWorld(int worldID, const QString& script)
{
- QWebScriptWorld* scriptWorld;
- if (!worldID) {
- scriptWorld = new QWebScriptWorld();
- } else if (!m_worldMap.contains(worldID)) {
- scriptWorld = new QWebScriptWorld();
- m_worldMap.insert(worldID, scriptWorld);
- } else
- scriptWorld = m_worldMap.value(worldID);
-
- m_drt->webPage()->mainFrame()->evaluateScriptInIsolatedWorld(scriptWorld, script);
+ DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->webPage()->mainFrame(), worldID, script);
}
const unsigned LayoutTestController::maxViewWidth = 800;
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
index b56f1c9..ed1a232 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
@@ -62,6 +62,7 @@ public:
bool shouldDumpAsText() const { return m_textDump; }
bool shouldDumpBackForwardList() const { return m_dumpBackForwardList; }
bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; }
+ bool shouldDumpChildFrameScrollPositions() const { return m_dumpChildFrameScrollPositions; }
bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
bool shouldWaitUntilDone() const { return m_waitForDone; }
@@ -88,6 +89,7 @@ public slots:
void maybeDump(bool ok);
void dumpAsText() { m_textDump = true; }
void dumpChildFramesAsText() { m_dumpChildrenAsText = true; }
+ void dumpChildFrameScrollPositions() { m_dumpChildFrameScrollPositions = true; }
void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
void setCanOpenWindows() { m_canOpenWindows = true; }
@@ -103,6 +105,7 @@ public slots:
void dumpEditingCallbacks();
void dumpFrameLoadCallbacks();
void dumpResourceLoadCallbacks();
+ void dumpResourceResponseMIMETypes();
void setWillSendRequestReturnsNullOnRedirect(bool enabled);
void setWillSendRequestReturnsNull(bool enabled);
void setWillSendRequestClearHeader(const QStringList& headers);
@@ -171,7 +174,9 @@ public slots:
void clearAllDatabases();
void setIconDatabaseEnabled(bool enable);
+ void setCustomPolicyDelegate(bool enabled, bool permissive = true);
void waitForPolicyDelegate();
+
void overridePreference(const QString& name, const QVariant& value);
void setUserStyleSheetLocation(const QString& url);
void setUserStyleSheetEnabled(bool enabled);
@@ -194,6 +199,9 @@ public slots:
bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
bool geolocationPermission() const { return m_geolocationPermission; }
+ // Empty stub method to keep parity with object model exposed by global LayoutTestController.
+ void abortModal() {}
+
/*
Policy values: 'on', 'auto' or 'off'.
Orientation values: 'vertical' or 'horizontal'.
@@ -218,6 +226,7 @@ private:
bool m_textDump;
bool m_dumpBackForwardList;
bool m_dumpChildrenAsText;
+ bool m_dumpChildFrameScrollPositions;
bool m_canOpenWindows;
bool m_waitForDone;
bool m_dumpTitleChanges;
@@ -227,10 +236,10 @@ private:
bool m_handleErrorPages;
bool m_loadFinished;
bool m_globalFlag;
+ bool m_userStyleSheetEnabled;
bool m_isGeolocationPermissionSet;
bool m_geolocationPermission;
- QMap<int, QWebScriptWorld*> m_worldMap;
QUrl m_userStyleSheetLocation;
QBasicTimer m_timeoutTimer;
QWebFrame* m_topLoadingFrame;