diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/qt')
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro | 8 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp | 113 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h | 2 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp | 36 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/EventSenderQt.h | 10 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/GCControllerQt.cpp | 12 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/GCControllerQt.h | 2 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/ImageDiff.pro | 3 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp | 203 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h | 39 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro | 1 | ||||
-rw-r--r-- | WebKitTools/DumpRenderTree/qt/main.cpp | 7 |
12 files changed, 344 insertions, 92 deletions
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro index ad42bdd..b66eb5d 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro @@ -2,12 +2,8 @@ TARGET = DumpRenderTree CONFIG -= app_bundle CONFIG += uitools -mac:!static:contains(QT_CONFIG, qt_framework):!CONFIG(webkit_no_framework) { - CONFIG -= debug - CONFIG += release -} - BASEDIR = $$PWD/../ +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. include(../../../WebKit.pri) INCLUDEPATH += /usr/include/freetype2 @@ -17,7 +13,7 @@ INCLUDEPATH += ../../../JavaScriptCore/ForwardingHeaders INCLUDEPATH += $$BASEDIR DESTDIR = ../../../bin -!win32 { +!win32:!symbian { CONFIG += link_pkgconfig PKGCONFIG += fontconfig } diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 43f1318..2c2db92 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -32,6 +32,7 @@ #include "config.h" #include "DumpRenderTreeQt.h" +#include "../../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" #include "EventSenderQt.h" #include "GCControllerQt.h" #include "LayoutTestControllerQt.h" @@ -39,12 +40,11 @@ #include "testplugin.h" #include "WorkQueue.h" +#include <QApplication> #include <QBuffer> #include <QCryptographicHash> #include <QDir> #include <QFile> -#include <QApplication> -#include <QUrl> #include <QFileInfo> #include <QFocusEvent> #include <QFontDatabase> @@ -52,7 +52,13 @@ #include <QNetworkAccessManager> #include <QNetworkReply> #include <QNetworkRequest> +#include <QPaintDevice> +#include <QPaintEngine> +#ifndef QT_NO_PRINTER +#include <QPrinter> +#endif #include <QUndoStack> +#include <QUrl> #include <qwebsettings.h> #include <qwebsecurityorigin.h> @@ -66,6 +72,7 @@ #endif #include <limits.h> +#include <locale.h> #ifndef Q_OS_WIN #include <unistd.h> @@ -73,20 +80,12 @@ #include <qdebug.h> -extern void qt_drt_run(bool b); extern void qt_dump_set_accepts_editing(bool b); extern void qt_dump_frame_loader(bool b); -extern void qt_drt_clearFrameName(QWebFrame* qFrame); -extern void qt_drt_overwritePluginDirectories(); -extern void qt_drt_resetOriginAccessWhiteLists(); -extern bool qt_drt_hasDocumentElement(QWebFrame* qFrame); +extern void qt_dump_resource_load_callbacks(bool b); namespace WebCore { -// Choose some default values. -const unsigned int maxViewWidth = 800; -const unsigned int maxViewHeight = 600; - NetworkAccessManager::NetworkAccessManager(QObject* parent) : QNetworkAccessManager(parent) { @@ -116,6 +115,26 @@ void NetworkAccessManager::sslErrorsEncountered(QNetworkReply* reply, const QLis } #endif + +#ifndef QT_NO_PRINTER +class NullPrinter : public QPrinter { +public: + class NullPaintEngine : public QPaintEngine { + public: + virtual bool begin(QPaintDevice*) { return true; } + virtual bool end() { return true; } + virtual QPaintEngine::Type type() const { return QPaintEngine::User; } + virtual void drawPixmap(const QRectF& r, const QPixmap& pm, const QRectF& sr) { } + virtual void updateState(const QPaintEngineState& state) { } + }; + + virtual QPaintEngine* paintEngine() const { return const_cast<NullPaintEngine*>(&m_engine); } + + NullPaintEngine m_engine; +}; +#endif + + WebPage::WebPage(QObject* parent, DumpRenderTree* drt) : QWebPage(parent) , m_webInspector(0) @@ -135,6 +154,7 @@ WebPage::WebPage(QObject* parent, DumpRenderTree* drt) globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true); globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); + globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false); connect(this, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(setViewGeometry(const QRect & ))); @@ -165,9 +185,16 @@ void WebPage::resetSettings() settings()->resetAttribute(QWebSettings::JavascriptCanOpenWindows); settings()->resetAttribute(QWebSettings::JavascriptEnabled); settings()->resetAttribute(QWebSettings::PrivateBrowsingEnabled); + settings()->resetAttribute(QWebSettings::SpatialNavigationEnabled); settings()->resetAttribute(QWebSettings::LinksIncludedInFocusChain); settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); settings()->resetAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); + settings()->resetAttribute(QWebSettings::PluginsEnabled); + + m_drt->layoutTestController()->setCaretBrowsingEnabled(false); + m_drt->layoutTestController()->setFrameFlatteningEnabled(false); + m_drt->layoutTestController()->setSmartInsertDeleteEnabled(true); + m_drt->layoutTestController()->setSelectTrailingWhitespaceEnabled(false); // globalSettings must be reset explicitly. m_drt->layoutTestController()->setXSSAuditorEnabled(false); @@ -315,16 +342,25 @@ DumpRenderTree::DumpRenderTree() , m_enableTextOutput(false) , m_singleFileMode(false) { - qt_drt_overwritePluginDirectories(); - QWebSettings::enablePersistentStorage(); + DumpRenderTreeSupportQt::overwritePluginDirectories(); + + char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP"); + if (dumpRenderTreeTemp) + QWebSettings::enablePersistentStorage(QString(dumpRenderTreeTemp)); + else + QWebSettings::enablePersistentStorage(); // create our primary testing page/view. m_mainView = new QWebView(0); - m_mainView->resize(QSize(maxViewWidth, maxViewHeight)); + m_mainView->resize(QSize(LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight)); m_page = new WebPage(m_mainView, this); m_mainView->setPage(m_page); m_mainView->setContextMenuPolicy(Qt::NoContextMenu); + // clean up cache by resetting quota. + qint64 quota = webPage()->settings()->offlineWebApplicationCacheQuota(); + webPage()->settings()->setOfflineWebApplicationCacheQuota(quota); + // create our controllers. This has to be done before connectFrame, // as it exports there to the JavaScript DOM window. m_controller = new LayoutTestController(this); @@ -348,6 +384,7 @@ DumpRenderTree::DumpRenderTree() connect(m_page, SIGNAL(loadStarted()), m_controller, SLOT(resetLoadFinished())); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); + connect(m_page, SIGNAL(printRequested(QWebFrame*)), this, SLOT(dryRunPrint(QWebFrame*))); connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)), SLOT(titleChanged(const QString&))); @@ -357,7 +394,8 @@ DumpRenderTree::DumpRenderTree() this, SLOT(statusBarMessage(const QString&))); QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection); - qt_drt_run(true); + + DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true); QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason); QApplication::sendEvent(m_mainView, &event); } @@ -381,6 +419,14 @@ static void clearHistory(QWebPage* page) history->setMaximumItemCount(itemCount); } +void DumpRenderTree::dryRunPrint(QWebFrame* frame) +{ +#ifndef QT_NO_PRINTER + NullPrinter printer; + frame->print(&printer); +#endif +} + void DumpRenderTree::resetToConsistentStateBeforeTesting() { // reset so that any current loads are stopped @@ -395,18 +441,24 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() // of the DRT. m_controller->reset(); + // reset mouse clicks counter + m_eventSender->resetClickCount(); + closeRemainingWindows(); m_page->resetSettings(); m_page->undoStack()->clear(); m_page->mainFrame()->setZoomFactor(1.0); clearHistory(m_page); - qt_drt_clearFrameName(m_page->mainFrame()); + DumpRenderTreeSupportQt::clearFrameName(m_page->mainFrame()); + + m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); + m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); WorkQueue::shared()->clear(); WorkQueue::shared()->setFrozen(false); - qt_drt_resetOriginAccessWhiteLists(); + DumpRenderTreeSupportQt::resetOriginAccessWhiteLists(); QLocale::setDefault(QLocale::c()); setlocale(LC_ALL, ""); @@ -419,20 +471,30 @@ static bool isWebInspectorTest(const QUrl& url) return false; } +static bool shouldEnableDeveloperExtras(const QUrl& url) +{ + return isWebInspectorTest(url) || url.path().contains("inspector-enabled/"); +} + void DumpRenderTree::open(const QUrl& url) { resetToConsistentStateBeforeTesting(); - if (isWebInspectorTest(m_page->mainFrame()->url())) + if (shouldEnableDeveloperExtras(m_page->mainFrame()->url())) { layoutTestController()->closeWebInspector(); + layoutTestController()->setDeveloperExtrasEnabled(false); + } - if (isWebInspectorTest(url)) - layoutTestController()->showWebInspector(); + if (shouldEnableDeveloperExtras(url)) { + layoutTestController()->setDeveloperExtrasEnabled(true); + if (isWebInspectorTest(url)) + layoutTestController()->showWebInspector(); + } // W3C SVG tests expect to be 480x360 bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); - int width = isW3CTest ? 480 : maxViewWidth; - int height = isW3CTest ? 360 : maxViewHeight; + int width = isW3CTest ? 480 : LayoutTestController::maxViewWidth; + int height = isW3CTest ? 360 : LayoutTestController::maxViewHeight; m_mainView->resize(QSize(width, height)); m_page->setPreferredContentsSize(QSize()); m_page->setViewportSize(QSize(width, height)); @@ -441,7 +503,9 @@ void DumpRenderTree::open(const QUrl& url) m_page->event(&ev); QWebSettings::clearMemoryCaches(); +#if !(defined(Q_WS_S60) && QT_VERSION <= QT_VERSION_CHECK(4, 6, 2)) QFontDatabase::removeAllApplicationFonts(); +#endif #if defined(Q_WS_X11) initializeFonts(); #endif @@ -557,7 +621,7 @@ void DumpRenderTree::hidePage() QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) { - if (!frame || !qt_drt_hasDocumentElement(frame)) + if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame)) return QString(); QString result; @@ -666,8 +730,9 @@ static const char *methodNameStringForFailedTest(LayoutTestController *controlle void DumpRenderTree::dump() { - // Prevent any further frame load callbacks from appearing after we dump the result. + // Prevent any further frame load or resource load callbacks from appearing after we dump the result. qt_dump_frame_loader(false); + qt_dump_resource_load_callbacks(false); QWebFrame *mainFrame = m_page->mainFrame(); diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h index 8d80f87..8309492 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h @@ -53,6 +53,7 @@ QT_END_NAMESPACE class QWebFrame; class LayoutTestController; +class DumpRenderTreeSupportQt; class EventSender; class TextInputController; class GCController; @@ -118,6 +119,7 @@ Q_SIGNALS: private Q_SLOTS: void showPage(); void hidePage(); + void dryRunPrint(QWebFrame*); private: QString dumpFramesAsText(QWebFrame* frame); diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp index 1ef2d3f..7432052 100644 --- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp @@ -67,6 +67,8 @@ EventSender::EventSender(QWebPage* parent) endOfQueue = 0; startOfQueue = 0; m_eventLoop = 0; + m_currentButton = 0; + resetClickCount(); m_page->view()->installEventFilter(this); } @@ -92,11 +94,28 @@ void EventSender::mouseDown(int button) break; } + // only consider a click to count, an event originated by the + // same previous button and at the same position. + if (m_currentButton == button + && m_mousePos == m_clickPos + && m_clickTimer.isActive()) + m_clickCount++; + else + m_clickCount = 1; + + m_currentButton = button; + m_clickPos = m_mousePos; m_mouseButtons |= mouseButton; // qDebug() << "EventSender::mouseDown" << frame; - QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonPress, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier); + QMouseEvent* event; + event = new QMouseEvent((m_clickCount == 2) ? QEvent::MouseButtonDblClick : + QEvent::MouseButtonPress, m_mousePos, m_mousePos, + mouseButton, m_mouseButtons, Qt::NoModifier); + sendOrQueueEvent(event); + + m_clickTimer.start(QApplication::doubleClickInterval(), this); } void EventSender::mouseUp(int button) @@ -289,11 +308,15 @@ void EventSender::scheduleAsynchronousClick() void EventSender::addTouchPoint(int x, int y) { #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) - int id = m_touchPoints.count(); + // Use index to refer to the position in the vector that this touch + // is stored. We then create a unique id for the touch that will be + // passed into WebCore. + int index = m_touchPoints.count(); + int id = m_touchPoints.isEmpty() ? 0 : m_touchPoints.last().id() + 1; QTouchEvent::TouchPoint point(id); m_touchPoints.append(point); - updateTouchPoint(id, x, y); - m_touchPoints[id].setState(Qt::TouchPointPressed); + updateTouchPoint(index, x, y); + m_touchPoints[index].setState(Qt::TouchPointPressed); #endif } @@ -510,3 +533,8 @@ bool EventSender::eventFilter(QObject* watched, QEvent* event) } return false; } + +void EventSender::timerEvent(QTimerEvent* ev) +{ + m_clickTimer.stop(); +} diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h index 38bca89..e824e0f 100644 --- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h +++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h @@ -30,6 +30,7 @@ #define EventSenderQt_h #include <QApplication> +#include <QBasicTimer> #include <QEvent> #include <QEventLoop> #include <QMouseEvent> @@ -50,6 +51,7 @@ class EventSender : public QObject { public: EventSender(QWebPage* parent); virtual bool eventFilter(QObject* watched, QEvent* event); + void resetClickCount() { m_clickCount = 0; } public slots: void mouseDown(int button = 0); @@ -73,18 +75,24 @@ public slots: void clearTouchPoints(); void releaseTouchPoint(int index); +protected: + void timerEvent(QTimerEvent*); + private: void sendTouchEvent(QEvent::Type); void sendOrQueueEvent(QEvent*); void replaySavedEvents(bool flush); QPoint m_mousePos; + QPoint m_clickPos; Qt::MouseButtons m_mouseButtons; QWebPage* m_page; - int m_timeLeap; + int m_clickCount; + int m_currentButton; bool m_mouseButtonPressed; bool m_drag; QEventLoop* m_eventLoop; QWebFrame* frameUnderMouse() const; + QBasicTimer m_clickTimer; #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0) QList<QTouchEvent::TouchPoint> m_touchPoints; Qt::KeyboardModifiers m_touchModifiers; diff --git a/WebKitTools/DumpRenderTree/qt/GCControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/GCControllerQt.cpp index 9cc3aa7..ba7e2c3 100644 --- a/WebKitTools/DumpRenderTree/qt/GCControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/GCControllerQt.cpp @@ -29,14 +29,10 @@ #include "config.h" #include "GCControllerQt.h" +#include "../../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" #include <qwebpage.h> -extern int qt_drt_javaScriptObjectsCount(); -extern void qt_drt_garbageCollector_collect(); - -extern void qt_drt_garbageCollector_collectOnAlternateThread(bool waitUntilDone); - GCController::GCController(QWebPage* parent) : QObject(parent) { @@ -44,15 +40,15 @@ GCController::GCController(QWebPage* parent) void GCController::collect() const { - qt_drt_garbageCollector_collect(); + DumpRenderTreeSupportQt::garbageCollectorCollect(); } void GCController::collectOnAlternateThread(bool waitUntilDone) const { - qt_drt_garbageCollector_collectOnAlternateThread(waitUntilDone); + DumpRenderTreeSupportQt::garbageCollectorCollectOnAlternateThread(waitUntilDone); } size_t GCController::getJSObjectCount() const { - return qt_drt_javaScriptObjectsCount(); + return DumpRenderTreeSupportQt::javaScriptObjectsCount(); } diff --git a/WebKitTools/DumpRenderTree/qt/GCControllerQt.h b/WebKitTools/DumpRenderTree/qt/GCControllerQt.h index 8f5b432..ed2a858 100644 --- a/WebKitTools/DumpRenderTree/qt/GCControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/GCControllerQt.h @@ -32,6 +32,7 @@ #include <QObject> class QWebPage; +class DumpRenderTreeSupportQt; class GCController : public QObject { @@ -43,6 +44,7 @@ public slots: void collect() const; void collectOnAlternateThread(bool waitUntilDone) const; size_t getJSObjectCount() const; + }; #endif diff --git a/WebKitTools/DumpRenderTree/qt/ImageDiff.pro b/WebKitTools/DumpRenderTree/qt/ImageDiff.pro index 636835a..74fabf8 100644 --- a/WebKitTools/DumpRenderTree/qt/ImageDiff.pro +++ b/WebKitTools/DumpRenderTree/qt/ImageDiff.pro @@ -1,9 +1,10 @@ TARGET = ImageDiff CONFIG -= app_bundle +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. include(../../../WebKit.pri) INCLUDEPATH += ../../../JavaScriptCore -DESTDIR = ../../../bin +DESTDIR = $$OUTPUT_DIR/bin QT = core gui diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index a26bc3d..b95fe23 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -28,6 +28,7 @@ */ #include "config.h" #include "LayoutTestControllerQt.h" +#include "../../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" #include "DumpRenderTreeQt.h" #include "WorkQueue.h" @@ -36,32 +37,23 @@ #include <QLocale> #include <qwebsettings.h> +extern void qt_wrt_setViewMode(QWebPage* page, const QString& mode); extern void qt_dump_editing_callbacks(bool b); extern void qt_dump_frame_loader(bool b); extern void qt_dump_resource_load_callbacks(bool b); -extern void qt_drt_setFrameSetFlatteningEnabled(QWebPage*, bool); -extern void qt_drt_setJavaScriptProfilingEnabled(QWebFrame*, bool enabled); -extern void qt_drt_setTimelineProfilingEnabled(QWebPage*, bool enabled); -extern bool qt_drt_pauseAnimation(QWebFrame*, const QString& name, double time, const QString& elementId); -extern bool qt_drt_pauseTransitionOfProperty(QWebFrame*, const QString& name, double time, const QString& elementId); -extern bool qt_drt_pauseSVGAnimation(QWebFrame*, const QString& animationId, double time, const QString& elementId); -extern int qt_drt_numberOfActiveAnimations(QWebFrame*); -extern void qt_drt_setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme); - -extern void qt_drt_whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); -extern QString qt_drt_counterValueForElementById(QWebFrame* qFrame, const QString& id); -extern int qt_drt_workerThreadCount(); -extern int qt_drt_pageNumberForElementById(QWebFrame* qFrame, const QString& id, float width, float height); -extern int qt_drt_numberOfPages(QWebFrame* qFrame, float width, float height); -extern void qt_drt_webinspector_executeScript(QWebPage* page, long callId, const QString& script); -extern void qt_drt_webinspector_show(QWebPage *page); -extern void qt_drt_webinspector_close(QWebPage *page); +extern void qt_set_will_send_request_returns_null_on_redirect(bool b); +extern void qt_set_will_send_request_returns_null(bool b); +extern void qt_set_will_send_request_clear_headers(const QStringList& headers); + +extern void qt_dump_notification(bool b); LayoutTestController::LayoutTestController(WebCore::DumpRenderTree* drt) : QObject() , m_drt(drt) { + qRegisterMetaType<QWebElement>("QWebElement"); reset(); + qt_dump_notification(true); } void LayoutTestController::reset() @@ -85,6 +77,9 @@ void LayoutTestController::reset() qt_dump_editing_callbacks(false); qt_dump_frame_loader(false); qt_dump_resource_load_callbacks(false); + qt_set_will_send_request_returns_null_on_redirect(false); + qt_set_will_send_request_returns_null(false); + qt_set_will_send_request_clear_headers(QStringList()); emit hidePage(); } @@ -136,12 +131,17 @@ void LayoutTestController::waitUntilDone() { //qDebug() << ">>>>waitForDone"; m_waitForDone = true; - m_timeoutTimer.start(15000, this); + m_timeoutTimer.start(30000, this); } QString LayoutTestController::counterValueForElementById(const QString& id) { - return qt_drt_counterValueForElementById(m_drt->webPage()->mainFrame(), id); + return DumpRenderTreeSupportQt::counterValueForElementById(m_drt->webPage()->mainFrame(), id); +} + +void LayoutTestController::setViewModeMediaFeature(const QString& mode) +{ + qt_wrt_setViewMode(m_drt->webPage(), mode); } int LayoutTestController::webHistoryItemCount() @@ -188,6 +188,17 @@ int LayoutTestController::windowCount() return m_drt->windowCount(); } +void LayoutTestController::grantDesktopNotificationPermission(const QString& origin) +{ + // FIXME: Implement for notification security +} + +bool LayoutTestController::checkDesktopNotificationPermission(const QString& origin) +{ + // FIXME: Implement for notification security + return true; +} + void LayoutTestController::display() { emit showPage(); @@ -220,6 +231,21 @@ void LayoutTestController::dumpResourceLoadCallbacks() qt_dump_resource_load_callbacks(true); } +void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(bool enabled) +{ + qt_set_will_send_request_returns_null_on_redirect(enabled); +} + +void LayoutTestController::setWillSendRequestReturnsNull(bool enabled) +{ + qt_set_will_send_request_returns_null(enabled); +} + +void LayoutTestController::setWillSendRequestClearHeader(const QStringList& headers) +{ + qt_set_will_send_request_clear_headers(headers); +} + void LayoutTestController::queueBackNavigation(int howFarBackward) { //qDebug() << ">>>queueBackNavigation" << howFarBackward; @@ -290,27 +316,36 @@ QString LayoutTestController::decodeHostName(const QString& host) return decoded; } +void LayoutTestController::setMediaType(const QString& type) +{ + DumpRenderTreeSupportQt::setMediaType(m_drt->webPage()->mainFrame(), type); +} void LayoutTestController::closeWebInspector() { - qt_drt_webinspector_close(m_drt->webPage()); + DumpRenderTreeSupportQt::webInspectorClose(m_drt->webPage()); m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false); } +void LayoutTestController::setDeveloperExtrasEnabled(bool enabled) +{ + m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enabled); +} + void LayoutTestController::showWebInspector() { m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - qt_drt_webinspector_show(m_drt->webPage()); + DumpRenderTreeSupportQt::webInspectorShow(m_drt->webPage()); } void LayoutTestController::evaluateInWebInspector(long callId, const QString& script) { - qt_drt_webinspector_executeScript(m_drt->webPage(), callId, script); + DumpRenderTreeSupportQt::webInspectorExecuteScript(m_drt->webPage(), callId, script); } -void LayoutTestController::setFrameSetFlatteningEnabled(bool enabled) +void LayoutTestController::setFrameFlatteningEnabled(bool enabled) { - qt_drt_setFrameSetFlatteningEnabled(m_drt->webPage(), enabled); + DumpRenderTreeSupportQt::setFrameFlatteningEnabled(m_drt->webPage(), enabled); } void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled) @@ -323,15 +358,20 @@ void LayoutTestController::setAllowFileAccessFromFileURLs(bool enabled) m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, enabled); } +void LayoutTestController::setAppCacheMaximumSize(unsigned long long quota) +{ + m_drt->webPage()->settings()->setOfflineWebApplicationCacheQuota(quota); +} + void LayoutTestController::setJavaScriptProfilingEnabled(bool enable) { - m_topLoadingFrame->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - qt_drt_setJavaScriptProfilingEnabled(m_topLoadingFrame, enable); + setDeveloperExtrasEnabled(enable); + DumpRenderTreeSupportQt::setJavaScriptProfilingEnabled(m_topLoadingFrame, enable); } void LayoutTestController::setTimelineProfilingEnabled(bool enable) { - qt_drt_setTimelineProfilingEnabled(m_drt->webPage(), enable); + DumpRenderTreeSupportQt::setTimelineProfilingEnabled(m_drt->webPage(), enable); } void LayoutTestController::setFixedContentsSize(int width, int height) @@ -344,6 +384,11 @@ void LayoutTestController::setPrivateBrowsingEnabled(bool enable) m_drt->webPage()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable); } +void LayoutTestController::setSpatialNavigationEnabled(bool enable) +{ + m_drt->webPage()->settings()->setAttribute(QWebSettings::SpatialNavigationEnabled, enable); +} + void LayoutTestController::setPopupBlockingEnabled(bool enable) { m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable); @@ -367,12 +412,12 @@ void LayoutTestController::setMainFrameIsFirstResponder(bool isFirst) void LayoutTestController::setXSSAuditorEnabled(bool enable) { - // Set XSSAuditorEnabled globally so that windows created by the test inherit it too. + // Set XSSAuditingEnabled globally so that windows created by the test inherit it too. // resetSettings() will call this to reset the page and global setting to false again. // Needed by http/tests/security/xssAuditor/link-opens-new-window.html QWebSettings* globalSettings = QWebSettings::globalSettings(); - globalSettings->setAttribute(QWebSettings::XSSAuditorEnabled, enable); - m_drt->webPage()->settings()->setAttribute(QWebSettings::XSSAuditorEnabled, enable); + globalSettings->setAttribute(QWebSettings::XSSAuditingEnabled, enable); + m_drt->webPage()->settings()->setAttribute(QWebSettings::XSSAuditingEnabled, enable); } bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString& animationName, @@ -381,7 +426,7 @@ bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString& an { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return qt_drt_pauseAnimation(frame, animationName, time, elementId); + return DumpRenderTreeSupportQt::pauseAnimation(frame, animationName, time, elementId); } bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString& propertyName, @@ -390,7 +435,7 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString& p { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return qt_drt_pauseTransitionOfProperty(frame, propertyName, time, elementId); + return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame, propertyName, time, elementId); } bool LayoutTestController::sampleSVGAnimationForElementAtTime(const QString& animationId, @@ -399,14 +444,14 @@ bool LayoutTestController::sampleSVGAnimationForElementAtTime(const QString& ani { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return qt_drt_pauseSVGAnimation(frame, animationId, time, elementId); + return DumpRenderTreeSupportQt::pauseSVGAnimation(frame, animationId, time, elementId); } unsigned LayoutTestController::numberOfActiveAnimations() const { QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); - return qt_drt_numberOfActiveAnimations(frame); + return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame); } void LayoutTestController::disableImageLoading() @@ -432,9 +477,14 @@ void LayoutTestController::clearAllDatabases() QWebDatabase::removeAllDatabases(); } -void LayoutTestController::whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) +void LayoutTestController::addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) +{ + DumpRenderTreeSupportQt::whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); +} + +void LayoutTestController::removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) { - qt_drt_whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); + // FIXME: Implement. } void LayoutTestController::waitForPolicyDelegate() @@ -457,6 +507,10 @@ void LayoutTestController::overridePreference(const QString& name, const QVarian settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt()); else if (name == "WebKitUsesPageCachePreferenceKey") QWebSettings::setMaximumPagesInCache(value.toInt()); + else if (name == "WebKitEnableCaretBrowsing") + setCaretBrowsingEnabled(value.toBool()); + else if (name == "WebKitPluginsEnabled") + settings->setAttribute(QWebSettings::PluginsEnabled, value.toBool()); else printf("ERROR: LayoutTestController::overridePreference() does not support the '%s' preference\n", name.toLatin1().data()); @@ -467,6 +521,11 @@ void LayoutTestController::setUserStyleSheetLocation(const QString& url) m_userStyleSheetLocation = QUrl(url); } +void LayoutTestController::setCaretBrowsingEnabled(bool value) +{ + DumpRenderTreeSupportQt::setCaretBrowsingEnabled(m_drt->webPage(), value); +} + void LayoutTestController::setUserStyleSheetEnabled(bool enabled) { if (enabled) @@ -477,12 +536,12 @@ void LayoutTestController::setUserStyleSheetEnabled(bool enabled) void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme) { - qt_drt_setDomainRelaxationForbiddenForURLScheme(forbidden, scheme); + DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme); } int LayoutTestController::workerThreadCount() { - return qt_drt_workerThreadCount(); + return DumpRenderTreeSupportQt::workerThreadCount(); } int LayoutTestController::pageNumberForElementById(const QString& id, float width, float height) @@ -493,10 +552,74 @@ int LayoutTestController::pageNumberForElementById(const QString& id, float widt height = m_drt->webPage()->viewportSize().height(); } - return qt_drt_pageNumberForElementById(m_drt->webPage()->mainFrame(), id, width, height); + return DumpRenderTreeSupportQt::pageNumberForElementById(m_drt->webPage()->mainFrame(), id, width, height); } int LayoutTestController::numberOfPages(float width, float height) { - return qt_drt_numberOfPages(m_drt->webPage()->mainFrame(), width, height); + return DumpRenderTreeSupportQt::numberOfPages(m_drt->webPage()->mainFrame(), width, height); +} + +bool LayoutTestController::callShouldCloseOnWebView() +{ + // FIXME: Implement for testing fix for https://bugs.webkit.org/show_bug.cgi?id=27481 + return false; +} + +void LayoutTestController::setScrollbarPolicy(const QString& orientation, const QString& policy) +{ + Qt::Orientation o; + Qt::ScrollBarPolicy p; + + if (orientation == "vertical") + o = Qt::Vertical; + else if (orientation == "horizontal") + o = Qt::Horizontal; + else + return; + + if (policy == "on") + p = Qt::ScrollBarAlwaysOn; + else if (policy == "auto") + p = Qt::ScrollBarAsNeeded; + else if (policy == "off") + p = Qt::ScrollBarAlwaysOff; + else + return; + + m_drt->webPage()->mainFrame()->setScrollBarPolicy(o, p); +} + +void LayoutTestController::setSmartInsertDeleteEnabled(bool enable) +{ + DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(m_drt->webPage(), enable); } + +void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool enable) +{ + DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(m_drt->webPage(), enable); +} + +void LayoutTestController::execCommand(const QString& name, const QString& value) +{ + DumpRenderTreeSupportQt::executeCoreCommandByName(m_drt->webPage(), name, value); +} + +bool LayoutTestController::isCommandEnabled(const QString& name) const +{ + return DumpRenderTreeSupportQt::isCommandEnabled(m_drt->webPage(), name); +} + +QString LayoutTestController::markerTextForListItem(const QWebElement& listItem) +{ + return DumpRenderTreeSupportQt::markerTextForListItem(listItem); +} + +void LayoutTestController::authenticateSession(const QString&, const QString&, const QString&) +{ + // FIXME: If there is a concept per-session (per-process) credential storage, the credentials should be added to it for later use. +} + + +const unsigned LayoutTestController::maxViewWidth = 800; +const unsigned LayoutTestController::maxViewHeight = 600; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index d73794e..df645e1 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -40,12 +40,14 @@ #include <QVariant> #include <qwebdatabase.h> +#include <qwebelement.h> #include <qwebframe.h> #include <qwebhistory.h> #include <qwebpage.h> #include <qwebsecurityorigin.h> class QWebFrame; +class DumpRenderTreeSupportQt; namespace WebCore { class DumpRenderTree; } @@ -70,6 +72,9 @@ public: void reset(); + static const unsigned int maxViewWidth; + static const unsigned int maxViewHeight; + protected: void timerEvent(QTimerEvent*); @@ -98,6 +103,9 @@ public slots: void dumpEditingCallbacks(); void dumpFrameLoadCallbacks(); void dumpResourceLoadCallbacks(); + void setWillSendRequestReturnsNullOnRedirect(bool enabled); + void setWillSendRequestReturnsNull(bool enabled); + void setWillSendRequestClearHeader(const QStringList& headers); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); void queueLoad(const QString& url, const QString& target = QString()); @@ -107,6 +115,8 @@ public slots: void provisionalLoad(); void setCloseRemainingWindowsWhenComplete(bool = false) {} int windowCount(); + void grantDesktopNotificationPermission(const QString& origin); + bool checkDesktopNotificationPermission(const QString& origin); void display(); void clearBackForwardList(); QString pathToLocalResource(const QString& url); @@ -114,23 +124,33 @@ public slots: QString encodeHostName(const QString& host); QString decodeHostName(const QString& host); void dumpSelectionRect() const {} + void setDeveloperExtrasEnabled(bool); void showWebInspector(); void closeWebInspector(); void evaluateInWebInspector(long callId, const QString& script); - void setFrameSetFlatteningEnabled(bool enable); + void setMediaType(const QString& type); + void setFrameFlatteningEnabled(bool enable); void setAllowUniversalAccessFromFileURLs(bool enable); void setAllowFileAccessFromFileURLs(bool enable); + void setAppCacheMaximumSize(unsigned long long quota); void setJavaScriptProfilingEnabled(bool enable); void setTimelineProfilingEnabled(bool enable); void setFixedContentsSize(int width, int height); void setPrivateBrowsingEnabled(bool enable); + void setSpatialNavigationEnabled(bool enabled); void setPopupBlockingEnabled(bool enable); void setPOSIXLocale(const QString& locale); void resetLoadFinished() { m_loadFinished = false; } void setWindowIsKey(bool isKey); void setMainFrameIsFirstResponder(bool isFirst); void setXSSAuditorEnabled(bool enable); + void setCaretBrowsingEnabled(bool enable); + void setViewModeMediaFeature(const QString& mode); + void setSmartInsertDeleteEnabled(bool enable); + void setSelectTrailingWhitespaceEnabled(bool enable); + void execCommand(const QString& name, const QString& value = QString()); + bool isCommandEnabled(const QString& name) const; bool pauseAnimationAtTimeOnElementWithId(const QString& animationName, double time, const QString& elementId); bool pauseTransitionAtTimeOnElementWithId(const QString& propertyName, double time, const QString& elementId); @@ -138,7 +158,8 @@ public slots: unsigned numberOfActiveAnimations() const; - void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); + void addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); + void removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); void dispatchPendingLoadRequests(); void disableImageLoading(); @@ -153,7 +174,19 @@ public slots: void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme); int workerThreadCount(); int pageNumberForElementById(const QString& id, float width = 0, float height = 0); - int numberOfPages(float width, float height); + int numberOfPages(float width = maxViewWidth, float height = maxViewHeight); + bool callShouldCloseOnWebView(); + + /* + Policy values: 'on', 'auto' or 'off'. + Orientation values: 'vertical' or 'horizontal'. + */ + void setScrollbarPolicy(const QString& orientation, const QString& policy); + + QString markerTextForListItem(const QWebElement& listItem); + + // Simulate a request an embedding application could make, populating per-session credential storage. + void authenticateSession(const QString& url, const QString& username, const QString& password); private slots: void processWork(); diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro index 7b8162b..9b19231 100644 --- a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro +++ b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro @@ -2,6 +2,7 @@ TEMPLATE = lib TARGET = TestNetscapePlugIn VPATH = ../../unix/TestNetscapePlugin ../../TestNetscapePlugIn.subproj +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../.. include(../../../../WebKit.pri) DESTDIR = $$OUTPUT_DIR/lib/plugins diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp index 7d72982..7d1c08c 100644 --- a/WebKitTools/DumpRenderTree/qt/main.cpp +++ b/WebKitTools/DumpRenderTree/qt/main.cpp @@ -93,7 +93,7 @@ QString get_backtrace() { return s; } -#ifndef Q_OS_WIN +#if HAVE(SIGNAL_H) static NO_RETURN void crashHandler(int sig) { fprintf(stderr, "%s\n", strsignal(sig)); @@ -114,10 +114,7 @@ int main(int argc, char* argv[]) WebCore::DumpRenderTree::initializeFonts(); #endif -#if QT_VERSION >= 0x040500 QApplication::setGraphicsSystem("raster"); -#endif - QApplication::setStyle(new QWindowsStyle); QFont f("Sans Serif"); @@ -132,7 +129,7 @@ int main(int argc, char* argv[]) QX11Info::setAppDpiX(0, 96); #endif -#ifndef Q_OS_WIN +#if HAVE(SIGNAL_H) signal(SIGILL, crashHandler); /* 4: illegal instruction (not reset when caught) */ signal(SIGTRAP, crashHandler); /* 5: trace trap (not reset when caught) */ signal(SIGFPE, crashHandler); /* 8: floating point exception */ |