DumpRenderTreeSupportQt.h revision 65f03d4f644ce73618e5f4f50dd694b26f55ae12
1/* 2 Copyright (C) 2010 Robert Hogan <robert@roberthogan.net> 3 Copyright (C) 2008,2009,2010 Nokia Corporation and/or its subsidiary(-ies) 4 Copyright (C) 2007 Staikos Computing Services Inc. 5 Copyright (C) 2007 Apple Inc. 6 7 This library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Library General Public 9 License as published by the Free Software Foundation; either 10 version 2 of the License, or (at your option) any later version. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Library General Public License for more details. 16 17 You should have received a copy of the GNU Library General Public License 18 along with this library; see the file COPYING.LIB. If not, write to 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 Boston, MA 02110-1301, USA. 21*/ 22 23#ifndef DumpRenderTreeSupportQt_h 24#define DumpRenderTreeSupportQt_h 25 26#include "qwebkitglobal.h" 27#include <QVariant> 28 29namespace WebCore { 30class Text; 31class Node; 32} 33 34 35#if defined(WTF_USE_V8) && WTF_USE_V8 36namespace V8 { 37namespace Bindings { 38class QtDRTNodeRuntime; 39} 40} 41#else 42namespace JSC { 43namespace Bindings { 44class QtDRTNodeRuntime; 45} 46} 47#endif 48 49class QWebElement; 50class QWebFrame; 51class QWebPage; 52class QWebHistoryItem; 53class QWebScriptWorld; 54 55extern QMap<int, QWebScriptWorld*> m_worldMap; 56 57// Used to pass WebCore::Node's to layout tests using LayoutTestController 58class QWEBKIT_EXPORT QDRTNode { 59public: 60 QDRTNode(); 61 ~QDRTNode(); 62 63private: 64 explicit QDRTNode(WebCore::Node*); 65 66 friend class DumpRenderTreeSupportQt; 67 68#if defined(WTF_USE_V8) && WTF_USE_V8 69 friend class V8::Bindings::QtDRTNodeRuntime; 70#else 71 friend class JSC::Bindings::QtDRTNodeRuntime; 72#endif 73 74 WebCore::Node* m_node; 75}; 76 77Q_DECLARE_METATYPE(QDRTNode) 78 79class QWEBKIT_EXPORT DumpRenderTreeSupportQt { 80 81public: 82 83 DumpRenderTreeSupportQt(); 84 ~DumpRenderTreeSupportQt(); 85 86 87 static void executeCoreCommandByName(QWebPage* page, const QString& name, const QString& value); 88 static bool isCommandEnabled(QWebPage* page, const QString& name); 89 static bool findString(QWebPage* page, const QString& string, const QStringList& optionArray); 90 static void setSmartInsertDeleteEnabled(QWebPage* page, bool enabled); 91 static void setSelectTrailingWhitespaceEnabled(QWebPage* page, bool enabled); 92 static QVariantList selectedRange(QWebPage* page); 93 static QVariantList firstRectForCharacterRange(QWebPage* page, int location, int length); 94 95 static bool pauseAnimation(QWebFrame*, const QString& name, double time, const QString& elementId); 96 static bool pauseTransitionOfProperty(QWebFrame*, const QString& name, double time, const QString& elementId); 97 static bool pauseSVGAnimation(QWebFrame*, const QString& animationId, double time, const QString& elementId); 98 static void suspendActiveDOMObjects(QWebFrame* frame); 99 static void resumeActiveDOMObjects(QWebFrame* frame); 100 101 static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme); 102 static void setFrameFlatteningEnabled(QWebPage*, bool); 103 static void setCaretBrowsingEnabled(QWebPage* page, bool value); 104 static void setMediaType(QWebFrame* qframe, const QString& type); 105 static void setDumpRenderTreeModeEnabled(bool b); 106 107 static void garbageCollectorCollect(); 108 static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone); 109 static void setJavaScriptProfilingEnabled(QWebFrame*, bool enabled); 110 static int javaScriptObjectsCount(); 111 static void clearScriptWorlds(); 112 static void evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script); 113 114 static void setTimelineProfilingEnabled(QWebPage*, bool enabled); 115 static void webInspectorExecuteScript(QWebPage* page, long callId, const QString& script); 116 static void webInspectorShow(QWebPage* page); 117 static void webInspectorClose(QWebPage* page); 118 119 static QString webPageGroupName(QWebPage *page); 120 static QString counterValueForElementById(QWebFrame* frame, const QString& id); 121 static void webPageSetGroupName(QWebPage* page, const QString& groupName); 122 static void clearFrameName(QWebFrame* frame); 123 static void overwritePluginDirectories(); 124 static int numberOfActiveAnimations(QWebFrame*); 125 static void suspendAnimations(QWebFrame*); 126 static void resumeAnimations(QWebFrame*); 127 static int numberOfPages(QWebFrame* frame, float width, float height); 128 static int pageNumberForElementById(QWebFrame* frame, const QString& id, float width, float height); 129 static bool hasDocumentElement(QWebFrame* frame); 130 static bool elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId); 131 static void setEditingBehavior(QWebPage* page, const QString& editingBehavior); 132 133 static void clearAllApplicationCaches(); 134 135 static void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); 136 static void removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); 137 static void resetOriginAccessWhiteLists(); 138 139 static void activeMockDeviceOrientationClient(bool b); 140 static void removeMockDeviceOrientation(); 141 static void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); 142 143 static void setMockGeolocationPosition(double latitude, double longitude, double accuracy); 144 static void setMockGeolocationError(int errorCode, const QString& message); 145 146 static int workerThreadCount(); 147 148 static QString markerTextForListItem(const QWebElement& listItem); 149 static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element); 150 static QString plainText(const QVariant& rng); 151 152 static void dumpFrameLoader(bool b); 153 static void dumpUserGestureInFrameLoader(bool b); 154 static void dumpResourceLoadCallbacks(bool b); 155 static void dumpResourceResponseMIMETypes(bool b); 156 static void dumpResourceLoadCallbacksPath(const QString& path); 157 static void setWillSendRequestReturnsNullOnRedirect(bool b); 158 static void setWillSendRequestReturnsNull(bool b); 159 static void setWillSendRequestClearHeaders(const QStringList& headers); 160 static void dumpHistoryCallbacks(bool b); 161 static void dumpVisitedLinksCallbacks(bool b); 162 163 static void setDeferMainResourceDataLoad(bool b); 164 165 static void dumpEditingCallbacks(bool b); 166 static void dumpSetAcceptsEditing(bool b); 167 168 static void dumpNotification(bool b); 169 170 static QMap<QString, QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem); 171 static bool isTargetItem(const QWebHistoryItem& historyItem); 172 static QString historyItemTarget(const QWebHistoryItem& historyItem); 173 174 static bool shouldClose(QWebFrame* frame); 175 176 static void setCustomPolicyDelegate(bool enabled, bool permissive); 177 178 static bool isPageBoxVisible(QWebFrame* frame, int pageIndex); 179 180 static QString pageSizeAndMarginsInPixels(QWebFrame* frame, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft); 181 static QString pageProperty(QWebFrame* frame, const QString& propertyName, int pageNumber); 182 static void addUserStyleSheet(QWebPage* page, const QString& sourceCode); 183 static void simulateDesktopNotificationClick(const QString& title); 184 static QString viewportAsText(QWebPage*, const QSize&); 185 186 static QVariantList nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping); 187}; 188 189#endif 190