initial import
[vuplus_webkit] / Tools / DumpRenderTree / chromium / LayoutTestController.h
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  * Copyright (C) 2010 Pawel Hajdan (phajdan.jr@chromium.org)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 /*
33   LayoutTestController class:
34   Bound to a JavaScript window.layoutTestController object using the
35   CppBoundClass::bindToJavascript(), this allows layout tests that are run in
36   the test_shell (or, in principle, any web page loaded into a client app built
37   with this class) to control various aspects of how the tests are run and what
38   sort of output they produce.
39 */
40
41 #ifndef LayoutTestController_h
42 #define LayoutTestController_h
43
44 #include "CppBoundClass.h"
45 #include "Task.h"
46 #include "WebArrayBufferView.h"
47 #include "WebString.h"
48 #include "WebTextDirection.h"
49 #include "WebURL.h"
50 #include <wtf/Deque.h>
51 #include <wtf/OwnPtr.h>
52
53 namespace WebKit {
54 class WebGeolocationClientMock;
55 class WebSpeechInputController;
56 class WebSpeechInputControllerMock;
57 class WebSpeechInputListener;
58 }
59
60 namespace webkit_support {
61 class ScopedTempDirectory;
62 }
63
64 class TestShell;
65
66 class LayoutTestController : public CppBoundClass {
67 public:
68     // Builds the property and method lists needed to bind this class to a JS
69     // object.
70     LayoutTestController(TestShell*);
71
72     ~LayoutTestController();
73
74     // This function sets a flag that tells the test_shell to dump pages as
75     // plain text, rather than as a text representation of the renderer's state.
76     // It takes an optional argument, whether to dump pixels results or not.
77     void dumpAsText(const CppArgumentList&, CppVariant*);
78
79     // This function should set a flag that tells the test_shell to print a line
80     // of descriptive text for each database command. It should take no
81     // arguments, and ignore any that may be present. However, at the moment, we
82     // don't have any DB function that prints messages, so for now this function
83     // doesn't do anything.
84     void dumpDatabaseCallbacks(const CppArgumentList&, CppVariant*);
85
86     // This function sets a flag that tells the test_shell to print a line of
87     // descriptive text for each editing command. It takes no arguments, and
88     // ignores any that may be present.
89     void dumpEditingCallbacks(const CppArgumentList&, CppVariant*);
90
91     // This function sets a flag that tells the test_shell to print a line of
92     // descriptive text for each frame load callback. It takes no arguments, and
93     // ignores any that may be present.
94     void dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant*);
95
96     // This function sets a flag that tells the test_shell to print a line of
97     // descriptive text for the progress finished callback. It takes no
98     // arguments, and ignores any that may be present.
99     void dumpProgressFinishedCallback(const CppArgumentList&, CppVariant*);
100
101     // This function sets a flag that tells the test_shell to print a line of
102     // user gesture status text for some frame load callbacks. It takes no
103     // arguments, and ignores any that may be present.
104     void dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant*);
105
106     // This function sets a flag that tells the test_shell to print out a text
107     // representation of the back/forward list. It ignores all arguments.
108     void dumpBackForwardList(const CppArgumentList&, CppVariant*);
109
110     // This function sets a flag that tells the test_shell to print out the
111     // scroll offsets of the child frames. It ignores all.
112     void dumpChildFrameScrollPositions(const CppArgumentList&, CppVariant*);
113
114     // This function sets a flag that tells the test_shell to recursively
115     // dump all frames as plain text if the dumpAsText flag is set.
116     // It takes no arguments, and ignores any that may be present.
117     void dumpChildFramesAsText(const CppArgumentList&, CppVariant*);
118     
119     // This function sets a flag that tells the test_shell to dump a descriptive
120     // line for each resource load callback. It takes no arguments, and ignores
121     // any that may be present.
122     void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);    
123     
124     // This function sets a flag that tells the test_shell to dump the MIME type
125     // for each resource that was loaded. It takes no arguments, and ignores any
126     // that may be present.
127     void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
128
129     // This function sets a flag that tells the test_shell to dump all calls
130     // to window.status().
131     // It takes no arguments, and ignores any that may be present.
132     void dumpWindowStatusChanges(const CppArgumentList&, CppVariant*);
133
134     // When called with a boolean argument, this sets a flag that controls
135     // whether content-editable elements accept editing focus when an editing
136     // attempt is made. It ignores any additional arguments.
137     void setAcceptsEditing(const CppArgumentList&, CppVariant*);
138
139     // Functions for dealing with windows. By default we block all new windows.
140     void windowCount(const CppArgumentList&, CppVariant*);
141     void setCanOpenWindows(const CppArgumentList&, CppVariant*);
142     void setCloseRemainingWindowsWhenComplete(const CppArgumentList&, CppVariant*);
143
144     // By default, tests end when page load is complete. These methods are used
145     // to delay the completion of the test until notifyDone is called.
146     void waitUntilDone(const CppArgumentList&, CppVariant*);
147     void notifyDone(const CppArgumentList&, CppVariant*);
148
149     // Methods for adding actions to the work queue. Used in conjunction with
150     // waitUntilDone/notifyDone above.
151     void queueBackNavigation(const CppArgumentList&, CppVariant*);
152     void queueForwardNavigation(const CppArgumentList&, CppVariant*);
153     void queueReload(const CppArgumentList&, CppVariant*);
154     void queueLoadingScript(const CppArgumentList&, CppVariant*);
155     void queueNonLoadingScript(const CppArgumentList&, CppVariant*);
156     void queueLoad(const CppArgumentList&, CppVariant*);
157     void queueLoadHTMLString(const CppArgumentList&, CppVariant*);
158
159     // Although this is named "objC" to match the Mac version, it actually tests
160     // the identity of its two arguments in C++.
161     void objCIdentityIsEqual(const CppArgumentList&, CppVariant*);
162
163     // Changes the cookie policy from the default to allow all cookies.
164     void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*);
165
166     // Changes asynchronous spellchecking flag on the settings.
167     void setAsynchronousSpellCheckingEnabled(const CppArgumentList&, CppVariant*);
168
169     // Shows DevTools window.
170     void showWebInspector(const CppArgumentList&, CppVariant*);
171     void closeWebInspector(const CppArgumentList&, CppVariant*);
172
173     // Gives focus to the window.
174     void setWindowIsKey(const CppArgumentList&, CppVariant*);
175
176     // Method that controls whether pressing Tab key cycles through page elements
177     // or inserts a '\t' char in text area
178     void setTabKeyCyclesThroughElements(const CppArgumentList&, CppVariant*);
179
180     // Passes through to WebPreferences which allows the user to have a custom
181     // style sheet.
182     void setUserStyleSheetEnabled(const CppArgumentList&, CppVariant*);
183     void setUserStyleSheetLocation(const CppArgumentList&, CppVariant*);
184
185     // Passes this preference through to WebSettings.
186     void setAuthorAndUserStylesEnabled(const CppArgumentList&, CppVariant*);
187
188     // Puts Webkit in "dashboard compatibility mode", which is used in obscure
189     // Mac-only circumstances. It's not really necessary, and will most likely
190     // never be used by Chrome, but some layout tests depend on its presence.
191     void setUseDashboardCompatibilityMode(const CppArgumentList&, CppVariant*);
192
193     void setScrollbarPolicy(const CppArgumentList&, CppVariant*);
194
195     // Causes navigation actions just printout the intended navigation instead
196     // of taking you to the page. This is used for cases like mailto, where you
197     // don't actually want to open the mail program.
198     void setCustomPolicyDelegate(const CppArgumentList&, CppVariant*);
199
200     // Delays completion of the test until the policy delegate runs.
201     void waitForPolicyDelegate(const CppArgumentList&, CppVariant*);
202
203     // Causes WillSendRequest to clear certain headers.
204     void setWillSendRequestClearHeader(const CppArgumentList&, CppVariant*);
205
206     // Causes WillSendRequest to block redirects.
207     void setWillSendRequestReturnsNullOnRedirect(const CppArgumentList&, CppVariant*);
208
209     // Causes WillSendRequest to return an empty request.
210     void setWillSendRequestReturnsNull(const CppArgumentList&, CppVariant*);
211
212     // Converts a URL starting with file:///tmp/ to the local mapping.
213     void pathToLocalResource(const CppArgumentList&, CppVariant*);
214
215     // Sets a bool such that when a drag is started, we fill the drag clipboard
216     // with a fake file object.
217     void addFileToPasteboardOnDrag(const CppArgumentList&, CppVariant*);
218
219     // Executes an internal command (superset of document.execCommand() commands).
220     void execCommand(const CppArgumentList&, CppVariant*);
221
222     // Checks if an internal command is currently available.
223     void isCommandEnabled(const CppArgumentList&, CppVariant*);
224
225     // Set the WebPreference that controls webkit's popup blocking.
226     void setPopupBlockingEnabled(const CppArgumentList&, CppVariant*);
227
228     // If true, causes provisional frame loads to be stopped for the remainder of
229     // the test.
230     void setStopProvisionalFrameLoads(const CppArgumentList&, CppVariant*);
231
232     // Enable or disable smart insert/delete. This is enabled by default.
233     void setSmartInsertDeleteEnabled(const CppArgumentList&, CppVariant*);
234
235     // Enable or disable trailing whitespace selection on double click.
236     void setSelectTrailingWhitespaceEnabled(const CppArgumentList&, CppVariant*);
237
238     void pauseAnimationAtTimeOnElementWithId(const CppArgumentList&, CppVariant*);
239     void pauseTransitionAtTimeOnElementWithId(const CppArgumentList&, CppVariant*);
240     void elementDoesAutoCompleteForElementWithId(const CppArgumentList&, CppVariant*);
241     void numberOfActiveAnimations(const CppArgumentList&, CppVariant*);
242     void suspendAnimations(const CppArgumentList&, CppVariant*);
243     void resumeAnimations(const CppArgumentList&, CppVariant*);
244     void sampleSVGAnimationForElementAtTime(const CppArgumentList&, CppVariant*);
245     void disableImageLoading(const CppArgumentList&, CppVariant*);
246     void setIconDatabaseEnabled(const CppArgumentList&, CppVariant*);
247     void dumpSelectionRect(const CppArgumentList&, CppVariant*);
248
249     // Grants permission for desktop notifications to an origin
250     void grantDesktopNotificationPermission(const CppArgumentList&, CppVariant*);
251     // Simulates a click on a desktop notification.
252     void simulateDesktopNotificationClick(const CppArgumentList&, CppVariant*);
253
254     void setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&, CppVariant*);
255     void setDeferMainResourceDataLoad(const CppArgumentList&, CppVariant*);
256     void setEditingBehavior(const CppArgumentList&, CppVariant*);
257
258     // Deals with Web Audio WAV file data.
259     void setAudioData(const CppArgumentList&, CppVariant*);
260     const WebKit::WebArrayBufferView& audioData() const { return m_audioData; } 
261
262     // The following are only stubs.
263     // FIXME: Implement any of these that are needed to pass the layout tests.
264     void dumpAsWebArchive(const CppArgumentList&, CppVariant*);
265     void dumpTitleChanges(const CppArgumentList&, CppVariant*);
266     void setMainFrameIsFirstResponder(const CppArgumentList&, CppVariant*);
267     void display(const CppArgumentList&, CppVariant*);
268     void displayInvalidatedRegion(const CppArgumentList&, CppVariant*);
269     void testRepaint(const CppArgumentList&, CppVariant*);
270     void repaintSweepHorizontally(const CppArgumentList&, CppVariant*);
271     void clearBackForwardList(const CppArgumentList&, CppVariant*);
272     void keepWebHistory(const CppArgumentList&, CppVariant*);
273     void storeWebScriptObject(const CppArgumentList&, CppVariant*);
274     void accessStoredWebScriptObject(const CppArgumentList&, CppVariant*);
275     void objCClassNameOf(const CppArgumentList&, CppVariant*);
276     void addDisallowedURL(const CppArgumentList&, CppVariant*);
277     void callShouldCloseOnWebView(const CppArgumentList&, CppVariant*);
278     void setCallCloseOnWebViews(const CppArgumentList&, CppVariant*);
279     void setPrivateBrowsingEnabled(const CppArgumentList&, CppVariant*);
280
281     void setJavaScriptCanAccessClipboard(const CppArgumentList&, CppVariant*);
282     void setXSSAuditorEnabled(const CppArgumentList&, CppVariant*);
283     void overridePreference(const CppArgumentList&, CppVariant*);
284     void setAllowUniversalAccessFromFileURLs(const CppArgumentList&, CppVariant*);
285     void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*);
286     void setAllowFileAccessFromFileURLs(const CppArgumentList&, CppVariant*);
287     void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*);
288
289     void evaluateScriptInIsolatedWorld(const CppArgumentList&, CppVariant*);
290     void setIsolatedWorldSecurityOrigin(const CppArgumentList&, CppVariant*);
291
292     // The fallback method is called when a nonexistent method is called on
293     // the layout test controller object.
294     // It is usefull to catch typos in the JavaScript code (a few layout tests
295     // do have typos in them) and it allows the script to continue running in
296     // that case (as the Mac does).
297     void fallbackMethod(const CppArgumentList&, CppVariant*);
298
299     // Allows layout tests to manage origins' whitelisting.
300     void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
301     void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
302
303     // Clears all application caches.
304     void clearAllApplicationCaches(const CppArgumentList&, CppVariant*);
305     // Clears an application cache for an origin.
306     void clearApplicationCacheForOrigin(const CppArgumentList&, CppVariant*);
307     // Returns origins that have application caches.
308     void originsWithApplicationCache(const CppArgumentList&, CppVariant*);
309     // Sets the application cache quota for the localhost origin.
310     void setApplicationCacheOriginQuota(const CppArgumentList&, CppVariant*);
311     // Returns disk usage by all application caches for an origin.
312     void applicationCacheDiskUsageForOrigin(const CppArgumentList&, CppVariant*);
313
314     // Clears all databases.
315     void clearAllDatabases(const CppArgumentList&, CppVariant*);
316     // Sets the default quota for all origins
317     void setDatabaseQuota(const CppArgumentList&, CppVariant*);
318     // Overrides the backend for IndexedDB
319     void setOverrideIndexedDBBackingStore(const CppArgumentList&, CppVariant*);
320
321     // Calls setlocale(LC_ALL, ...) for a specified locale.
322     // Resets between tests.
323     void setPOSIXLocale(const CppArgumentList&, CppVariant*);
324
325     // Gets the value of the counter in the element specified by its ID.
326     void counterValueForElementById(const CppArgumentList&, CppVariant*);
327
328     // Gets the number of page where the specified element will be put.
329     void pageNumberForElementById(const CppArgumentList&, CppVariant*);
330
331     // Gets the number of pages to be printed.
332     void numberOfPages(const CppArgumentList&, CppVariant*);
333
334     // Gets the number of geolocation permissions requests pending.
335     void numberOfPendingGeolocationPermissionRequests(const CppArgumentList&, CppVariant*);
336
337     // Allows layout tests to start JavaScript profiling.
338     void setJavaScriptProfilingEnabled(const CppArgumentList&, CppVariant*);
339
340     // Allows layout tests to exec scripts at WebInspector side.
341     void evaluateInWebInspector(const CppArgumentList&, CppVariant*);
342
343     // Forces the selection colors for testing under Linux.
344     void forceRedSelectionColors(const CppArgumentList&, CppVariant*);
345
346     // Adds a user script or user style sheet to be injected into new documents.
347     void addUserScript(const CppArgumentList&, CppVariant*);
348     void addUserStyleSheet(const CppArgumentList&, CppVariant*);
349
350     // DeviceOrientation related functions
351     void setMockDeviceOrientation(const CppArgumentList&, CppVariant*);
352
353     // Geolocation related functions.
354     void setGeolocationPermission(const CppArgumentList&, CppVariant*);
355     void setMockGeolocationPosition(const CppArgumentList&, CppVariant*);
356     void setMockGeolocationError(const CppArgumentList&, CppVariant*);
357
358     // Empty stub method to keep parity with object model exposed by global LayoutTestController.
359     void abortModal(const CppArgumentList&, CppVariant*);
360
361     // Speech input related functions.
362     void addMockSpeechInputResult(const CppArgumentList&, CppVariant*);
363     void startSpeechInput(const CppArgumentList&, CppVariant*);
364
365     void layerTreeAsText(const CppArgumentList& args, CppVariant* result);
366
367     void loseCompositorContext(const CppArgumentList& args, CppVariant* result);
368
369     void markerTextForListItem(const CppArgumentList&, CppVariant*);
370     void hasSpellingMarker(const CppArgumentList&, CppVariant*);
371
372     void setMinimumTimerInterval(const CppArgumentList&, CppVariant*);
373
374     // Expects the first argument to be an input element and the second argument to be a boolean.
375     // Forwards the setAutofilled() call to the element.
376     void setAutofilled(const CppArgumentList&, CppVariant*);
377
378     // Expects the first argument to be an input element and the second argument to be a string value.
379     // Forwards the setValueForUser() call to the element.
380     void setValueForUser(const CppArgumentList&, CppVariant*);
381
382     // LocalStorage origin-related
383     void deleteAllLocalStorage(const CppArgumentList&, CppVariant*);
384     void originsWithLocalStorage(const CppArgumentList&, CppVariant*);
385     void deleteLocalStorageForOrigin(const CppArgumentList&, CppVariant*);
386     void localStorageDiskUsageForOrigin(const CppArgumentList&, CppVariant*);
387     void observeStorageTrackerNotifications(const CppArgumentList&, CppVariant*);
388     void syncLocalStorage(const CppArgumentList&, CppVariant*);
389
390     // WebPermissionClient related.
391     void setImagesAllowed(const CppArgumentList&, CppVariant*);
392     void setStorageAllowed(const CppArgumentList&, CppVariant*);
393     void setPluginsAllowed(const CppArgumentList&, CppVariant*);
394
395     // Enable or disable plugins.
396     void setPluginsEnabled(const CppArgumentList&, CppVariant*);
397
398     // Switch the visibility of the page.
399     void setPageVisibility(const CppArgumentList&, CppVariant*);
400     void resetPageVisibility(const CppArgumentList&, CppVariant*);
401
402     // Changes the direction of the focused element.
403     void setTextDirection(const CppArgumentList&, CppVariant*);
404
405     void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, CppVariant*);
406
407     void enableFixedLayoutMode(const CppArgumentList&, CppVariant*);
408     void setFixedLayoutSize(const CppArgumentList&, CppVariant*);
409
410 public:
411     // The following methods are not exposed to JavaScript.
412     void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
413
414     WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*);
415     bool shouldDumpAsAudio() const { return m_dumpAsAudio; } 
416     void setShouldDumpAsAudio(bool dumpAsAudio) { m_dumpAsAudio = dumpAsAudio; } 
417     bool shouldDumpAsText() { return m_dumpAsText; }
418     void setShouldDumpAsText(bool value) { m_dumpAsText = value; }
419     bool shouldDumpEditingCallbacks() { return m_dumpEditingCallbacks; }
420     bool shouldDumpFrameLoadCallbacks() { return m_dumpFrameLoadCallbacks; }
421     void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
422     bool shouldDumpProgressFinishedCallback() { return m_dumpProgressFinishedCallback; }
423     void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
424     bool shouldDumpUserGestureInFrameLoadCallbacks() { return m_dumpUserGestureInFrameLoadCallbacks; }
425     void setShouldDumpUserGestureInFrameLoadCallbacks(bool value) { m_dumpUserGestureInFrameLoadCallbacks = value; }
426     bool shouldDumpResourceLoadCallbacks() {return m_dumpResourceLoadCallbacks; }
427     void setShouldDumpResourceResponseMIMETypes(bool value) { m_dumpResourceResponseMIMETypes = value; }
428     bool shouldDumpResourceResponseMIMETypes() {return m_dumpResourceResponseMIMETypes; }
429     bool shouldDumpStatusCallbacks() { return m_dumpWindowStatusChanges; }
430     bool shouldDumpSelectionRect() { return m_dumpSelectionRect; }
431     bool shouldDumpBackForwardList() { return m_dumpBackForwardList; }
432     bool shouldDumpTitleChanges() { return m_dumpTitleChanges; }
433     bool shouldDumpChildFrameScrollPositions() { return m_dumpChildFrameScrollPositions; }
434     bool shouldDumpChildFramesAsText() { return m_dumpChildFramesAsText; }
435     bool shouldGeneratePixelResults() { return m_generatePixelResults; }
436     void setShouldGeneratePixelResults(bool value) { m_generatePixelResults = value; }
437     bool acceptsEditing() { return m_acceptsEditing; }
438     bool canOpenWindows() { return m_canOpenWindows; }
439     bool shouldAddFileToPasteboard() { return m_shouldAddFileToPasteboard; }
440     bool stopProvisionalFrameLoads() { return m_stopProvisionalFrameLoads; }
441     bool deferMainResourceDataLoad() { return m_deferMainResourceDataLoad; }
442     void setShowDebugLayerTree(bool value) { m_showDebugLayerTree = value; }
443     void setTitleTextDirection(WebKit::WebTextDirection dir)
444     {
445         m_titleTextDirection.set(dir == WebKit::WebTextDirectionLeftToRight ? "ltr" : "rtl");
446     }
447
448     bool testRepaint() const { return m_testRepaint; }
449     bool sweepHorizontally() const { return m_sweepHorizontally; }
450
451     // Called by the webview delegate when the toplevel frame load is done.
452     void locationChangeDone();
453
454     // Called by the webview delegate when the policy delegate runs if the
455     // waitForPolicyDelegate was called.
456     void policyDelegateDone();
457
458     // Reinitializes all static values. The reset() method should be called
459     // before the start of each test (currently from TestShell::runFileTest).
460     void reset();
461
462     // A single item in the work queue.
463     class WorkItem {
464     public:
465         virtual ~WorkItem() { }
466
467         // Returns true if this started a load.
468         virtual bool run(TestShell*) = 0;
469     };
470
471     TaskList* taskList() { return &m_taskList; }
472
473     bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
474
475 private:
476     friend class WorkItem;
477     friend class WorkQueue;
478
479     // Helper class for managing events queued by methods like queueLoad or
480     // queueScript.
481     class WorkQueue {
482     public:
483         WorkQueue(LayoutTestController* controller) : m_frozen(false), m_controller(controller) { }
484         virtual ~WorkQueue();
485         void processWorkSoon();
486
487         // Reset the state of the class between tests.
488         void reset();
489
490         void addWork(WorkItem*);
491
492         void setFrozen(bool frozen) { m_frozen = frozen; }
493         bool isEmpty() { return m_queue.isEmpty(); }
494         TaskList* taskList() { return &m_taskList; }
495
496     private:
497         void processWork();
498         class WorkQueueTask: public MethodTask<WorkQueue> {
499         public:
500             WorkQueueTask(WorkQueue* object): MethodTask<WorkQueue>(object) { }
501             virtual void runIfValid() { m_object->processWork(); }
502         };
503
504         TaskList m_taskList;
505         Deque<WorkItem*> m_queue;
506         bool m_frozen;
507         LayoutTestController* m_controller;
508     };
509
510     // Support for overridePreference.
511     bool cppVariantToBool(const CppVariant&);
512     int32_t cppVariantToInt32(const CppVariant&);
513     WebKit::WebString cppVariantToWebString(const CppVariant&);
514
515     void logErrorToConsole(const std::string&);
516     void completeNotifyDone(bool isTimeout);
517     class NotifyDoneTimedOutTask: public MethodTask<LayoutTestController> {
518     public:
519         NotifyDoneTimedOutTask(LayoutTestController* object): MethodTask<LayoutTestController>(object) { }
520         virtual void runIfValid() { m_object->completeNotifyDone(true); }
521     };
522
523
524     bool pauseAnimationAtTimeOnElementWithId(const WebKit::WebString& animationName, double time, const WebKit::WebString& elementId);
525     bool pauseTransitionAtTimeOnElementWithId(const WebKit::WebString& propertyName, double time, const WebKit::WebString& elementId);
526     bool elementDoesAutoCompleteForElementWithId(const WebKit::WebString&);
527     int numberOfActiveAnimations();
528     void suspendAnimations();
529     void resumeAnimations();
530
531     // Used for test timeouts.
532     TaskList m_taskList;
533
534     // Non-owning pointer. The LayoutTestController is owned by the host.
535     TestShell* m_shell;
536
537     // If true, the test_shell will produce a plain text dump rather than a
538     // text representation of the renderer.
539     bool m_dumpAsText;
540
541     // If true, the test_shell will output a base64 encoded WAVE file.
542     bool m_dumpAsAudio;
543
544     // If true, the test_shell will write a descriptive line for each editing
545     // command.
546     bool m_dumpEditingCallbacks;
547
548     // If true, the test_shell will draw the bounds of the current selection rect
549     // taking possible transforms of the selection rect into account.
550     bool m_dumpSelectionRect;
551
552     // If true, the test_shell will output a descriptive line for each frame
553     // load callback.
554     bool m_dumpFrameLoadCallbacks;
555
556     // If true, the test_shell will output a descriptive line for the progress
557     // finished callback.
558     bool m_dumpProgressFinishedCallback;
559
560     // If true, the test_shell will output a line of the user gesture status
561     // text for some frame load callbacks.
562     bool m_dumpUserGestureInFrameLoadCallbacks;
563
564     // If true, the test_shell will output a descriptive line for each resource
565     // load callback.
566     bool m_dumpResourceLoadCallbacks;
567     
568     // If true, the test_shell will output the MIME type for each resource that 
569     // was loaded.
570     bool m_dumpResourceResponseMIMETypes;
571
572     // If true, the test_shell will produce a dump of the back forward list as
573     // well.
574     bool m_dumpBackForwardList;
575
576     // If true, the test_shell will print out the child frame scroll offsets as
577     // well.
578     bool m_dumpChildFrameScrollPositions;
579
580     // If true and if dump_as_text_ is true, the test_shell will recursively
581     // dump all frames as plain text.
582     bool m_dumpChildFramesAsText;
583
584     // If true, the test_shell will dump all changes to window.status.
585     bool m_dumpWindowStatusChanges;
586
587     // If true, output a message when the page title is changed.
588     bool m_dumpTitleChanges;
589
590     // If true, the test_shell will generate pixel results in dumpAsText mode
591     bool m_generatePixelResults;
592
593     // If true, the element will be treated as editable. This value is returned
594     // from various editing callbacks that are called just before edit operations
595     // are allowed.
596     bool m_acceptsEditing;
597
598     // If true, new windows can be opened via javascript or by plugins. By
599     // default, set to false and can be toggled to true using
600     // setCanOpenWindows().
601     bool m_canOpenWindows;
602
603     // When reset is called, go through and close all but the main test shell
604     // window. By default, set to true but toggled to false using
605     // setCloseRemainingWindowsWhenComplete().
606     bool m_closeRemainingWindows;
607
608     // If true, pixel dump will be produced as a series of 1px-tall, view-wide
609     // individual paints over the height of the view.
610     bool m_testRepaint;
611     // If true and test_repaint_ is true as well, pixel dump will be produced as
612     // a series of 1px-wide, view-tall paints across the width of the view.
613     bool m_sweepHorizontally;
614
615     // If true and a drag starts, adds a file to the drag&drop clipboard.
616     bool m_shouldAddFileToPasteboard;
617
618     // If true, stops provisional frame loads during the
619     // DidStartProvisionalLoadForFrame callback.
620     bool m_stopProvisionalFrameLoads;
621
622     // If true, don't dump output until notifyDone is called.
623     bool m_waitUntilDone;
624
625     // If false, all new requests will not defer the main resource data load.
626     bool m_deferMainResourceDataLoad;
627
628     // If true, we will show extended information in the graphics layer tree.
629     bool m_showDebugLayerTree;
630
631     WorkQueue m_workQueue;
632
633     CppVariant m_globalFlag;
634
635     // Bound variable counting the number of top URLs visited.
636     CppVariant m_webHistoryItemCount;
637
638     // Bound variable tracking the directionality of the <title> tag.
639     CppVariant m_titleTextDirection;
640
641     WebKit::WebURL m_userStyleSheetLocation;
642
643     OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
644
645     // WAV audio data is stored here.
646     WebKit::WebArrayBufferView m_audioData;
647
648     bool m_shouldStayOnPageAfterHandlingBeforeUnload;
649 };
650
651 #endif // LayoutTestController_h