• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 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     // Controller Methods - platfrom independant implementations
44     void addDisallowedURL(JSStringRef url);
45     void clearAllDatabases();
46     void clearBackForwardList();
47     JSStringRef copyDecodedHostName(JSStringRef name);
48     JSStringRef copyEncodedHostName(JSStringRef name);
49     void execCommand(JSStringRef name, JSStringRef value);
50     void display();
51     void keepWebHistory();
52     void notifyDone();
53     JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
54     void queueBackNavigation(int howFarBackward);
55     void queueForwardNavigation(int howFarForward);
56     void queueLoad(JSStringRef url, JSStringRef target);
57     void queueReload();
58     void queueScript(JSStringRef url);
59     void setAcceptsEditing(bool acceptsEditing);
60     void setAuthorAndUserStylesEnabled(bool);
61     void setCustomPolicyDelegate(bool setDelegate);
62     void setDatabaseQuota(unsigned long long quota);
63     void setMainFrameIsFirstResponder(bool flag);
64     void setPrivateBrowsingEnabled(bool flag);
65     void setPopupBlockingEnabled(bool flag);
66     void setTabKeyCyclesThroughElements(bool cycles);
67     void setSmartInsertDeleteEnabled(bool flag);
68     void setJavaScriptProfilingEnabled(bool profilingEnabled);
69     void setUseDashboardCompatibilityMode(bool flag);
70     void setUserStyleSheetEnabled(bool flag);
71     void setUserStyleSheetLocation(JSStringRef path);
72     void setPersistentUserStyleSheetLocation(JSStringRef path);
73     void clearPersistentUserStyleSheet();
74     int windowCount();
75 
76     bool elementDoesAutoCompleteForElementWithId(JSStringRef id);
77 
dumpAsText()78     bool dumpAsText() const { return m_dumpAsText; }
setDumpAsText(bool dumpAsText)79     void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; }
80 
dumpAsPDF()81     bool dumpAsPDF() const { return m_dumpAsPDF; }
setDumpAsPDF(bool dumpAsPDF)82     void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; }
83 
dumpBackForwardList()84     bool dumpBackForwardList() const { return m_dumpBackForwardList; }
setDumpBackForwardList(bool dumpBackForwardList)85     void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; }
86 
dumpChildFrameScrollPositions()87     bool dumpChildFrameScrollPositions() const { return m_dumpChildFrameScrollPositions; }
setDumpChildFrameScrollPositions(bool dumpChildFrameScrollPositions)88     void setDumpChildFrameScrollPositions(bool dumpChildFrameScrollPositions) { m_dumpChildFrameScrollPositions = dumpChildFrameScrollPositions; }
89 
dumpChildFramesAsText()90     bool dumpChildFramesAsText() const { return m_dumpChildFramesAsText; }
setDumpChildFramesAsText(bool dumpChildFramesAsText)91     void setDumpChildFramesAsText(bool dumpChildFramesAsText) { m_dumpChildFramesAsText = dumpChildFramesAsText; }
92 
dumpDatabaseCallbacks()93     bool dumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
setDumpDatabaseCallbacks(bool dumpDatabaseCallbacks)94     void setDumpDatabaseCallbacks(bool dumpDatabaseCallbacks) { m_dumpDatabaseCallbacks = dumpDatabaseCallbacks; }
95 
dumpStatusCallbacks()96     bool dumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
setDumpStatusCallbacks(bool dumpStatusCallbacks)97     void setDumpStatusCallbacks(bool dumpStatusCallbacks) { m_dumpStatusCallbacks = dumpStatusCallbacks; }
98 
dumpDOMAsWebArchive()99     bool dumpDOMAsWebArchive() const { return m_dumpDOMAsWebArchive; }
setDumpDOMAsWebArchive(bool dumpDOMAsWebArchive)100     void setDumpDOMAsWebArchive(bool dumpDOMAsWebArchive) { m_dumpDOMAsWebArchive = dumpDOMAsWebArchive; }
101 
dumpSelectionRect()102     bool dumpSelectionRect() const { return m_dumpSelectionRect; }
setDumpSelectionRect(bool dumpSelectionRect)103     void setDumpSelectionRect(bool dumpSelectionRect) { m_dumpSelectionRect = dumpSelectionRect; }
104 
dumpSourceAsWebArchive()105     bool dumpSourceAsWebArchive() const { return m_dumpSourceAsWebArchive; }
setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive)106     void setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive) { m_dumpSourceAsWebArchive = dumpSourceAsWebArchive; }
107 
dumpTitleChanges()108     bool dumpTitleChanges() const { return m_dumpTitleChanges; }
setDumpTitleChanges(bool dumpTitleChanges)109     void setDumpTitleChanges(bool dumpTitleChanges) { m_dumpTitleChanges = dumpTitleChanges; }
110 
dumpEditingCallbacks()111     bool dumpEditingCallbacks() const { return m_dumpEditingCallbacks; }
setDumpEditingCallbacks(bool dumpEditingCallbacks)112     void setDumpEditingCallbacks(bool dumpEditingCallbacks) { m_dumpEditingCallbacks = dumpEditingCallbacks; }
113 
dumpResourceLoadCallbacks()114     bool dumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks)115     void setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks) { m_dumpResourceLoadCallbacks = dumpResourceLoadCallbacks; }
116 
dumpFrameLoadCallbacks()117     bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; }
setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks)118     void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; }
119 
addFileToPasteboardOnDrag()120     bool addFileToPasteboardOnDrag() const { return m_addFileToPasteboardOnDrag; }
setAddFileToPasteboardOnDrag(bool addFileToPasteboardOnDrag)121     void setAddFileToPasteboardOnDrag(bool addFileToPasteboardOnDrag) { m_addFileToPasteboardOnDrag = addFileToPasteboardOnDrag; }
122 
callCloseOnWebViews()123     bool callCloseOnWebViews() const { return m_callCloseOnWebViews; }
setCallCloseOnWebViews(bool callCloseOnWebViews)124     void setCallCloseOnWebViews(bool callCloseOnWebViews) { m_callCloseOnWebViews = callCloseOnWebViews; }
125 
canOpenWindows()126     bool canOpenWindows() const { return m_canOpenWindows; }
setCanOpenWindows(bool canOpenWindows)127     void setCanOpenWindows(bool canOpenWindows) { m_canOpenWindows = canOpenWindows; }
128 
closeRemainingWindowsWhenComplete()129     bool closeRemainingWindowsWhenComplete() const { return m_closeRemainingWindowsWhenComplete; }
setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete)130     void setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete) { m_closeRemainingWindowsWhenComplete = closeRemainingWindowsWhenComplete; }
131 
stopProvisionalFrameLoads()132     bool stopProvisionalFrameLoads() const { return m_stopProvisionalFrameLoads; }
setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads)133     void setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads) { m_stopProvisionalFrameLoads = stopProvisionalFrameLoads; }
134 
testOnscreen()135     bool testOnscreen() const { return m_testOnscreen; }
setTestOnscreen(bool testOnscreen)136     void setTestOnscreen(bool testOnscreen) { m_testOnscreen = testOnscreen; }
137 
testRepaint()138     bool testRepaint() const { return m_testRepaint; }
setTestRepaint(bool testRepaint)139     void setTestRepaint(bool testRepaint) { m_testRepaint = testRepaint; }
140 
testRepaintSweepHorizontally()141     bool testRepaintSweepHorizontally() const { return m_testRepaintSweepHorizontally; }
setTestRepaintSweepHorizontally(bool testRepaintSweepHorizontally)142     void setTestRepaintSweepHorizontally(bool testRepaintSweepHorizontally) { m_testRepaintSweepHorizontally = testRepaintSweepHorizontally; }
143 
waitToDump()144     bool waitToDump() const { return m_waitToDump; }
145     void setWaitToDump(bool waitToDump);
146 
windowIsKey()147     bool windowIsKey() const { return m_windowIsKey; }
148     void setWindowIsKey(bool windowIsKey);
149 
globalFlag()150     bool globalFlag() const { return m_globalFlag; }
setGlobalFlag(bool globalFlag)151     void setGlobalFlag(bool globalFlag) { m_globalFlag = globalFlag; }
152 
testPathOrURL()153     const std::string& testPathOrURL() const { return m_testPathOrURL; }
expectedPixelHash()154     const std::string& expectedPixelHash() const { return m_expectedPixelHash; }
155 
156 private:
157     bool m_dumpAsText;
158     bool m_dumpAsPDF;
159     bool m_dumpBackForwardList;
160     bool m_dumpChildFrameScrollPositions;
161     bool m_dumpChildFramesAsText;
162     bool m_dumpDatabaseCallbacks;
163     bool m_dumpDOMAsWebArchive;
164     bool m_dumpSelectionRect;
165     bool m_dumpSourceAsWebArchive;
166     bool m_dumpStatusCallbacks;
167     bool m_dumpTitleChanges;
168     bool m_dumpEditingCallbacks;
169     bool m_dumpResourceLoadCallbacks;
170     bool m_dumpFrameLoadCallbacks;
171     bool m_addFileToPasteboardOnDrag;
172     bool m_callCloseOnWebViews;
173     bool m_canOpenWindows;
174     bool m_closeRemainingWindowsWhenComplete;
175     bool m_stopProvisionalFrameLoads;
176     bool m_testOnscreen;
177     bool m_testRepaint;
178     bool m_testRepaintSweepHorizontally;
179     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
180     bool m_windowIsKey;
181 
182     bool m_globalFlag;
183 
184     std::string m_testPathOrURL;
185     std::string m_expectedPixelHash;    // empty string if no hash
186 
187     static JSClassRef getJSClass();
188     static JSStaticValue* staticValues();
189     static JSStaticFunction* staticFunctions();
190 };
191 
192 #endif // LayoutTestController_h
193