WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
       
     3  * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
       
     4  *
       
     5  * Redistribution and use in source and binary forms, with or without
       
     6  * modification, are permitted provided that the following conditions
       
     7  * are met:
       
     8  *
       
     9  * 1.  Redistributions of source code must retain the above copyright
       
    10  *     notice, this list of conditions and the following disclaimer.
       
    11  * 2.  Redistributions in binary form must reproduce the above copyright
       
    12  *     notice, this list of conditions and the following disclaimer in the
       
    13  *     documentation and/or other materials provided with the distribution.
       
    14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
       
    15  *     its contributors may be used to endorse or promote products derived
       
    16  *     from this software without specific prior written permission.
       
    17  *
       
    18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
       
    19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
    20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
       
    21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
       
    22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
       
    23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
       
    24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
       
    25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
       
    27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    28  */
       
    29 
       
    30 #ifndef LayoutTestControllerQt_h
       
    31 #define LayoutTestControllerQt_h
       
    32 
       
    33 #include <QBasicTimer>
       
    34 #include <QObject>
       
    35 #include <QSize>
       
    36 #include <QString>
       
    37 #include <QtDebug>
       
    38 #include <QTimer>
       
    39 #include <QTimerEvent>
       
    40 #include <QVariant>
       
    41 
       
    42 #include <qwebdatabase.h>
       
    43 #include <qwebelement.h>
       
    44 #include <qwebframe.h>
       
    45 #include <qwebhistory.h>
       
    46 #include <qwebpage.h>
       
    47 #include <qwebsecurityorigin.h>
       
    48 
       
    49 class QWebFrame;
       
    50 class DumpRenderTreeSupportQt;
       
    51 namespace WebCore {
       
    52     class DumpRenderTree;
       
    53 }
       
    54 class LayoutTestController : public QObject {
       
    55     Q_OBJECT
       
    56     Q_PROPERTY(int webHistoryItemCount READ webHistoryItemCount)
       
    57     Q_PROPERTY(int workerThreadCount READ workerThreadCount)
       
    58     Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag)
       
    59 public:
       
    60     LayoutTestController(WebCore::DumpRenderTree* drt);
       
    61 
       
    62     bool shouldDumpAsText() const { return m_textDump; }
       
    63     bool shouldDumpBackForwardList() const { return m_dumpBackForwardList; }
       
    64     bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; }
       
    65     bool shouldDumpChildFrameScrollPositions() const { return m_dumpChildFrameScrollPositions; }
       
    66     bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
       
    67     bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
       
    68     bool shouldWaitUntilDone() const { return m_waitForDone; }
       
    69     bool shouldHandleErrorPages() const { return m_handleErrorPages; }
       
    70     bool canOpenWindows() const { return m_canOpenWindows; }
       
    71     bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
       
    72     bool waitForPolicy() const { return m_waitForPolicy; }
       
    73     bool ignoreReqestForPermission() const { return m_ignoreDesktopNotification; }
       
    74 
       
    75     void reset();
       
    76 
       
    77     static const unsigned int maxViewWidth;
       
    78     static const unsigned int maxViewHeight;
       
    79 
       
    80 protected:
       
    81     void timerEvent(QTimerEvent*);
       
    82 
       
    83 signals:
       
    84     void done();
       
    85 
       
    86     void showPage();
       
    87     void hidePage();
       
    88 
       
    89 public slots:
       
    90     void maybeDump(bool ok);
       
    91     void dumpAsText() { m_textDump = true; }
       
    92     void dumpChildFramesAsText() { m_dumpChildrenAsText = true; }
       
    93     void dumpChildFrameScrollPositions() { m_dumpChildFrameScrollPositions = true; }
       
    94     void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
       
    95     void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
       
    96     void setCanOpenWindows() { m_canOpenWindows = true; }
       
    97     void waitUntilDone();
       
    98     QString counterValueForElementById(const QString& id);
       
    99     int webHistoryItemCount();
       
   100     void keepWebHistory();
       
   101     void notifyDone();
       
   102     void dumpBackForwardList() { m_dumpBackForwardList = true; }
       
   103     bool globalFlag() const { return m_globalFlag; }
       
   104     void setGlobalFlag(bool flag) { m_globalFlag = flag; }
       
   105     void handleErrorPages() { m_handleErrorPages = true; }
       
   106     void dumpEditingCallbacks();
       
   107     void dumpFrameLoadCallbacks();
       
   108     void dumpResourceLoadCallbacks();
       
   109     void dumpResourceResponseMIMETypes();
       
   110     void setWillSendRequestReturnsNullOnRedirect(bool enabled);
       
   111     void setWillSendRequestReturnsNull(bool enabled);
       
   112     void setWillSendRequestClearHeader(const QStringList& headers);
       
   113     void queueBackNavigation(int howFarBackward);
       
   114     void queueForwardNavigation(int howFarForward);
       
   115     void queueLoad(const QString& url, const QString& target = QString());
       
   116     void queueLoadHTMLString(const QString& content, const QString& baseURL = QString());
       
   117     void queueReload();
       
   118     void queueLoadingScript(const QString& script);
       
   119     void queueNonLoadingScript(const QString& script);
       
   120     void provisionalLoad();
       
   121     void setCloseRemainingWindowsWhenComplete(bool = false) {}
       
   122     int windowCount();
       
   123     void grantDesktopNotificationPermission(const QString& origin);
       
   124     void ignoreDesktopNotificationPermissionRequests();
       
   125     bool checkDesktopNotificationPermission(const QString& origin);
       
   126     void display();
       
   127     void clearBackForwardList();
       
   128     QString pathToLocalResource(const QString& url);
       
   129     void dumpTitleChanges() { m_dumpTitleChanges = true; }
       
   130     QString encodeHostName(const QString& host);
       
   131     QString decodeHostName(const QString& host);
       
   132     void dumpSelectionRect() const {}
       
   133     void setDeveloperExtrasEnabled(bool);
       
   134     void showWebInspector();
       
   135     void closeWebInspector();
       
   136     void evaluateInWebInspector(long callId, const QString& script);
       
   137 
       
   138     void setMediaType(const QString& type);
       
   139     void setFrameFlatteningEnabled(bool enable);
       
   140     void setAllowUniversalAccessFromFileURLs(bool enable);
       
   141     void setAllowFileAccessFromFileURLs(bool enable);
       
   142     void setAppCacheMaximumSize(unsigned long long quota);
       
   143     void setJavaScriptProfilingEnabled(bool enable);
       
   144     void setTimelineProfilingEnabled(bool enable);
       
   145     void setFixedContentsSize(int width, int height);
       
   146     void setPrivateBrowsingEnabled(bool enable);
       
   147     void setSpatialNavigationEnabled(bool enabled);
       
   148     void setPluginsEnabled(bool flag);
       
   149     void setPopupBlockingEnabled(bool enable);
       
   150     void setPOSIXLocale(const QString& locale);
       
   151     void resetLoadFinished() { m_loadFinished = false; }
       
   152     void setWindowIsKey(bool isKey);
       
   153     void setMainFrameIsFirstResponder(bool isFirst);
       
   154     void setDeferMainResourceDataLoad(bool);
       
   155     void setJavaScriptCanAccessClipboard(bool enable);
       
   156     void setXSSAuditorEnabled(bool enable);
       
   157     void setCaretBrowsingEnabled(bool enable);
       
   158     void setViewModeMediaFeature(const QString& mode);
       
   159     void setSmartInsertDeleteEnabled(bool enable);
       
   160     void setSelectTrailingWhitespaceEnabled(bool enable);
       
   161     void execCommand(const QString& name, const QString& value = QString());
       
   162     bool isCommandEnabled(const QString& name) const;
       
   163 
       
   164     bool pauseAnimationAtTimeOnElementWithId(const QString& animationName, double time, const QString& elementId);
       
   165     bool pauseTransitionAtTimeOnElementWithId(const QString& propertyName, double time, const QString& elementId);
       
   166     bool sampleSVGAnimationForElementAtTime(const QString& animationId, double time, const QString& elementId);
       
   167     bool elementDoesAutoCompleteForElementWithId(const QString& elementId);
       
   168 
       
   169     unsigned numberOfActiveAnimations() const;
       
   170 
       
   171     void addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
       
   172     void removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
       
   173 
       
   174     void dispatchPendingLoadRequests();
       
   175     void disableImageLoading();
       
   176 
       
   177     void setDatabaseQuota(int size);
       
   178     void clearAllDatabases();
       
   179     void setIconDatabaseEnabled(bool enable);
       
   180 
       
   181     void setCustomPolicyDelegate(bool enabled, bool permissive = true);
       
   182     void waitForPolicyDelegate();
       
   183 
       
   184     void overridePreference(const QString& name, const QVariant& value);
       
   185     void setUserStyleSheetLocation(const QString& url);
       
   186     void setUserStyleSheetEnabled(bool enabled);
       
   187     void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme);
       
   188     int workerThreadCount();
       
   189     int pageNumberForElementById(const QString& id, float width = 0, float height = 0);
       
   190     int numberOfPages(float width = maxViewWidth, float height = maxViewHeight);
       
   191     bool callShouldCloseOnWebView();
       
   192     // For now, this is a no-op. This may change depending on outcome of
       
   193     // https://bugs.webkit.org/show_bug.cgi?id=33333
       
   194     void setCallCloseOnWebViews() {}
       
   195     // This is a no-op - it allows us to pass
       
   196     // plugins/get-url-that-the-resource-load-delegate-will-disallow.html
       
   197     // which is a Mac-specific test.
       
   198     void addDisallowedURL(const QString&) {}
       
   199 
       
   200     void setMockGeolocationError(int code, const QString& message);
       
   201     void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
       
   202     void setGeolocationPermission(bool allow);
       
   203     bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
       
   204     bool geolocationPermission() const { return m_geolocationPermission; }
       
   205 
       
   206     // Empty stub method to keep parity with object model exposed by global LayoutTestController.
       
   207     void abortModal() {}
       
   208 
       
   209     /*
       
   210         Policy values: 'on', 'auto' or 'off'.
       
   211         Orientation values: 'vertical' or 'horizontal'.
       
   212     */
       
   213     void setScrollbarPolicy(const QString& orientation, const QString& policy);
       
   214 
       
   215     QString markerTextForListItem(const QWebElement& listItem);
       
   216     QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element) const;
       
   217 
       
   218     // Simulate a request an embedding application could make, populating per-session credential storage.
       
   219     void authenticateSession(const QString& url, const QString& username, const QString& password);
       
   220 
       
   221     void setEditingBehavior(const QString& editingBehavior);
       
   222 
       
   223     void evaluateScriptInIsolatedWorld(int worldID, const QString& script);
       
   224     bool isPageBoxVisible(int pageIndex);
       
   225     QString pageSizeAndMarginsInPixels(int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
       
   226     QString pageProperty(const QString& propertyName, int pageNumber);
       
   227     void addUserStyleSheet(const QString& sourceCode);
       
   228 
       
   229 private slots:
       
   230     void processWork();
       
   231 
       
   232 private:
       
   233     bool m_hasDumped;
       
   234     bool m_textDump;
       
   235     bool m_dumpBackForwardList;
       
   236     bool m_dumpChildrenAsText;
       
   237     bool m_dumpChildFrameScrollPositions;
       
   238     bool m_canOpenWindows;
       
   239     bool m_waitForDone;
       
   240     bool m_dumpTitleChanges;
       
   241     bool m_dumpDatabaseCallbacks;
       
   242     bool m_dumpStatusCallbacks;
       
   243     bool m_waitForPolicy;
       
   244     bool m_handleErrorPages;
       
   245     bool m_loadFinished;
       
   246     bool m_globalFlag;
       
   247     bool m_userStyleSheetEnabled;
       
   248     bool m_isGeolocationPermissionSet;
       
   249     bool m_geolocationPermission;
       
   250 
       
   251     QUrl m_userStyleSheetLocation;
       
   252     QBasicTimer m_timeoutTimer;
       
   253     QWebFrame* m_topLoadingFrame;
       
   254     WebCore::DumpRenderTree* m_drt;
       
   255     QWebHistory* m_webHistory;
       
   256     QStringList m_desktopNotificationAllowedOrigins;
       
   257     bool m_ignoreDesktopNotification;
       
   258 };
       
   259 
       
   260 #endif // LayoutTestControllerQt_h