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