Home | History | Annotate | Download | only in runner
      1 /*
      2  * Copyright (C) 2010 Google Inc. All rights reserved.
      3  * Copyright (C) 2010 Pawel Hajdan (phajdan.jr (at) chromium.org)
      4  * Copyright (C) 2012 Apple Inc. All Rights Reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions are
      8  * met:
      9  *
     10  *     * Redistributions of source code must retain the above copyright
     11  * notice, this list of conditions and the following disclaimer.
     12  *     * Redistributions in binary form must reproduce the above
     13  * copyright notice, this list of conditions and the following disclaimer
     14  * in the documentation and/or other materials provided with the
     15  * distribution.
     16  *     * Neither the name of Google Inc. nor the names of its
     17  * contributors may be used to endorse or promote products derived from
     18  * this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifndef TestRunner_h
     34 #define TestRunner_h
     35 
     36 #include "CppBoundClass.h"
     37 #include "TestCommon.h"
     38 #include "public/platform/WebCanvas.h"
     39 #include "public/platform/WebURL.h"
     40 #include "public/testing/WebScopedPtr.h"
     41 #include "public/testing/WebTask.h"
     42 #include "public/testing/WebTestRunner.h"
     43 #include "public/web/WebArrayBufferView.h"
     44 #include "public/web/WebPageOverlay.h"
     45 #include "public/web/WebTextDirection.h"
     46 #include "third_party/skia/include/core/SkCanvas.h"
     47 #include <deque>
     48 #include <set>
     49 #include <string>
     50 
     51 namespace blink {
     52 class WebArrayBufferView;
     53 class WebNotificationPresenter;
     54 class WebPageOverlay;
     55 class WebPermissionClient;
     56 class WebView;
     57 }
     58 
     59 namespace WebTestRunner {
     60 
     61 class NotificationPresenter;
     62 class TestInterfaces;
     63 class WebPermissions;
     64 class WebTestDelegate;
     65 class WebTestProxyBase;
     66 
     67 class TestRunner : public WebTestRunner, public CppBoundClass {
     68 public:
     69     explicit TestRunner(TestInterfaces*);
     70     virtual ~TestRunner();
     71 
     72     void setDelegate(WebTestDelegate*);
     73     void setWebView(blink::WebView*, WebTestProxyBase*);
     74 
     75     void reset();
     76 
     77     WebTaskList* taskList() { return &m_taskList; }
     78 
     79     void setTestIsRunning(bool);
     80     bool testIsRunning() const { return m_testIsRunning; }
     81 
     82     // WebTestRunner implementation.
     83     virtual bool shouldGeneratePixelResults() OVERRIDE;
     84     virtual bool shouldDumpAsAudio() const OVERRIDE;
     85     virtual const blink::WebArrayBufferView* audioData() const OVERRIDE;
     86     virtual bool shouldDumpBackForwardList() const OVERRIDE;
     87     virtual blink::WebPermissionClient* webPermissions() const OVERRIDE;
     88 
     89     // Methods used by WebTestProxyBase.
     90     bool shouldDumpSelectionRect() const;
     91     bool testRepaint() const;
     92     bool sweepHorizontally() const;
     93     bool isPrinting() const;
     94     bool shouldDumpAsText();
     95     bool shouldDumpAsTextWithPixelResults();
     96     bool shouldDumpAsMarkup();
     97     bool shouldDumpChildFrameScrollPositions() const;
     98     bool shouldDumpChildFramesAsText() const;
     99     void showDevTools();
    100     void setShouldDumpAsText(bool);
    101     void setShouldDumpAsMarkup(bool);
    102     void setShouldGeneratePixelResults(bool);
    103     void setShouldDumpFrameLoadCallbacks(bool);
    104     void setShouldDumpPingLoaderCallbacks(bool);
    105     void setShouldEnableViewSource(bool);
    106     bool shouldDumpEditingCallbacks() const;
    107     bool shouldDumpFrameLoadCallbacks() const;
    108     bool shouldDumpPingLoaderCallbacks() const;
    109     bool shouldDumpUserGestureInFrameLoadCallbacks() const;
    110     bool shouldDumpTitleChanges() const;
    111     bool shouldDumpIconChanges() const;
    112     bool shouldDumpCreateView() const;
    113     bool canOpenWindows() const;
    114     bool shouldDumpResourceLoadCallbacks() const;
    115     bool shouldDumpResourceRequestCallbacks() const;
    116     bool shouldDumpResourceResponseMIMETypes() const;
    117     bool shouldDumpStatusCallbacks() const;
    118     bool shouldDumpProgressFinishedCallback() const;
    119     bool shouldDumpSpellCheckCallbacks() const;
    120     bool deferMainResourceDataLoad() const;
    121     bool shouldStayOnPageAfterHandlingBeforeUnload() const;
    122     const std::set<std::string>* httpHeadersToClear() const;
    123     void setTopLoadingFrame(blink::WebFrame*, bool);
    124     blink::WebFrame* topLoadingFrame() const;
    125     void policyDelegateDone();
    126     bool policyDelegateEnabled() const;
    127     bool policyDelegateIsPermissive() const;
    128     bool policyDelegateShouldNotifyDone() const;
    129     bool shouldInterceptPostMessage() const;
    130     bool shouldDumpResourcePriorities() const;
    131     blink::WebNotificationPresenter* notificationPresenter() const;
    132     bool requestPointerLock();
    133     void requestPointerUnlock();
    134     bool isPointerLocked();
    135     void setToolTipText(const blink::WebString&);
    136 
    137     bool midiAccessorResult();
    138 
    139     // A single item in the work queue.
    140     class WorkItem {
    141     public:
    142         virtual ~WorkItem() { }
    143 
    144         // Returns true if this started a load.
    145         virtual bool run(WebTestDelegate*, blink::WebView*) = 0;
    146     };
    147 
    148 private:
    149     friend class WorkQueue;
    150 
    151     // Helper class for managing events queued by methods like queueLoad or
    152     // queueScript.
    153     class WorkQueue {
    154     public:
    155         WorkQueue(TestRunner* controller) : m_frozen(false), m_controller(controller) { }
    156         virtual ~WorkQueue();
    157         void processWorkSoon();
    158 
    159         // Reset the state of the class between tests.
    160         void reset();
    161 
    162         void addWork(WorkItem*);
    163 
    164         void setFrozen(bool frozen) { m_frozen = frozen; }
    165         bool isEmpty() { return m_queue.empty(); }
    166         WebTaskList* taskList() { return &m_taskList; }
    167 
    168     private:
    169         void processWork();
    170         class WorkQueueTask: public WebMethodTask<WorkQueue> {
    171         public:
    172             WorkQueueTask(WorkQueue* object): WebMethodTask<WorkQueue>(object) { }
    173             virtual void runIfValid() { m_object->processWork(); }
    174         };
    175 
    176         WebTaskList m_taskList;
    177         std::deque<WorkItem*> m_queue;
    178         bool m_frozen;
    179         TestRunner* m_controller;
    180     };
    181     ///////////////////////////////////////////////////////////////////////////
    182     // Methods dealing with the test logic
    183 
    184     // By default, tests end when page load is complete. These methods are used
    185     // to delay the completion of the test until notifyDone is called.
    186     void waitUntilDone(const CppArgumentList&, CppVariant*);
    187     void notifyDone(const CppArgumentList&, CppVariant*);
    188 
    189     // Methods for adding actions to the work queue. Used in conjunction with
    190     // waitUntilDone/notifyDone above.
    191     void queueBackNavigation(const CppArgumentList&, CppVariant*);
    192     void queueForwardNavigation(const CppArgumentList&, CppVariant*);
    193     void queueReload(const CppArgumentList&, CppVariant*);
    194     void queueLoadingScript(const CppArgumentList&, CppVariant*);
    195     void queueNonLoadingScript(const CppArgumentList&, CppVariant*);
    196     void queueLoad(const CppArgumentList&, CppVariant*);
    197     void queueLoadHTMLString(const CppArgumentList&, CppVariant*);
    198 
    199 
    200     // Causes navigation actions just printout the intended navigation instead
    201     // of taking you to the page. This is used for cases like mailto, where you
    202     // don't actually want to open the mail program.
    203     void setCustomPolicyDelegate(const CppArgumentList&, CppVariant*);
    204 
    205     // Delays completion of the test until the policy delegate runs.
    206     void waitForPolicyDelegate(const CppArgumentList&, CppVariant*);
    207 
    208     // Functions for dealing with windows. By default we block all new windows.
    209     void windowCount(const CppArgumentList&, CppVariant*);
    210     void setCloseRemainingWindowsWhenComplete(const CppArgumentList&, CppVariant*);
    211 
    212     void resetTestHelperControllers(const CppArgumentList&, CppVariant*);
    213 
    214     ///////////////////////////////////////////////////////////////////////////
    215     // Methods implemented entirely in terms of chromium's public WebKit API
    216 
    217     // Method that controls whether pressing Tab key cycles through page elements
    218     // or inserts a '\t' char in text area
    219     void setTabKeyCyclesThroughElements(const CppArgumentList&, CppVariant*);
    220 
    221     // Executes an internal command (superset of document.execCommand() commands).
    222     void execCommand(const CppArgumentList&, CppVariant*);
    223 
    224     // Checks if an internal command is currently available.
    225     void isCommandEnabled(const CppArgumentList&, CppVariant*);
    226 
    227     void callShouldCloseOnWebView(const CppArgumentList&, CppVariant*);
    228     void setDomainRelaxationForbiddenForURLScheme(const CppArgumentList&, CppVariant*);
    229     void evaluateScriptInIsolatedWorldAndReturnValue(const CppArgumentList&, CppVariant*);
    230     void evaluateScriptInIsolatedWorld(const CppArgumentList&, CppVariant*);
    231     void setIsolatedWorldSecurityOrigin(const CppArgumentList&, CppVariant*);
    232     void setIsolatedWorldContentSecurityPolicy(const CppArgumentList&, CppVariant*);
    233 
    234     // Allows layout tests to manage origins' whitelisting.
    235     void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
    236     void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
    237 
    238     // Returns true if the current page box has custom page size style for
    239     // printing.
    240     void hasCustomPageSizeStyle(const CppArgumentList&, CppVariant*);
    241 
    242     // Forces the selection colors for testing under Linux.
    243     void forceRedSelectionColors(const CppArgumentList&, CppVariant*);
    244 
    245     // Adds a style sheet to be injected into new documents.
    246     void injectStyleSheet(const CppArgumentList&, CppVariant*);
    247 
    248     void startSpeechInput(const CppArgumentList&, CppVariant*);
    249 
    250     void findString(const CppArgumentList&, CppVariant*);
    251 
    252     // Expects the first argument to be an input element and the second argument to be a string value.
    253     // Forwards the setValueForUser() call to the element.
    254     void setValueForUser(const CppArgumentList&, CppVariant*);
    255 
    256     void selectionAsMarkup(const CppArgumentList&, CppVariant*);
    257 
    258     // Enables or disables subpixel positioning (i.e. fractional X positions for
    259     // glyphs) in text rendering on Linux. Since this method changes global
    260     // settings, tests that call it must use their own custom font family for
    261     // all text that they render. If not, an already-cached style will be used,
    262     // resulting in the changed setting being ignored.
    263     void setTextSubpixelPositioning(const CppArgumentList&, CppVariant*);
    264 
    265     // Switch the visibility of the page.
    266     void setPageVisibility(const CppArgumentList&, CppVariant*);
    267 
    268     // Changes the direction of the focused element.
    269     void setTextDirection(const CppArgumentList&, CppVariant*);
    270 
    271     // Retrieves the text surrounding a position in a text node.
    272     // Expects the first argument to be a text node, the second and third to be
    273     // point coordinates relative to the node and the fourth the maximum text
    274     // length to retrieve.
    275     void textSurroundingNode(const CppArgumentList&, CppVariant*);
    276 
    277     // After this function is called, all window-sizing machinery is
    278     // short-circuited inside the renderer. This mode is necessary for
    279     // some tests that were written before browsers had multi-process architecture
    280     // and rely on window resizes to happen synchronously.
    281     // The function has "unfortunate" it its name because we must strive to remove all tests
    282     // that rely on this... well, unfortunate behavior. See http://crbug.com/309760 for the plan.
    283     void useUnfortunateSynchronousResizeMode(const CppArgumentList&, CppVariant*);
    284 
    285     void enableAutoResizeMode(const CppArgumentList&, CppVariant*);
    286     void disableAutoResizeMode(const CppArgumentList&, CppVariant*);
    287 
    288     // Device Motion / Device Orientation related functions
    289     void setMockDeviceMotion(const CppArgumentList&, CppVariant*);
    290     void setMockDeviceOrientation(const CppArgumentList&, CppVariant*);
    291 
    292     void didAcquirePointerLock(const CppArgumentList&, CppVariant*);
    293     void didNotAcquirePointerLock(const CppArgumentList&, CppVariant*);
    294     void didLosePointerLock(const CppArgumentList&, CppVariant*);
    295     void setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant*);
    296     void setPointerLockWillRespondAsynchronously(const CppArgumentList&, CppVariant*);
    297 
    298     ///////////////////////////////////////////////////////////////////////////
    299     // Methods modifying WebPreferences.
    300 
    301     // Set the WebPreference that controls webkit's popup blocking.
    302     void setPopupBlockingEnabled(const CppArgumentList&, CppVariant*);
    303 
    304     void setJavaScriptCanAccessClipboard(const CppArgumentList&, CppVariant*);
    305     void setXSSAuditorEnabled(const CppArgumentList&, CppVariant*);
    306     void setAllowUniversalAccessFromFileURLs(const CppArgumentList&, CppVariant*);
    307     void setAllowFileAccessFromFileURLs(const CppArgumentList&, CppVariant*);
    308     void overridePreference(const CppArgumentList&, CppVariant*);
    309 
    310     // Enable or disable plugins.
    311     void setPluginsEnabled(const CppArgumentList&, CppVariant*);
    312 
    313     ///////////////////////////////////////////////////////////////////////////
    314     // Methods that modify the state of TestRunner
    315 
    316     // This function sets a flag that tells the test_shell to print a line of
    317     // descriptive text for each editing command. It takes no arguments, and
    318     // ignores any that may be present.
    319     void dumpEditingCallbacks(const CppArgumentList&, CppVariant*);
    320 
    321     // This function sets a flag that tells the test_shell to dump pages as
    322     // plain text, rather than as a text representation of the renderer's state.
    323     // The pixel results will not be generated for this test.
    324     void dumpAsText(const CppArgumentList&, CppVariant*);
    325 
    326     // This function sets a flag that tells the test_shell to dump pages as
    327     // plain text, rather than as a text representation of the renderer's state.
    328     // It will also generate a pixel dump for the test.
    329     void dumpAsTextWithPixelResults(const CppArgumentList&, CppVariant*);
    330 
    331     // This function sets a flag that tells the test_shell to print out the
    332     // scroll offsets of the child frames. It ignores all.
    333     void dumpChildFrameScrollPositions(const CppArgumentList&, CppVariant*);
    334 
    335     // This function sets a flag that tells the test_shell to recursively
    336     // dump all frames as plain text if the dumpAsText flag is set.
    337     // It takes no arguments, and ignores any that may be present.
    338     void dumpChildFramesAsText(const CppArgumentList&, CppVariant*);
    339 
    340     // This function sets a flag that tells the test_shell to print out the
    341     // information about icon changes notifications from WebKit.
    342     void dumpIconChanges(const CppArgumentList&, CppVariant*);
    343 
    344     // Deals with Web Audio WAV file data.
    345     void setAudioData(const CppArgumentList&, CppVariant*);
    346 
    347     // This function sets a flag that tells the test_shell to print a line of
    348     // descriptive text for each frame load callback. It takes no arguments, and
    349     // ignores any that may be present.
    350     void dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant*);
    351 
    352     // This function sets a flag that tells the test_shell to print a line of
    353     // descriptive text for each PingLoader dispatch. It takes no arguments, and
    354     // ignores any that may be present.
    355     void dumpPingLoaderCallbacks(const CppArgumentList&, CppVariant*);
    356 
    357     // This function sets a flag that tells the test_shell to print a line of
    358     // user gesture status text for some frame load callbacks. It takes no
    359     // arguments, and ignores any that may be present.
    360     void dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant*);
    361 
    362     void dumpTitleChanges(const CppArgumentList&, CppVariant*);
    363 
    364     // This function sets a flag that tells the test_shell to dump all calls to
    365     // WebViewClient::createView().
    366     // It takes no arguments, and ignores any that may be present.
    367     void dumpCreateView(const CppArgumentList&, CppVariant*);
    368 
    369     void setCanOpenWindows(const CppArgumentList&, CppVariant*);
    370 
    371     // This function sets a flag that tells the test_shell to dump a descriptive
    372     // line for each resource load callback. It takes no arguments, and ignores
    373     // any that may be present.
    374     void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);
    375 
    376     // This function sets a flag that tells the test_shell to print a line of
    377     // descriptive text for each element that requested a resource. It takes no
    378     // arguments, and ignores any that may be present.
    379     void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*);
    380 
    381     // This function sets a flag that tells the test_shell to dump the MIME type
    382     // for each resource that was loaded. It takes no arguments, and ignores any
    383     // that may be present.
    384     void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
    385 
    386     // WebPermissionClient related.
    387     void setImagesAllowed(const CppArgumentList&, CppVariant*);
    388     void setScriptsAllowed(const CppArgumentList&, CppVariant*);
    389     void setStorageAllowed(const CppArgumentList&, CppVariant*);
    390     void setPluginsAllowed(const CppArgumentList&, CppVariant*);
    391     void setAllowDisplayOfInsecureContent(const CppArgumentList&, CppVariant*);
    392     void setAllowRunningOfInsecureContent(const CppArgumentList&, CppVariant*);
    393     void dumpPermissionClientCallbacks(const CppArgumentList&, CppVariant*);
    394 
    395     // This function sets a flag that tells the test_shell to dump all calls
    396     // to window.status().
    397     // It takes no arguments, and ignores any that may be present.
    398     void dumpWindowStatusChanges(const CppArgumentList&, CppVariant*);
    399 
    400     // This function sets a flag that tells the test_shell to print a line of
    401     // descriptive text for the progress finished callback. It takes no
    402     // arguments, and ignores any that may be present.
    403     void dumpProgressFinishedCallback(const CppArgumentList&, CppVariant*);
    404 
    405     // This function sets a flag that tells the test_shell to dump all
    406     // the lines of descriptive text about spellcheck execution.
    407     void dumpSpellCheckCallbacks(const CppArgumentList&, CppVariant*);
    408 
    409     // This function sets a flag that tells the test_shell to print out a text
    410     // representation of the back/forward list. It ignores all arguments.
    411     void dumpBackForwardList(const CppArgumentList&, CppVariant*);
    412 
    413     void setDeferMainResourceDataLoad(const CppArgumentList&, CppVariant*);
    414     void dumpSelectionRect(const CppArgumentList&, CppVariant*);
    415     void testRepaint(const CppArgumentList&, CppVariant*);
    416     void repaintSweepHorizontally(const CppArgumentList&, CppVariant*);
    417 
    418     // Causes layout to happen as if targetted to printed pages.
    419     void setPrinting(const CppArgumentList&, CppVariant*);
    420 
    421     void setShouldStayOnPageAfterHandlingBeforeUnload(const CppArgumentList&, CppVariant*);
    422 
    423     // Causes WillSendRequest to clear certain headers.
    424     void setWillSendRequestClearHeader(const CppArgumentList&, CppVariant*);
    425 
    426     // This function sets a flag that tells the test_shell to dump a descriptive
    427     // line for each resource load's priority and any time that priority
    428     // changes. It takes no arguments, and ignores any that may be present.
    429     void dumpResourceRequestPriorities(const CppArgumentList&, CppVariant*);
    430 
    431     ///////////////////////////////////////////////////////////////////////////
    432     // Methods interacting with the WebTestProxy
    433 
    434     ///////////////////////////////////////////////////////////////////////////
    435     // Methods forwarding to the WebTestDelegate
    436 
    437     // Shows DevTools window.
    438     void showWebInspector(const CppArgumentList&, CppVariant*);
    439     void closeWebInspector(const CppArgumentList&, CppVariant*);
    440 
    441     // Inspect chooser state
    442     void isChooserShown(const CppArgumentList&, CppVariant*);
    443 
    444     // Allows layout tests to exec scripts at WebInspector side.
    445     void evaluateInWebInspector(const CppArgumentList&, CppVariant*);
    446 
    447     // Clears all databases.
    448     void clearAllDatabases(const CppArgumentList&, CppVariant*);
    449     // Sets the default quota for all origins
    450     void setDatabaseQuota(const CppArgumentList&, CppVariant*);
    451 
    452     // Changes the cookie policy from the default to allow all cookies.
    453     void setAlwaysAcceptCookies(const CppArgumentList&, CppVariant*);
    454 
    455     // Gives focus to the window.
    456     void setWindowIsKey(const CppArgumentList&, CppVariant*);
    457 
    458     // Converts a URL starting with file:///tmp/ to the local mapping.
    459     void pathToLocalResource(const CppArgumentList&, CppVariant*);
    460 
    461     // Used to set the device scale factor.
    462     void setBackingScaleFactor(const CppArgumentList&, CppVariant*);
    463 
    464     // Calls setlocale(LC_ALL, ...) for a specified locale.
    465     // Resets between tests.
    466     void setPOSIXLocale(const CppArgumentList&, CppVariant*);
    467 
    468     // Gets the number of geolocation permissions requests pending.
    469     void numberOfPendingGeolocationPermissionRequests(const CppArgumentList&, CppVariant*);
    470 
    471     // Geolocation related functions.
    472     void setGeolocationPermission(const CppArgumentList&, CppVariant*);
    473     void setMockGeolocationPosition(const CppArgumentList&, CppVariant*);
    474     void setMockGeolocationPositionUnavailableError(const CppArgumentList&, CppVariant*);
    475 
    476     // MIDI function to control permission handling.
    477     void setMIDIAccessorResult(const CppArgumentList&, CppVariant*);
    478     void setMIDISysExPermission(const CppArgumentList&, CppVariant*);
    479 
    480     // Grants permission for desktop notifications to an origin
    481     void grantWebNotificationPermission(const CppArgumentList&, CppVariant*);
    482     // Simulates a click on a desktop notification.
    483     void simulateLegacyWebNotificationClick(const CppArgumentList&, CppVariant*);
    484     // Cancel all active desktop notifications.
    485     void cancelAllActiveNotifications(const CppArgumentList& arguments, CppVariant* result);
    486 
    487     // Speech input related functions.
    488     void addMockSpeechInputResult(const CppArgumentList&, CppVariant*);
    489     void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*);
    490     void addMockSpeechRecognitionResult(const CppArgumentList&, CppVariant*);
    491     void setMockSpeechRecognitionError(const CppArgumentList&, CppVariant*);
    492     void wasMockSpeechRecognitionAborted(const CppArgumentList&, CppVariant*);
    493 
    494     // WebPageOverlay related functions. Permits the adding and removing of only
    495     // one opaque overlay.
    496     void addWebPageOverlay(const CppArgumentList&, CppVariant*);
    497     void removeWebPageOverlay(const CppArgumentList&, CppVariant*);
    498 
    499     void display(const CppArgumentList&, CppVariant*);
    500     void displayInvalidatedRegion(const CppArgumentList&, CppVariant*);
    501 
    502     //////////////////////////////////////////////////////////////////////////
    503     // Fallback and stub methods
    504 
    505     // The fallback method is called when a nonexistent method is called on
    506     // the layout test controller object.
    507     // It is usefull to catch typos in the JavaScript code (a few layout tests
    508     // do have typos in them) and it allows the script to continue running in
    509     // that case (as the Mac does).
    510     void fallbackMethod(const CppArgumentList&, CppVariant*);
    511 
    512     // Stub for not implemented methods.
    513     void notImplemented(const CppArgumentList&, CppVariant*);
    514 
    515     ///////////////////////////////////////////////////////////////////////////
    516     // Internal helpers
    517     void checkResponseMimeType();
    518     void completeNotifyDone();
    519     class HostMethodTask : public WebMethodTask<TestRunner> {
    520     public:
    521         typedef void (TestRunner::*CallbackMethodType)();
    522         HostMethodTask(TestRunner* object, CallbackMethodType callback)
    523             : WebMethodTask<TestRunner>(object)
    524             , m_callback(callback)
    525         { }
    526 
    527         virtual void runIfValid() { (m_object->*m_callback)(); }
    528 
    529     private:
    530         CallbackMethodType m_callback;
    531     };
    532     class TestPageOverlay : public blink::WebPageOverlay {
    533     public:
    534         explicit TestPageOverlay(blink::WebView*);
    535         virtual void paintPageOverlay(blink::WebCanvas*) OVERRIDE;
    536         virtual ~TestPageOverlay();
    537     private:
    538         blink::WebView* m_webView;
    539     };
    540     void didAcquirePointerLockInternal();
    541     void didNotAcquirePointerLockInternal();
    542     void didLosePointerLockInternal();
    543 
    544     bool cppVariantToBool(const CppVariant&);
    545     int32_t cppVariantToInt32(const CppVariant&);
    546     blink::WebString cppVariantToWebString(const CppVariant&);
    547 
    548     void printErrorMessage(const std::string&);
    549 
    550     // In the Mac code, this is called to trigger the end of a test after the
    551     // page has finished loading. From here, we can generate the dump for the
    552     // test.
    553     void locationChangeDone();
    554 
    555     bool m_testIsRunning;
    556 
    557     // When reset is called, go through and close all but the main test shell
    558     // window. By default, set to true but toggled to false using
    559     // setCloseRemainingWindowsWhenComplete().
    560     bool m_closeRemainingWindows;
    561 
    562     // If true, don't dump output until notifyDone is called.
    563     bool m_waitUntilDone;
    564 
    565     // Causes navigation actions just printout the intended navigation instead
    566     // of taking you to the page. This is used for cases like mailto, where you
    567     // don't actually want to open the mail program.
    568     bool m_policyDelegateEnabled;
    569 
    570     // Toggles the behavior of the policy delegate. If true, then navigations
    571     // will be allowed. Otherwise, they will be ignored (dropped).
    572     bool m_policyDelegateIsPermissive;
    573 
    574     // If true, the policy delegate will signal layout test completion.
    575     bool m_policyDelegateShouldNotifyDone;
    576 
    577     WorkQueue m_workQueue;
    578 
    579     // globalFlag is used by a number of layout tests in http/tests/security/dataURL.
    580     CppVariant m_globalFlag;
    581 
    582     // Bound variable to return the name of this platform (chromium).
    583     CppVariant m_platformName;
    584 
    585     // Bound variable counting the number of top URLs visited.
    586     CppVariant m_webHistoryItemCount;
    587 
    588     // Bound variable to set whether postMessages should be intercepted or not
    589     CppVariant m_interceptPostMessage;
    590 
    591     // Bound variable to store the last tooltip text
    592     CppVariant m_tooltipText;
    593 
    594     // Bound variable to disable notifyDone calls. This is used in GC leak
    595     // tests, where existing LayoutTests are loaded within an iframe. The GC
    596     // test harness will set this flag to ignore the notifyDone calls from the
    597     // target LayoutTest.
    598     CppVariant m_disableNotifyDone;
    599 
    600     // If true, the test_shell will write a descriptive line for each editing
    601     // command.
    602     bool m_dumpEditingCallbacks;
    603 
    604     // If true, the test_shell will generate pixel results in dumpAsText mode
    605     bool m_generatePixelResults;
    606 
    607     // If true, the test_shell will produce a plain text dump rather than a
    608     // text representation of the renderer.
    609     bool m_dumpAsText;
    610 
    611     // If true and if dump_as_text_ is true, the test_shell will recursively
    612     // dump all frames as plain text.
    613     bool m_dumpChildFramesAsText;
    614 
    615     // If true, the test_shell will produce a dump of the DOM rather than a text
    616     // representation of the renderer.
    617     bool m_dumpAsMarkup;
    618 
    619     // If true, the test_shell will print out the child frame scroll offsets as
    620     // well.
    621     bool m_dumpChildFrameScrollPositions;
    622 
    623     // If true, the test_shell will print out the icon change notifications.
    624     bool m_dumpIconChanges;
    625 
    626     // If true, the test_shell will output a base64 encoded WAVE file.
    627     bool m_dumpAsAudio;
    628 
    629     // If true, the test_shell will output a descriptive line for each frame
    630     // load callback.
    631     bool m_dumpFrameLoadCallbacks;
    632 
    633     // If true, the test_shell will output a descriptive line for each
    634     // PingLoader dispatched.
    635     bool m_dumpPingLoaderCallbacks;
    636 
    637     // If true, the test_shell will output a line of the user gesture status
    638     // text for some frame load callbacks.
    639     bool m_dumpUserGestureInFrameLoadCallbacks;
    640 
    641     // If true, output a message when the page title is changed.
    642     bool m_dumpTitleChanges;
    643 
    644     // If true, output a descriptive line each time WebViewClient::createView
    645     // is invoked.
    646     bool m_dumpCreateView;
    647 
    648     // If true, new windows can be opened via javascript or by plugins. By
    649     // default, set to false and can be toggled to true using
    650     // setCanOpenWindows().
    651     bool m_canOpenWindows;
    652 
    653     // If true, the test_shell will output a descriptive line for each resource
    654     // load callback.
    655     bool m_dumpResourceLoadCallbacks;
    656 
    657     // If true, the test_shell will output a descriptive line for each resource
    658     // request callback.
    659     bool m_dumpResourceRequestCallbacks;
    660 
    661     // If true, the test_shell will output the MIME type for each resource that
    662     // was loaded.
    663     bool m_dumpResourceResponseMIMETypes;
    664 
    665     // If true, the test_shell will dump all changes to window.status.
    666     bool m_dumpWindowStatusChanges;
    667 
    668     // If true, the test_shell will output a descriptive line for the progress
    669     // finished callback.
    670     bool m_dumpProgressFinishedCallback;
    671 
    672     // If true, the test_shell will output descriptive test for spellcheck
    673     // execution.
    674     bool m_dumpSpellCheckCallbacks;
    675 
    676     // If true, the test_shell will produce a dump of the back forward list as
    677     // well.
    678     bool m_dumpBackForwardList;
    679 
    680     // If false, all new requests will not defer the main resource data load.
    681     bool m_deferMainResourceDataLoad;
    682 
    683     // If true, the test_shell will draw the bounds of the current selection rect
    684     // taking possible transforms of the selection rect into account.
    685     bool m_dumpSelectionRect;
    686 
    687     // If true, pixel dump will be produced as a series of 1px-tall, view-wide
    688     // individual paints over the height of the view.
    689     bool m_testRepaint;
    690 
    691     // If true and test_repaint_ is true as well, pixel dump will be produced as
    692     // a series of 1px-wide, view-tall paints across the width of the view.
    693     bool m_sweepHorizontally;
    694 
    695     // If true, layout is to target printed pages.
    696     bool m_isPrinting;
    697 
    698     // If false, MockWebMIDIAccessor fails on startSession() for testing.
    699     bool m_midiAccessorResult;
    700 
    701     bool m_shouldStayOnPageAfterHandlingBeforeUnload;
    702 
    703     bool m_shouldDumpResourcePriorities;
    704 
    705     std::set<std::string> m_httpHeadersToClear;
    706 
    707     // WAV audio data is stored here.
    708     blink::WebArrayBufferView m_audioData;
    709 
    710     // Used for test timeouts.
    711     WebTaskList m_taskList;
    712 
    713     TestInterfaces* m_testInterfaces;
    714     WebTestDelegate* m_delegate;
    715     blink::WebView* m_webView;
    716     TestPageOverlay* m_pageOverlay;
    717     WebTestProxyBase* m_proxy;
    718 
    719     // This is non-0 IFF a load is in progress.
    720     blink::WebFrame* m_topLoadingFrame;
    721 
    722     // WebPermissionClient mock object.
    723     WebScopedPtr<WebPermissions> m_webPermissions;
    724 
    725     WebScopedPtr<NotificationPresenter> m_notificationPresenter;
    726 
    727     bool m_pointerLocked;
    728     enum {
    729         PointerLockWillSucceed,
    730         PointerLockWillRespondAsync,
    731         PointerLockWillFailSync,
    732     } m_pointerLockPlannedResult;
    733 };
    734 
    735 }
    736 
    737 #endif // TestRunner_h
    738