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