1 /* 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef LayoutTestController_h 30 #define LayoutTestController_h 31 32 #include <JavaScriptCore/JSObjectRef.h> 33 #include <wtf/RefCounted.h> 34 #include <string> 35 36 class LayoutTestController : public RefCounted<LayoutTestController> { 37 public: 38 LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash); 39 ~LayoutTestController(); 40 41 void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception); 42 43 void addDisallowedURL(JSStringRef url); 44 void clearAllDatabases(); 45 void clearBackForwardList(); 46 void clearPersistentUserStyleSheet(); 47 JSStringRef copyDecodedHostName(JSStringRef name); 48 JSStringRef copyEncodedHostName(JSStringRef name); 49 void disableImageLoading(); 50 void dispatchPendingLoadRequests(); 51 void display(); 52 void execCommand(JSStringRef name, JSStringRef value); 53 bool isCommandEnabled(JSStringRef name); 54 void keepWebHistory(); 55 void notifyDone(); 56 JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); 57 void queueBackNavigation(int howFarBackward); 58 void queueForwardNavigation(int howFarForward); 59 void queueLoad(JSStringRef url, JSStringRef target); 60 void queueLoadingScript(JSStringRef script); 61 void queueNonLoadingScript(JSStringRef script); 62 void queueReload(); 63 void setAcceptsEditing(bool acceptsEditing); 64 void setAppCacheMaximumSize(unsigned long long quota); 65 void setAuthorAndUserStylesEnabled(bool); 66 void setCacheModel(int); 67 void setCustomPolicyDelegate(bool setDelegate, bool permissive); 68 void setDatabaseQuota(unsigned long long quota); 69 void setIconDatabaseEnabled(bool iconDatabaseEnabled); 70 void setJavaScriptProfilingEnabled(bool profilingEnabled); 71 void setMainFrameIsFirstResponder(bool flag); 72 void setPersistentUserStyleSheetLocation(JSStringRef path); 73 void setPopupBlockingEnabled(bool flag); 74 void setPrivateBrowsingEnabled(bool flag); 75 void setXSSAuditorEnabled(bool flag); 76 void setSelectTrailingWhitespaceEnabled(bool flag); 77 void setSmartInsertDeleteEnabled(bool flag); 78 void setTabKeyCyclesThroughElements(bool cycles); 79 void setUseDashboardCompatibilityMode(bool flag); 80 void setUserStyleSheetEnabled(bool flag); 81 void setUserStyleSheetLocation(JSStringRef path); 82 void waitForPolicyDelegate(); 83 size_t webHistoryItemCount(); 84 int windowCount(); 85 86 bool elementDoesAutoCompleteForElementWithId(JSStringRef id); 87 dumpAsText()88 bool dumpAsText() const { return m_dumpAsText; } setDumpAsText(bool dumpAsText)89 void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; } 90 dumpAsPDF()91 bool dumpAsPDF() const { return m_dumpAsPDF; } setDumpAsPDF(bool dumpAsPDF)92 void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; } 93 dumpBackForwardList()94 bool dumpBackForwardList() const { return m_dumpBackForwardList; } setDumpBackForwardList(bool dumpBackForwardList)95 void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; } 96 dumpChildFrameScrollPositions()97 bool dumpChildFrameScrollPositions() const { return m_dumpChildFrameScrollPositions; } setDumpChildFrameScrollPositions(bool dumpChildFrameScrollPositions)98 void setDumpChildFrameScrollPositions(bool dumpChildFrameScrollPositions) { m_dumpChildFrameScrollPositions = dumpChildFrameScrollPositions; } 99 dumpChildFramesAsText()100 bool dumpChildFramesAsText() const { return m_dumpChildFramesAsText; } setDumpChildFramesAsText(bool dumpChildFramesAsText)101 void setDumpChildFramesAsText(bool dumpChildFramesAsText) { m_dumpChildFramesAsText = dumpChildFramesAsText; } 102 dumpDatabaseCallbacks()103 bool dumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; } setDumpDatabaseCallbacks(bool dumpDatabaseCallbacks)104 void setDumpDatabaseCallbacks(bool dumpDatabaseCallbacks) { m_dumpDatabaseCallbacks = dumpDatabaseCallbacks; } 105 dumpStatusCallbacks()106 bool dumpStatusCallbacks() const { return m_dumpStatusCallbacks; } setDumpStatusCallbacks(bool dumpStatusCallbacks)107 void setDumpStatusCallbacks(bool dumpStatusCallbacks) { m_dumpStatusCallbacks = dumpStatusCallbacks; } 108 dumpDOMAsWebArchive()109 bool dumpDOMAsWebArchive() const { return m_dumpDOMAsWebArchive; } setDumpDOMAsWebArchive(bool dumpDOMAsWebArchive)110 void setDumpDOMAsWebArchive(bool dumpDOMAsWebArchive) { m_dumpDOMAsWebArchive = dumpDOMAsWebArchive; } 111 dumpSelectionRect()112 bool dumpSelectionRect() const { return m_dumpSelectionRect; } setDumpSelectionRect(bool dumpSelectionRect)113 void setDumpSelectionRect(bool dumpSelectionRect) { m_dumpSelectionRect = dumpSelectionRect; } 114 dumpSourceAsWebArchive()115 bool dumpSourceAsWebArchive() const { return m_dumpSourceAsWebArchive; } setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive)116 void setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive) { m_dumpSourceAsWebArchive = dumpSourceAsWebArchive; } 117 dumpTitleChanges()118 bool dumpTitleChanges() const { return m_dumpTitleChanges; } setDumpTitleChanges(bool dumpTitleChanges)119 void setDumpTitleChanges(bool dumpTitleChanges) { m_dumpTitleChanges = dumpTitleChanges; } 120 dumpEditingCallbacks()121 bool dumpEditingCallbacks() const { return m_dumpEditingCallbacks; } setDumpEditingCallbacks(bool dumpEditingCallbacks)122 void setDumpEditingCallbacks(bool dumpEditingCallbacks) { m_dumpEditingCallbacks = dumpEditingCallbacks; } 123 dumpResourceLoadCallbacks()124 bool dumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; } setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks)125 void setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks) { m_dumpResourceLoadCallbacks = dumpResourceLoadCallbacks; } 126 dumpResourceResponseMIMETypes()127 bool dumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; } setDumpResourceResponseMIMETypes(bool dumpResourceResponseMIMETypes)128 void setDumpResourceResponseMIMETypes(bool dumpResourceResponseMIMETypes) { m_dumpResourceResponseMIMETypes = dumpResourceResponseMIMETypes; } 129 dumpWillCacheResponse()130 bool dumpWillCacheResponse() const { return m_dumpWillCacheResponse; } setDumpWillCacheResponse(bool dumpWillCacheResponse)131 void setDumpWillCacheResponse(bool dumpWillCacheResponse) { m_dumpWillCacheResponse = dumpWillCacheResponse; } 132 dumpFrameLoadCallbacks()133 bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; } setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks)134 void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; } 135 callCloseOnWebViews()136 bool callCloseOnWebViews() const { return m_callCloseOnWebViews; } setCallCloseOnWebViews(bool callCloseOnWebViews)137 void setCallCloseOnWebViews(bool callCloseOnWebViews) { m_callCloseOnWebViews = callCloseOnWebViews; } 138 canOpenWindows()139 bool canOpenWindows() const { return m_canOpenWindows; } setCanOpenWindows(bool canOpenWindows)140 void setCanOpenWindows(bool canOpenWindows) { m_canOpenWindows = canOpenWindows; } 141 closeRemainingWindowsWhenComplete()142 bool closeRemainingWindowsWhenComplete() const { return m_closeRemainingWindowsWhenComplete; } setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete)143 void setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete) { m_closeRemainingWindowsWhenComplete = closeRemainingWindowsWhenComplete; } 144 stopProvisionalFrameLoads()145 bool stopProvisionalFrameLoads() const { return m_stopProvisionalFrameLoads; } setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads)146 void setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads) { m_stopProvisionalFrameLoads = stopProvisionalFrameLoads; } 147 testOnscreen()148 bool testOnscreen() const { return m_testOnscreen; } setTestOnscreen(bool testOnscreen)149 void setTestOnscreen(bool testOnscreen) { m_testOnscreen = testOnscreen; } 150 testRepaint()151 bool testRepaint() const { return m_testRepaint; } setTestRepaint(bool testRepaint)152 void setTestRepaint(bool testRepaint) { m_testRepaint = testRepaint; } 153 testRepaintSweepHorizontally()154 bool testRepaintSweepHorizontally() const { return m_testRepaintSweepHorizontally; } setTestRepaintSweepHorizontally(bool testRepaintSweepHorizontally)155 void setTestRepaintSweepHorizontally(bool testRepaintSweepHorizontally) { m_testRepaintSweepHorizontally = testRepaintSweepHorizontally; } 156 waitToDump()157 bool waitToDump() const { return m_waitToDump; } 158 void setWaitToDump(bool waitToDump); 159 willSendRequestReturnsNullOnRedirect()160 bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; } setWillSendRequestReturnsNullOnRedirect(bool returnsNull)161 void setWillSendRequestReturnsNullOnRedirect(bool returnsNull) { m_willSendRequestReturnsNullOnRedirect = returnsNull; } 162 windowIsKey()163 bool windowIsKey() const { return m_windowIsKey; } 164 void setWindowIsKey(bool windowIsKey); 165 globalFlag()166 bool globalFlag() const { return m_globalFlag; } setGlobalFlag(bool globalFlag)167 void setGlobalFlag(bool globalFlag) { m_globalFlag = globalFlag; } 168 testPathOrURL()169 const std::string& testPathOrURL() const { return m_testPathOrURL; } expectedPixelHash()170 const std::string& expectedPixelHash() const { return m_expectedPixelHash; } 171 172 bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId); 173 bool pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId); 174 unsigned numberOfActiveAnimations() const; 175 176 private: 177 bool m_dumpAsText; 178 bool m_dumpAsPDF; 179 bool m_dumpBackForwardList; 180 bool m_dumpChildFrameScrollPositions; 181 bool m_dumpChildFramesAsText; 182 bool m_dumpDatabaseCallbacks; 183 bool m_dumpDOMAsWebArchive; 184 bool m_dumpSelectionRect; 185 bool m_dumpSourceAsWebArchive; 186 bool m_dumpStatusCallbacks; 187 bool m_dumpTitleChanges; 188 bool m_dumpEditingCallbacks; 189 bool m_dumpResourceLoadCallbacks; 190 bool m_dumpResourceResponseMIMETypes; 191 bool m_dumpWillCacheResponse; 192 bool m_dumpFrameLoadCallbacks; 193 bool m_callCloseOnWebViews; 194 bool m_canOpenWindows; 195 bool m_closeRemainingWindowsWhenComplete; 196 bool m_stopProvisionalFrameLoads; 197 bool m_testOnscreen; 198 bool m_testRepaint; 199 bool m_testRepaintSweepHorizontally; 200 bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called. 201 bool m_willSendRequestReturnsNullOnRedirect; 202 bool m_windowIsKey; 203 204 bool m_globalFlag; 205 206 std::string m_testPathOrURL; 207 std::string m_expectedPixelHash; // empty string if no hash 208 209 static JSClassRef getJSClass(); 210 static JSStaticValue* staticValues(); 211 static JSStaticFunction* staticFunctions(); 212 }; 213 214 #endif // LayoutTestController_h 215