diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
18 files changed, 231 insertions, 100 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index 02c77a4..edab29e 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -555,10 +555,65 @@ static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber) { pageNumber = 0; - if (argumentCount != 1) + switch (argumentCount) { + case 1: + pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); + if (*exception) + return false; + // Fall through. + case 0: + return true; + default: + return false; + } +} + +static bool parsePageNumberSizeMarings(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber, int& width, int& height, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) +{ + pageNumber = 0; + width = height = 0; + marginTop = marginRight = marginBottom = marginLeft = 0; + + switch (argumentCount) { + case 7: + marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception)); + if (*exception) + return false; + // Fall through. + case 6: + marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception)); + if (*exception) + return false; + // Fall through. + case 5: + marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception)); + if (*exception) + return false; + // Fall through. + case 4: + marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception)); + if (*exception) + return false; + // Fall through. + case 3: + height = static_cast<int>(JSValueToNumber(context, arguments[2], exception)); + if (*exception) + return false; + // Fall through. + case 2: + width = static_cast<int>(JSValueToNumber(context, arguments[1], exception)); + if (*exception) + return false; + // Fall through. + case 1: + pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); + if (*exception) + return false; + // Fall through. + return true; + default: return false; - pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); - return !*exception; + } } static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -612,24 +667,16 @@ static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef fun return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber)); } -static JSValueRef pageAreaRectInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - int pageNumber = 0; - if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber)) - return JSValueMakeUndefined(context); - - LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - return JSValueMakeString(context, controller->pageAreaRectInPixels(pageNumber).get()); -} - -static JSValueRef preferredPageSizeInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int pageNumber = 0; - if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber)) + int width = 0, height = 0; + int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0; + if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - return JSValueMakeString(context, controller->preferredPageSizeInPixels(pageNumber).get()); + return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get()); } static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -1513,14 +1560,12 @@ static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef f } -#if PLATFORM(MAC) static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); controller->abortModal(); return JSValueMakeUndefined(context); } -#endif static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { @@ -1648,9 +1693,7 @@ JSStaticValue* LayoutTestController::staticValues() JSStaticFunction* LayoutTestController::staticFunctions() { static JSStaticFunction staticFunctions[] = { -#if PLATFORM(MAC) { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -#endif { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1699,12 +1742,11 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "pageAreaRectInPixels", pageAreaRectInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "preferredPageSizeInPixels", preferredPageSizeInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index 6af2c57..be79473 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -64,9 +64,8 @@ public: void overridePreference(JSStringRef key, JSStringRef value); int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels); JSRetainPtr<JSStringRef> pageProperty(const char* propertyName, int pageNumber) const; + JSRetainPtr<JSStringRef> pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const; bool isPageBoxVisible(int pageNumber) const; - JSRetainPtr<JSStringRef> pageAreaRectInPixels(int pageNumber) const; - JSRetainPtr<JSStringRef> preferredPageSizeInPixels(int pageNumber) const; JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); @@ -260,10 +259,7 @@ public: void setWebViewEditable(bool); - -#if PLATFORM(MAC) void abortModal(); -#endif // The following API test functions should probably be moved to platform-specific // unit tests outside of DRT once they exist. diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 89e16e0..9ba6421 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -165,6 +165,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission); bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); + bindMethod("abortModal", &LayoutTestController::abortModal); // The fallback method is called when an unknown method is invoked. bindFallbackMethod(&LayoutTestController::fallbackMethod); @@ -1312,3 +1313,8 @@ void LayoutTestController::setMockGeolocationError(const CppArgumentList& argume return; WebGeolocationServiceMock::setMockGeolocationError(arguments[0].toInt32(), cppVariantToWebString(arguments[1])); } + +void LayoutTestController::abortModal(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); +} diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index 0e66087..22741d5 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -286,6 +286,9 @@ public: void setMockGeolocationPosition(const CppArgumentList&, CppVariant*); void setMockGeolocationError(const CppArgumentList&, CppVariant*); + // Empty stub method to keep parity with object model exposed by global LayoutTestController. + void abortModal(const CppArgumentList&, CppVariant*); + public: // The following methods are not exposed to JavaScript. void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); } diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 610248a..52f1e7d 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -586,7 +586,7 @@ WebViewHost* TestShell::createWebView() WebViewHost* TestShell::createNewWindow(const WebURL& url) { WebViewHost* host = new WebViewHost(this); - WebView* view = WebView::create(host); + WebView* view = WebView::create(host, 0); host->setWebWidget(view); resetWebSettings(*view); view->initializeMainFrame(host); diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index d186ffa..fbdbd23 100644 --- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "AccessibilityUIElement.h" +#include "GOwnPtr.h" #include "GRefPtr.h" #include <JavaScriptCore/JSStringRef.h> @@ -198,7 +199,10 @@ JSStringRef AccessibilityUIElement::role() if (!role) return JSStringCreateWithCharacters(0, 0); - return JSStringCreateWithUTF8CString(atk_role_get_name(role)); + const gchar* roleName = atk_role_get_name(role); + GOwnPtr<gchar> axRole(g_strdup_printf("AXRole: %s", roleName)); + + return JSStringCreateWithUTF8CString(axRole.get()); } JSStringRef AccessibilityUIElement::subrole() @@ -218,7 +222,9 @@ JSStringRef AccessibilityUIElement::title() if (!name) return JSStringCreateWithCharacters(0, 0); - return JSStringCreateWithUTF8CString(name); + GOwnPtr<gchar> axTitle(g_strdup_printf("AXTitle: %s", name)); + + return JSStringCreateWithUTF8CString(axTitle.get()); } JSStringRef AccessibilityUIElement::description() @@ -228,7 +234,9 @@ JSStringRef AccessibilityUIElement::description() if (!description) return JSStringCreateWithCharacters(0, 0); - return JSStringCreateWithUTF8CString(description); + GOwnPtr<gchar> axDesc(g_strdup_printf("AXDescription: %s", description)); + + return JSStringCreateWithUTF8CString(axDesc.get()); } JSStringRef AccessibilityUIElement::stringValue() diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp index 7836ff0..4936fe5 100644 --- a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp @@ -96,6 +96,14 @@ static void gdk_window_get_root_coords(GdkWindow* window, gint x, gint y, gint* } #endif +#if !GTK_CHECK_VERSION(2, 14, 0) +static GdkWindow* gtk_widget_get_window(GtkWidget* widget) +{ + g_return_val_if_fail(GTK_IS_WIDGET(widget), 0); + return widget->window; +} +#endif + static JSValueRef getDragModeCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { return JSValueMakeBoolean(context, dragMode); @@ -139,13 +147,13 @@ bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber) event->button.button = gdkButtonNumber; event->button.x = lastMousePositionX; event->button.y = lastMousePositionY; - event->button.window = GTK_WIDGET(view)->window; + event->button.window = gtk_widget_get_window(GTK_WIDGET(view)); event->button.device = gdk_device_get_core_pointer(); event->button.state = getStateFlags(); event->button.time = GDK_CURRENT_TIME; int xRoot, yRoot; - gdk_window_get_root_coords(GTK_WIDGET(view)->window, lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); + gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(view)), lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); event->button.x_root = xRoot; event->button.y_root = yRoot; @@ -266,12 +274,12 @@ static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function event.motion.y = lastMousePositionY; event.motion.time = GDK_CURRENT_TIME; - event.motion.window = GTK_WIDGET(view)->window; + event.motion.window = gtk_widget_get_window(GTK_WIDGET(view)); event.motion.device = gdk_device_get_core_pointer(); event.motion.state = getStateFlags(); int xRoot, yRoot; - gdk_window_get_root_coords(GTK_WIDGET(view)->window, lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); + gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(view)), lastMousePositionX, lastMousePositionY, &xRoot, &yRoot); event.motion.x_root = xRoot; event.motion.y_root = yRoot; @@ -301,7 +309,7 @@ static JSValueRef mouseWheelToCallback(JSContextRef context, JSObjectRef functio event.scroll.x = lastMousePositionX; event.scroll.y = lastMousePositionY; event.scroll.time = GDK_CURRENT_TIME; - event.scroll.window = GTK_WIDGET(view)->window; + event.scroll.window = gtk_widget_get_window(GTK_WIDGET(view)); if (horizontal < 0) event.scroll.direction = GDK_SCROLL_LEFT; @@ -499,7 +507,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS memset(&event, 0, sizeof(event)); event.key.keyval = gdkKeySym; event.key.state = state; - event.key.window = GTK_WIDGET(view)->window; + event.key.window = gtk_widget_get_window(GTK_WIDGET(view)); // When synthesizing an event, an invalid hardware_keycode value // can cause it to be badly processed by Gtk+. diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 6f8e637..1814933 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -183,13 +183,7 @@ bool LayoutTestController::isPageBoxVisible(int pageNumber) const return false; } -JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const -{ - // FIXME: implement - return JSRetainPtr<JSStringRef>(); -} - -JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const +JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const { // FIXME: implement return JSRetainPtr<JSStringRef>(); @@ -729,3 +723,7 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) if (!strcmp(editingBehavior, "mac")) g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL); } + +void LayoutTestController::abortModal() +{ +} diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index 51ea004..ce02081 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -137,6 +137,7 @@ static int threaded; static int dumpTree = YES; static int forceComplexText; static int useHTML5Parser = YES; +static int useHTML5TreeBuilder = NO; // Temporary, will be removed. static BOOL printSeparators; static RetainPtr<CFStringRef> persistentUserStyleSheetLocation; @@ -456,6 +457,7 @@ static void resetDefaultsToConsistentValues() [preferences setAcceleratedCompositingEnabled:YES]; [preferences setWebGLEnabled:NO]; [preferences setHTML5ParserEnabled:useHTML5Parser]; + [preferences setHTML5TreeBuilderEnabled:useHTML5TreeBuilder]; // Temporary, will be removed. [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain]; @@ -563,6 +565,7 @@ static void initializeGlobalsFromCommandLineOptions(int argc, const char *argv[] {"threaded", no_argument, &threaded, YES}, {"complex-text", no_argument, &forceComplexText, YES}, {"legacy-parser", no_argument, &useHTML5Parser, NO}, + {"html5-treebuilder", no_argument, &useHTML5TreeBuilder, YES}, {NULL, 0, NULL, 0} }; diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index d0599e0..9b044c3 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -223,15 +223,9 @@ bool LayoutTestController::isPageBoxVisible(int pageNumber) const return [mainFrame isPageBoxVisible:pageNumber]; } -JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const +JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const { - JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame pageAreaRectInPixels:pageNumber])); - return propertyValue; -} - -JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const -{ - JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame preferredPageSizeInPixels:pageNumber])); + JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame pageSizeAndMarginsInPixels:pageNumber:width:height:marginTop:marginRight:marginBottom:marginLeft])); return propertyValue; } 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; diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index e0d5731..df96328 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -617,8 +617,14 @@ static bool resolveCygwinPath(const wstring& cygwinPath, wstring& windowsPath) DWORD keyType; DWORD result = ::SHGetValueW(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/"), TEXT("native"), &keyType, &rootPath, &rootPathSize); - if (result != ERROR_SUCCESS || keyType != REG_SZ) - return false; + if (result != ERROR_SUCCESS || keyType != REG_SZ) { + // Cygwin 1.7 doesn't store Cygwin's root as a mount point anymore, because mount points are now stored in /etc/fstab. + // However, /etc/fstab doesn't contain any information about where / is located as a Windows path, so we need to use Cygwin's + // new registry key that has the root. + result = ::SHGetValueW(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Cygwin\\setup"), TEXT("rootdir"), &keyType, &rootPath, &rootPathSize); + if (result != ERROR_SUCCESS || keyType != REG_SZ) + return false; + } windowsPath = wstring(rootPath, rootPathSize); @@ -1254,13 +1260,7 @@ bool LayoutTestController::isPageBoxVisible(int pageNumber) const return false; } -JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const -{ - // FIXME: implement - return JSRetainPtr<JSStringRef>(); -} - -JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const +JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const { // FIXME: implement return JSRetainPtr<JSStringRef>(); @@ -1308,3 +1308,7 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) if (behaviorString == "win") preferences->setEditingBehavior(WebKitEditingWinBehavior); } + +void LayoutTestController::abortModal() +{ +} diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index 90ddea8..511eb81 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -452,6 +452,10 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior) // FIXME: Implement } +void LayoutTestController::abortModal() +{ +} + JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const { @@ -463,14 +467,9 @@ bool LayoutTestController::isPageBoxVisible(int pageNumber) const return true; } -JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const +JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const { // FIXME: Implement return 0; } -JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const -{ - // FIXME: Implement - return 0; -} |