Home | History | Annotate | Download | only in test_runner
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_
      6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_
      7 
      8 #include <deque>
      9 #include <set>
     10 #include <string>
     11 
     12 #include "base/memory/scoped_ptr.h"
     13 #include "base/memory/weak_ptr.h"
     14 #include "content/shell/renderer/test_runner/web_task.h"
     15 #include "content/shell/renderer/test_runner/web_test_runner.h"
     16 #include "v8/include/v8.h"
     17 
     18 class GURL;
     19 class SkBitmap;
     20 
     21 namespace blink {
     22 class WebFrame;
     23 class WebNotificationPresenter;
     24 class WebPermissionClient;
     25 class WebString;
     26 class WebView;
     27 class WebURLResponse;
     28 }
     29 
     30 namespace gin {
     31 class ArrayBufferView;
     32 class Arguments;
     33 }
     34 
     35 namespace content {
     36 
     37 class InvokeCallbackTask;
     38 class NotificationPresenter;
     39 class TestInterfaces;
     40 class TestPageOverlay;
     41 class WebPermissions;
     42 class WebTestDelegate;
     43 class WebTestProxyBase;
     44 
     45 class TestRunner : public WebTestRunner,
     46                    public base::SupportsWeakPtr<TestRunner> {
     47  public:
     48   explicit TestRunner(TestInterfaces*);
     49   virtual ~TestRunner();
     50 
     51   void Install(blink::WebFrame* frame);
     52 
     53   void SetDelegate(WebTestDelegate*);
     54   void SetWebView(blink::WebView*, WebTestProxyBase*);
     55 
     56   void Reset();
     57 
     58   WebTaskList* mutable_task_list() { return &task_list_; }
     59 
     60   void SetTestIsRunning(bool);
     61   bool TestIsRunning() const { return test_is_running_; }
     62 
     63   bool UseMockTheme() const { return use_mock_theme_; }
     64 
     65   void InvokeCallback(scoped_ptr<InvokeCallbackTask> callback);
     66 
     67   // WebTestRunner implementation.
     68   virtual bool ShouldGeneratePixelResults() OVERRIDE;
     69   virtual bool ShouldDumpAsAudio() const OVERRIDE;
     70   virtual void GetAudioData(
     71       std::vector<unsigned char>* buffer_view) const OVERRIDE;
     72   virtual bool ShouldDumpBackForwardList() const OVERRIDE;
     73   virtual blink::WebPermissionClient* GetWebPermissions() const OVERRIDE;
     74 
     75   // Methods used by WebTestProxyBase.
     76   bool shouldDumpSelectionRect() const;
     77   bool isPrinting() const;
     78   bool shouldDumpAsText();
     79   bool shouldDumpAsTextWithPixelResults();
     80   bool shouldDumpAsCustomText() const;
     81   std:: string customDumpText() const;
     82   bool shouldDumpAsMarkup();
     83   bool shouldDumpChildFrameScrollPositions() const;
     84   bool shouldDumpChildFramesAsMarkup() const;
     85   bool shouldDumpChildFramesAsText() const;
     86   void ShowDevTools(const std::string& settings,
     87                     const std::string& frontend_url);
     88   void ClearDevToolsLocalStorage();
     89   void setShouldDumpAsText(bool);
     90   void setShouldDumpAsMarkup(bool);
     91   void setCustomTextOutput(std::string text);
     92   void setShouldGeneratePixelResults(bool);
     93   void setShouldDumpFrameLoadCallbacks(bool);
     94   void setShouldDumpPingLoaderCallbacks(bool);
     95   void setShouldEnableViewSource(bool);
     96   bool shouldDumpEditingCallbacks() const;
     97   bool shouldDumpFrameLoadCallbacks() const;
     98   bool shouldDumpPingLoaderCallbacks() const;
     99   bool shouldDumpUserGestureInFrameLoadCallbacks() const;
    100   bool shouldDumpTitleChanges() const;
    101   bool shouldDumpIconChanges() const;
    102   bool shouldDumpCreateView() const;
    103   bool canOpenWindows() const;
    104   bool shouldDumpResourceLoadCallbacks() const;
    105   bool shouldDumpResourceRequestCallbacks() const;
    106   bool shouldDumpResourceResponseMIMETypes() const;
    107   bool shouldDumpStatusCallbacks() const;
    108   bool shouldDumpProgressFinishedCallback() const;
    109   bool shouldDumpSpellCheckCallbacks() const;
    110   bool shouldStayOnPageAfterHandlingBeforeUnload() const;
    111   bool shouldWaitUntilExternalURLLoad() const;
    112   const std::set<std::string>* httpHeadersToClear() const;
    113   void setTopLoadingFrame(blink::WebFrame*, bool);
    114   blink::WebFrame* topLoadingFrame() const;
    115   void policyDelegateDone();
    116   bool policyDelegateEnabled() const;
    117   bool policyDelegateIsPermissive() const;
    118   bool policyDelegateShouldNotifyDone() const;
    119   bool shouldInterceptPostMessage() const;
    120   bool shouldDumpResourcePriorities() const;
    121   blink::WebNotificationPresenter* notification_presenter() const;
    122   bool RequestPointerLock();
    123   void RequestPointerUnlock();
    124   bool isPointerLocked();
    125   void setToolTipText(const blink::WebString&);
    126 
    127   bool midiAccessorResult();
    128 
    129   // A single item in the work queue.
    130   class WorkItem {
    131    public:
    132     virtual ~WorkItem() {}
    133 
    134     // Returns true if this started a load.
    135     virtual bool Run(WebTestDelegate*, blink::WebView*) = 0;
    136   };
    137 
    138  private:
    139   friend class InvokeCallbackTask;
    140   friend class TestRunnerBindings;
    141   friend class WorkQueue;
    142 
    143   // Helper class for managing events queued by methods like queueLoad or
    144   // queueScript.
    145   class WorkQueue {
    146    public:
    147     explicit WorkQueue(TestRunner* controller);
    148     virtual ~WorkQueue();
    149     void ProcessWorkSoon();
    150 
    151     // Reset the state of the class between tests.
    152     void Reset();
    153 
    154     void AddWork(WorkItem*);
    155 
    156     void set_frozen(bool frozen) { frozen_ = frozen; }
    157     bool is_empty() { return queue_.empty(); }
    158     WebTaskList* mutable_task_list() { return &task_list_; }
    159 
    160    private:
    161     void ProcessWork();
    162 
    163     class WorkQueueTask : public WebMethodTask<WorkQueue> {
    164      public:
    165       WorkQueueTask(WorkQueue* object) : WebMethodTask<WorkQueue>(object) {}
    166 
    167       virtual void RunIfValid() OVERRIDE;
    168     };
    169 
    170     WebTaskList task_list_;
    171     std::deque<WorkItem*> queue_;
    172     bool frozen_;
    173     TestRunner* controller_;
    174   };
    175 
    176   ///////////////////////////////////////////////////////////////////////////
    177   // Methods dealing with the test logic
    178 
    179   // By default, tests end when page load is complete. These methods are used
    180   // to delay the completion of the test until notifyDone is called.
    181   void NotifyDone();
    182   void WaitUntilDone();
    183 
    184   // Methods for adding actions to the work queue. Used in conjunction with
    185   // waitUntilDone/notifyDone above.
    186   void QueueBackNavigation(int how_far_back);
    187   void QueueForwardNavigation(int how_far_forward);
    188   void QueueReload();
    189   void QueueLoadingScript(const std::string& script);
    190   void QueueNonLoadingScript(const std::string& script);
    191   void QueueLoad(const std::string& url, const std::string& target);
    192   void QueueLoadHTMLString(gin::Arguments* args);
    193 
    194   // Causes navigation actions just printout the intended navigation instead
    195   // of taking you to the page. This is used for cases like mailto, where you
    196   // don't actually want to open the mail program.
    197   void SetCustomPolicyDelegate(gin::Arguments* args);
    198 
    199   // Delays completion of the test until the policy delegate runs.
    200   void WaitForPolicyDelegate();
    201 
    202   // Functions for dealing with windows. By default we block all new windows.
    203   int WindowCount();
    204   void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows);
    205   void ResetTestHelperControllers();
    206 
    207   ///////////////////////////////////////////////////////////////////////////
    208   // Methods implemented entirely in terms of chromium's public WebKit API
    209 
    210   // Method that controls whether pressing Tab key cycles through page elements
    211   // or inserts a '\t' char in text area
    212   void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements);
    213 
    214   // Executes an internal command (superset of document.execCommand() commands).
    215   void ExecCommand(gin::Arguments* args);
    216 
    217   // Checks if an internal command is currently available.
    218   bool IsCommandEnabled(const std::string& command);
    219 
    220   bool CallShouldCloseOnWebView();
    221   void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
    222                                                 const std::string& scheme);
    223   v8::Handle<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
    224       int world_id, const std::string& script);
    225   void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script);
    226   void SetIsolatedWorldSecurityOrigin(int world_id,
    227                                       v8::Handle<v8::Value> origin);
    228   void SetIsolatedWorldContentSecurityPolicy(int world_id,
    229                                              const std::string& policy);
    230 
    231   // Allows layout tests to manage origins' whitelisting.
    232   void AddOriginAccessWhitelistEntry(const std::string& source_origin,
    233                                      const std::string& destination_protocol,
    234                                      const std::string& destination_host,
    235                                      bool allow_destination_subdomains);
    236   void RemoveOriginAccessWhitelistEntry(const std::string& source_origin,
    237                                         const std::string& destination_protocol,
    238                                         const std::string& destination_host,
    239                                         bool allow_destination_subdomains);
    240 
    241   // Returns true if the current page box has custom page size style for
    242   // printing.
    243   bool HasCustomPageSizeStyle(int page_index);
    244 
    245   // Forces the selection colors for testing under Linux.
    246   void ForceRedSelectionColors();
    247 
    248   // Adds a style sheet to be injected into new documents.
    249   void InjectStyleSheet(const std::string& source_code, bool all_frames);
    250 
    251   bool FindString(const std::string& search_text,
    252                   const std::vector<std::string>& options_array);
    253 
    254   std::string SelectionAsMarkup();
    255 
    256   // Enables or disables subpixel positioning (i.e. fractional X positions for
    257   // glyphs) in text rendering on Linux. Since this method changes global
    258   // settings, tests that call it must use their own custom font family for
    259   // all text that they render. If not, an already-cached style will be used,
    260   // resulting in the changed setting being ignored.
    261   void SetTextSubpixelPositioning(bool value);
    262 
    263   // Switch the visibility of the page.
    264   void SetPageVisibility(const std::string& new_visibility);
    265 
    266   // Changes the direction of the focused element.
    267   void SetTextDirection(const std::string& direction_name);
    268 
    269   // After this function is called, all window-sizing machinery is
    270   // short-circuited inside the renderer. This mode is necessary for
    271   // some tests that were written before browsers had multi-process architecture
    272   // and rely on window resizes to happen synchronously.
    273   // The function has "unfortunate" it its name because we must strive to remove
    274   // all tests that rely on this... well, unfortunate behavior. See
    275   // http://crbug.com/309760 for the plan.
    276   void UseUnfortunateSynchronousResizeMode();
    277 
    278   bool EnableAutoResizeMode(int min_width,
    279                             int min_height,
    280                             int max_width,
    281                             int max_height);
    282   bool DisableAutoResizeMode(int new_width, int new_height);
    283 
    284   void SetMockDeviceLight(double value);
    285   void ResetDeviceLight();
    286   // Device Motion / Device Orientation related functions
    287   void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x,
    288                            bool has_acceleration_y, double acceleration_y,
    289                            bool has_acceleration_z, double acceleration_z,
    290                            bool has_acceleration_including_gravity_x,
    291                            double acceleration_including_gravity_x,
    292                            bool has_acceleration_including_gravity_y,
    293                            double acceleration_including_gravity_y,
    294                            bool has_acceleration_including_gravity_z,
    295                            double acceleration_including_gravity_z,
    296                            bool has_rotation_rate_alpha,
    297                            double rotation_rate_alpha,
    298                            bool has_rotation_rate_beta,
    299                            double rotation_rate_beta,
    300                            bool has_rotation_rate_gamma,
    301                            double rotation_rate_gamma,
    302                            double interval);
    303   void SetMockDeviceOrientation(bool has_alpha, double alpha,
    304                                 bool has_beta, double beta,
    305                                 bool has_gamma, double gamma,
    306                                 bool has_absolute, bool absolute);
    307 
    308   void SetMockScreenOrientation(const std::string& orientation);
    309 
    310   void DidChangeBatteryStatus(bool charging,
    311                               double chargingTime,
    312                               double dischargingTime,
    313                               double level);
    314   void ResetBatteryStatus();
    315 
    316   void DidAcquirePointerLock();
    317   void DidNotAcquirePointerLock();
    318   void DidLosePointerLock();
    319   void SetPointerLockWillFailSynchronously();
    320   void SetPointerLockWillRespondAsynchronously();
    321 
    322   ///////////////////////////////////////////////////////////////////////////
    323   // Methods modifying WebPreferences.
    324 
    325   // Set the WebPreference that controls webkit's popup blocking.
    326   void SetPopupBlockingEnabled(bool block_popups);
    327 
    328   void SetJavaScriptCanAccessClipboard(bool can_access);
    329   void SetXSSAuditorEnabled(bool enabled);
    330   void SetAllowUniversalAccessFromFileURLs(bool allow);
    331   void SetAllowFileAccessFromFileURLs(bool allow);
    332   void OverridePreference(const std::string key, v8::Handle<v8::Value> value);
    333 
    334   // Modify accept_languages in RendererPreferences.
    335   void SetAcceptLanguages(const std::string& accept_languages);
    336 
    337   // Enable or disable plugins.
    338   void SetPluginsEnabled(bool enabled);
    339 
    340   ///////////////////////////////////////////////////////////////////////////
    341   // Methods that modify the state of TestRunner
    342 
    343   // This function sets a flag that tells the test_shell to print a line of
    344   // descriptive text for each editing command. It takes no arguments, and
    345   // ignores any that may be present.
    346   void DumpEditingCallbacks();
    347 
    348   // This function sets a flag that tells the test_shell to dump pages as
    349   // plain text, rather than as a text representation of the renderer's state.
    350   // The pixel results will not be generated for this test.
    351   void DumpAsText();
    352 
    353   // This function sets a flag that tells the test_shell to dump pages as
    354   // the DOM contents, rather than as a text representation of the renderer's
    355   // state. The pixel results will not be generated for this test.
    356   void DumpAsMarkup();
    357 
    358   // This function sets a flag that tells the test_shell to dump pages as
    359   // plain text, rather than as a text representation of the renderer's state.
    360   // It will also generate a pixel dump for the test.
    361   void DumpAsTextWithPixelResults();
    362 
    363   // This function sets a flag that tells the test_shell to print out the
    364   // scroll offsets of the child frames. It ignores all.
    365   void DumpChildFrameScrollPositions();
    366 
    367   // This function sets a flag that tells the test_shell to recursively
    368   // dump all frames as plain text if the DumpAsText flag is set.
    369   // It takes no arguments, and ignores any that may be present.
    370   void DumpChildFramesAsText();
    371 
    372   // This function sets a flag that tells the test_shell to recursively
    373   // dump all frames as the DOM contents if the DumpAsMarkup flag is set.
    374   // It takes no arguments, and ignores any that may be present.
    375   void DumpChildFramesAsMarkup();
    376 
    377   // This function sets a flag that tells the test_shell to print out the
    378   // information about icon changes notifications from WebKit.
    379   void DumpIconChanges();
    380 
    381   // Deals with Web Audio WAV file data.
    382   void SetAudioData(const gin::ArrayBufferView& view);
    383 
    384   // This function sets a flag that tells the test_shell to print a line of
    385   // descriptive text for each frame load callback. It takes no arguments, and
    386   // ignores any that may be present.
    387   void DumpFrameLoadCallbacks();
    388 
    389   // This function sets a flag that tells the test_shell to print a line of
    390   // descriptive text for each PingLoader dispatch. It takes no arguments, and
    391   // ignores any that may be present.
    392   void DumpPingLoaderCallbacks();
    393 
    394   // This function sets a flag that tells the test_shell to print a line of
    395   // user gesture status text for some frame load callbacks. It takes no
    396   // arguments, and ignores any that may be present.
    397   void DumpUserGestureInFrameLoadCallbacks();
    398 
    399   void DumpTitleChanges();
    400 
    401   // This function sets a flag that tells the test_shell to dump all calls to
    402   // WebViewClient::createView().
    403   // It takes no arguments, and ignores any that may be present.
    404   void DumpCreateView();
    405 
    406   void SetCanOpenWindows();
    407 
    408   // This function sets a flag that tells the test_shell to dump a descriptive
    409   // line for each resource load callback. It takes no arguments, and ignores
    410   // any that may be present.
    411   void DumpResourceLoadCallbacks();
    412 
    413   // This function sets a flag that tells the test_shell to print a line of
    414   // descriptive text for each element that requested a resource. It takes no
    415   // arguments, and ignores any that may be present.
    416   void DumpResourceRequestCallbacks();
    417 
    418   // This function sets a flag that tells the test_shell to dump the MIME type
    419   // for each resource that was loaded. It takes no arguments, and ignores any
    420   // that may be present.
    421   void DumpResourceResponseMIMETypes();
    422 
    423   // WebPermissionClient related.
    424   void SetImagesAllowed(bool allowed);
    425   void SetMediaAllowed(bool allowed);
    426   void SetScriptsAllowed(bool allowed);
    427   void SetStorageAllowed(bool allowed);
    428   void SetPluginsAllowed(bool allowed);
    429   void SetAllowDisplayOfInsecureContent(bool allowed);
    430   void SetAllowRunningOfInsecureContent(bool allowed);
    431   void DumpPermissionClientCallbacks();
    432 
    433   // This function sets a flag that tells the test_shell to dump all calls
    434   // to window.status().
    435   // It takes no arguments, and ignores any that may be present.
    436   void DumpWindowStatusChanges();
    437 
    438   // This function sets a flag that tells the test_shell to print a line of
    439   // descriptive text for the progress finished callback. It takes no
    440   // arguments, and ignores any that may be present.
    441   void DumpProgressFinishedCallback();
    442 
    443   // This function sets a flag that tells the test_shell to dump all
    444   // the lines of descriptive text about spellcheck execution.
    445   void DumpSpellCheckCallbacks();
    446 
    447   // This function sets a flag that tells the test_shell to print out a text
    448   // representation of the back/forward list. It ignores all arguments.
    449   void DumpBackForwardList();
    450 
    451   void DumpSelectionRect();
    452 
    453   // Causes layout to happen as if targetted to printed pages.
    454   void SetPrinting();
    455 
    456   // Clears the state from SetPrinting().
    457   void ClearPrinting();
    458 
    459   void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value);
    460 
    461   // Causes WillSendRequest to clear certain headers.
    462   void SetWillSendRequestClearHeader(const std::string& header);
    463 
    464   // This function sets a flag that tells the test_shell to dump a descriptive
    465   // line for each resource load's priority and any time that priority
    466   // changes. It takes no arguments, and ignores any that may be present.
    467   void DumpResourceRequestPriorities();
    468 
    469   // Sets a flag to enable the mock theme.
    470   void SetUseMockTheme(bool use);
    471 
    472   // Sets a flag that causes the test to be marked as completed when the
    473   // WebFrameClient receives a loadURLExternally() call.
    474   void WaitUntilExternalURLLoad();
    475 
    476   ///////////////////////////////////////////////////////////////////////////
    477   // Methods interacting with the WebTestProxy
    478 
    479   ///////////////////////////////////////////////////////////////////////////
    480   // Methods forwarding to the WebTestDelegate
    481 
    482   // Shows DevTools window.
    483   void ShowWebInspector(const std::string& str,
    484                         const std::string& frontend_url);
    485   void CloseWebInspector();
    486 
    487   // Inspect chooser state
    488   bool IsChooserShown();
    489 
    490   // Allows layout tests to exec scripts at WebInspector side.
    491   void EvaluateInWebInspector(int call_id, const std::string& script);
    492 
    493   // Clears all databases.
    494   void ClearAllDatabases();
    495   // Sets the default quota for all origins
    496   void SetDatabaseQuota(int quota);
    497 
    498   // Changes the cookie policy from the default to allow all cookies.
    499   void SetAlwaysAcceptCookies(bool accept);
    500 
    501   // Gives focus to the window.
    502   void SetWindowIsKey(bool value);
    503 
    504   // Converts a URL starting with file:///tmp/ to the local mapping.
    505   std::string PathToLocalResource(const std::string& path);
    506 
    507   // Used to set the device scale factor.
    508   void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback);
    509 
    510   // Change the device color profile while running a layout test.
    511   void SetColorProfile(const std::string& name,
    512                        v8::Handle<v8::Function> callback);
    513 
    514   // Calls setlocale(LC_ALL, ...) for a specified locale.
    515   // Resets between tests.
    516   void SetPOSIXLocale(const std::string& locale);
    517 
    518   // MIDI function to control permission handling.
    519   void SetMIDIAccessorResult(bool result);
    520   void SetMIDISysexPermission(bool value);
    521 
    522   // Grants permission for desktop notifications to an origin
    523   void GrantWebNotificationPermission(const GURL& origin,
    524                                       bool permission_granted);
    525 
    526   // Clears all previously granted Web Notification permissions.
    527   void ClearWebNotificationPermissions();
    528 
    529   // Simulates a click on a desktop notification.
    530   bool SimulateWebNotificationClick(const std::string& value);
    531 
    532   // Speech recognition related functions.
    533   void AddMockSpeechRecognitionResult(const std::string& transcript,
    534                                       double confidence);
    535   void SetMockSpeechRecognitionError(const std::string& error,
    536                                      const std::string& message);
    537   bool WasMockSpeechRecognitionAborted();
    538 
    539   // Credential Manager mock functions
    540   // TODO(mkwst): Support FederatedCredential.
    541   void AddMockCredentialManagerResponse(const std::string& id,
    542                                         const std::string& name,
    543                                         const std::string& avatar,
    544                                         const std::string& password);
    545 
    546   // WebPageOverlay related functions. Permits the adding and removing of only
    547   // one opaque overlay.
    548   void AddWebPageOverlay();
    549   void RemoveWebPageOverlay();
    550 
    551   void DisplayAsync();
    552   void DisplayAsyncThen(v8::Handle<v8::Function> callback);
    553 
    554   // Similar to DisplayAsyncThen(), but pass parameters of the captured
    555   // snapshot (width, height, snapshot) to the callback. The snapshot is in
    556   // uint8 RGBA format.
    557   void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback);
    558   // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image
    559   // located at a particular point in the WebView (if there is such an image),
    560   // reads back its pixels, and provides the snapshot to the callback. If there
    561   // is no image at that point, calls the callback with (0, 0, empty_snapshot).
    562   void CopyImageAtAndCapturePixelsAsyncThen(
    563       int x, int y, const v8::Handle<v8::Function> callback);
    564 
    565   void SetMockPushClientSuccess(const std::string& endpoint,
    566                                 const std::string& registration_id);
    567   void SetMockPushClientError(const std::string& message);
    568 
    569   void GetManifestThen(v8::Handle<v8::Function> callback);
    570 
    571   ///////////////////////////////////////////////////////////////////////////
    572   // Internal helpers
    573 
    574   void GetManifestCallback(scoped_ptr<InvokeCallbackTask> task,
    575                            const blink::WebURLResponse& response,
    576                            const std::string& data);
    577   void CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
    578                              const SkBitmap& snapshot);
    579 
    580   void CheckResponseMimeType();
    581   void CompleteNotifyDone();
    582 
    583   void DidAcquirePointerLockInternal();
    584   void DidNotAcquirePointerLockInternal();
    585   void DidLosePointerLockInternal();
    586 
    587   // In the Mac code, this is called to trigger the end of a test after the
    588   // page has finished loading. From here, we can generate the dump for the
    589   // test.
    590   void LocationChangeDone();
    591 
    592   bool test_is_running_;
    593 
    594   // When reset is called, go through and close all but the main test shell
    595   // window. By default, set to true but toggled to false using
    596   // setCloseRemainingWindowsWhenComplete().
    597   bool close_remaining_windows_;
    598 
    599   // If true, don't dump output until notifyDone is called.
    600   bool wait_until_done_;
    601 
    602   // If true, ends the test when a URL is loaded externally via
    603   // WebFrameClient::loadURLExternally().
    604   bool wait_until_external_url_load_;
    605 
    606   // Causes navigation actions just printout the intended navigation instead
    607   // of taking you to the page. This is used for cases like mailto, where you
    608   // don't actually want to open the mail program.
    609   bool policy_delegate_enabled_;
    610 
    611   // Toggles the behavior of the policy delegate. If true, then navigations
    612   // will be allowed. Otherwise, they will be ignored (dropped).
    613   bool policy_delegate_is_permissive_;
    614 
    615   // If true, the policy delegate will signal layout test completion.
    616   bool policy_delegate_should_notify_done_;
    617 
    618   WorkQueue work_queue_;
    619 
    620   // Bound variable to return the name of this platform (chromium).
    621   std::string platform_name_;
    622 
    623   // Bound variable to store the last tooltip text
    624   std::string tooltip_text_;
    625 
    626   // Bound variable to disable notifyDone calls. This is used in GC leak
    627   // tests, where existing LayoutTests are loaded within an iframe. The GC
    628   // test harness will set this flag to ignore the notifyDone calls from the
    629   // target LayoutTest.
    630   bool disable_notify_done_;
    631 
    632   // Bound variable counting the number of top URLs visited.
    633   int web_history_item_count_;
    634 
    635   // Bound variable to set whether postMessages should be intercepted or not
    636   bool intercept_post_message_;
    637 
    638   // If true, the test_shell will write a descriptive line for each editing
    639   // command.
    640   bool dump_editting_callbacks_;
    641 
    642   // If true, the test_shell will generate pixel results in DumpAsText mode
    643   bool generate_pixel_results_;
    644 
    645   // If true, the test_shell will produce a plain text dump rather than a
    646   // text representation of the renderer.
    647   bool dump_as_text_;
    648 
    649   // If true and if dump_as_text_ is true, the test_shell will recursively
    650   // dump all frames as plain text.
    651   bool dump_child_frames_as_text_;
    652 
    653   // If true, the test_shell will produce a dump of the DOM rather than a text
    654   // representation of the renderer.
    655   bool dump_as_markup_;
    656 
    657   // If true and if dump_as_markup_ is true, the test_shell will recursively
    658   // produce a dump of the DOM rather than a text representation of the
    659   // renderer.
    660   bool dump_child_frames_as_markup_;
    661 
    662   // If true, the test_shell will print out the child frame scroll offsets as
    663   // well.
    664   bool dump_child_frame_scroll_positions_;
    665 
    666   // If true, the test_shell will print out the icon change notifications.
    667   bool dump_icon_changes_;
    668 
    669   // If true, the test_shell will output a base64 encoded WAVE file.
    670   bool dump_as_audio_;
    671 
    672   // If true, the test_shell will output a descriptive line for each frame
    673   // load callback.
    674   bool dump_frame_load_callbacks_;
    675 
    676   // If true, the test_shell will output a descriptive line for each
    677   // PingLoader dispatched.
    678   bool dump_ping_loader_callbacks_;
    679 
    680   // If true, the test_shell will output a line of the user gesture status
    681   // text for some frame load callbacks.
    682   bool dump_user_gesture_in_frame_load_callbacks_;
    683 
    684   // If true, output a message when the page title is changed.
    685   bool dump_title_changes_;
    686 
    687   // If true, output a descriptive line each time WebViewClient::createView
    688   // is invoked.
    689   bool dump_create_view_;
    690 
    691   // If true, new windows can be opened via javascript or by plugins. By
    692   // default, set to false and can be toggled to true using
    693   // setCanOpenWindows().
    694   bool can_open_windows_;
    695 
    696   // If true, the test_shell will output a descriptive line for each resource
    697   // load callback.
    698   bool dump_resource_load_callbacks_;
    699 
    700   // If true, the test_shell will output a descriptive line for each resource
    701   // request callback.
    702   bool dump_resource_request_callbacks_;
    703 
    704   // If true, the test_shell will output the MIME type for each resource that
    705   // was loaded.
    706   bool dump_resource_reqponse_mime_types_;
    707 
    708   // If true, the test_shell will dump all changes to window.status.
    709   bool dump_window_status_changes_;
    710 
    711   // If true, the test_shell will output a descriptive line for the progress
    712   // finished callback.
    713   bool dump_progress_finished_callback_;
    714 
    715   // If true, the test_shell will output descriptive test for spellcheck
    716   // execution.
    717   bool dump_spell_check_callbacks_;
    718 
    719   // If true, the test_shell will produce a dump of the back forward list as
    720   // well.
    721   bool dump_back_forward_list_;
    722 
    723   // If true, the test_shell will draw the bounds of the current selection rect
    724   // taking possible transforms of the selection rect into account.
    725   bool dump_selection_rect_;
    726 
    727   // If true, pixel dump will be produced as a series of 1px-tall, view-wide
    728   // individual paints over the height of the view.
    729   bool test_repaint_;
    730 
    731   // If true and test_repaint_ is true as well, pixel dump will be produced as
    732   // a series of 1px-wide, view-tall paints across the width of the view.
    733   bool sweep_horizontally_;
    734 
    735   // If true, layout is to target printed pages.
    736   bool is_printing_;
    737 
    738   // If false, MockWebMIDIAccessor fails on startSession() for testing.
    739   bool midi_accessor_result_;
    740 
    741   bool should_stay_on_page_after_handling_before_unload_;
    742 
    743   bool should_dump_resource_priorities_;
    744 
    745   bool has_custom_text_output_;
    746   std::string custom_text_output_;
    747 
    748   std::set<std::string> http_headers_to_clear_;
    749 
    750   // WAV audio data is stored here.
    751   std::vector<unsigned char> audio_data_;
    752 
    753   // Used for test timeouts.
    754   WebTaskList task_list_;
    755 
    756   TestInterfaces* test_interfaces_;
    757   WebTestDelegate* delegate_;
    758   blink::WebView* web_view_;
    759   TestPageOverlay* page_overlay_;
    760   WebTestProxyBase* proxy_;
    761 
    762   // This is non-0 IFF a load is in progress.
    763   blink::WebFrame* top_loading_frame_;
    764 
    765   // WebPermissionClient mock object.
    766   scoped_ptr<WebPermissions> web_permissions_;
    767 
    768   scoped_ptr<NotificationPresenter> notification_presenter_;
    769 
    770   bool pointer_locked_;
    771   enum {
    772     PointerLockWillSucceed,
    773     PointerLockWillRespondAsync,
    774     PointerLockWillFailSync,
    775   } pointer_lock_planned_result_;
    776   bool use_mock_theme_;
    777 
    778   base::WeakPtrFactory<TestRunner> weak_factory_;
    779 
    780   DISALLOW_COPY_AND_ASSIGN(TestRunner);
    781 };
    782 
    783 }  // namespace content
    784 
    785 #endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_RUNNER_H_
    786