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