| OLD | NEW |
| (Empty) |
| 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 COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | |
| 6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <deque> | |
| 11 #include <memory> | |
| 12 #include <set> | |
| 13 #include <string> | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "base/macros.h" | |
| 17 #include "base/memory/weak_ptr.h" | |
| 18 #include "components/test_runner/layout_test_runtime_flags.h" | |
| 19 #include "components/test_runner/test_runner_export.h" | |
| 20 #include "components/test_runner/web_test_runner.h" | |
| 21 #include "media/midi/midi_service.mojom.h" | |
| 22 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" | |
| 23 #include "third_party/WebKit/public/platform/WebImage.h" | |
| 24 #include "v8/include/v8.h" | |
| 25 | |
| 26 class GURL; | |
| 27 class SkBitmap; | |
| 28 | |
| 29 namespace base { | |
| 30 class NullableString16; | |
| 31 } | |
| 32 | |
| 33 namespace blink { | |
| 34 class WebContentSettingsClient; | |
| 35 class WebFrame; | |
| 36 class WebLocalFrame; | |
| 37 class WebString; | |
| 38 class WebView; | |
| 39 } | |
| 40 | |
| 41 namespace gin { | |
| 42 class ArrayBufferView; | |
| 43 class Arguments; | |
| 44 } | |
| 45 | |
| 46 namespace test_runner { | |
| 47 | |
| 48 class MockContentSettingsClient; | |
| 49 class MockCredentialManagerClient; | |
| 50 class MockScreenOrientationClient; | |
| 51 class MockWebSpeechRecognizer; | |
| 52 class MockWebUserMediaClient; | |
| 53 class SpellCheckClient; | |
| 54 class TestInterfaces; | |
| 55 class TestRunnerForSpecificView; | |
| 56 class WebTestDelegate; | |
| 57 | |
| 58 // TestRunner class currently has dual purpose: | |
| 59 // 1. It implements |testRunner| javascript bindings for "global" / "ambient". | |
| 60 // Examples: | |
| 61 // - testRunner.dumpAsText (test flag affecting test behavior) | |
| 62 // - testRunner.setAllowRunningOfInsecureContent (test flag affecting product | |
| 63 // behavior) | |
| 64 // - testRunner.setTextSubpixelPositioning (directly interacts with product). | |
| 65 // Note that "per-view" (non-"global") bindings are handled by | |
| 66 // instances of TestRunnerForSpecificView class. | |
| 67 // 2. It manages global test state. Example: | |
| 68 // - Tracking topLoadingFrame that can finish the test when it loads. | |
| 69 // - WorkQueue holding load requests from the TestInterfaces | |
| 70 // - LayoutTestRuntimeFlags | |
| 71 class TestRunner : public WebTestRunner { | |
| 72 public: | |
| 73 explicit TestRunner(TestInterfaces*); | |
| 74 virtual ~TestRunner(); | |
| 75 | |
| 76 void Install(blink::WebLocalFrame* frame, | |
| 77 base::WeakPtr<TestRunnerForSpecificView> view_test_runner); | |
| 78 | |
| 79 void SetDelegate(WebTestDelegate*); | |
| 80 void SetMainView(blink::WebView*); | |
| 81 | |
| 82 void Reset(); | |
| 83 | |
| 84 void SetTestIsRunning(bool); | |
| 85 bool TestIsRunning() const { return test_is_running_; } | |
| 86 | |
| 87 bool UseMockTheme() const { return use_mock_theme_; } | |
| 88 | |
| 89 // WebTestRunner implementation. | |
| 90 bool ShouldGeneratePixelResults() override; | |
| 91 bool ShouldDumpAsAudio() const override; | |
| 92 void GetAudioData(std::vector<unsigned char>* buffer_view) const override; | |
| 93 bool IsRecursiveLayoutDumpRequested() override; | |
| 94 std::string DumpLayout(blink::WebLocalFrame* frame) override; | |
| 95 void DumpPixelsAsync( | |
| 96 blink::WebView* web_view, | |
| 97 const base::Callback<void(const SkBitmap&)>& callback) override; | |
| 98 void ReplicateLayoutTestRuntimeFlagsChanges( | |
| 99 const base::DictionaryValue& changed_values) override; | |
| 100 bool HasCustomTextDump(std::string* custom_text_dump) const override; | |
| 101 bool ShouldDumpBackForwardList() const override; | |
| 102 blink::WebContentSettingsClient* GetWebContentSettings() const override; | |
| 103 void InitializeWebViewWithMocks(blink::WebView* web_view) override; | |
| 104 void SetFocus(blink::WebView* web_view, bool focus) override; | |
| 105 | |
| 106 // Methods used by WebViewTestClient and WebFrameTestClient. | |
| 107 void OnNavigationBegin(blink::WebFrame* frame); | |
| 108 void OnNavigationEnd() { will_navigate_ = false; } | |
| 109 std::string GetAcceptLanguages() const; | |
| 110 bool shouldStayOnPageAfterHandlingBeforeUnload() const; | |
| 111 MockScreenOrientationClient* getMockScreenOrientationClient(); | |
| 112 MockWebUserMediaClient* getMockWebUserMediaClient(); | |
| 113 MockWebSpeechRecognizer* getMockWebSpeechRecognizer(); | |
| 114 bool isPrinting() const; | |
| 115 bool shouldDumpAsCustomText() const; | |
| 116 std:: string customDumpText() const; | |
| 117 void ShowDevTools(const std::string& settings, | |
| 118 const std::string& frontend_url); | |
| 119 void ClearDevToolsLocalStorage(); | |
| 120 void SetV8CacheDisabled(bool); | |
| 121 void setShouldDumpAsText(bool); | |
| 122 void setShouldDumpAsMarkup(bool); | |
| 123 void setCustomTextOutput(const std::string& text); | |
| 124 void setShouldGeneratePixelResults(bool); | |
| 125 void setShouldDumpFrameLoadCallbacks(bool); | |
| 126 void setShouldEnableViewSource(bool); | |
| 127 bool shouldDumpEditingCallbacks() const; | |
| 128 bool shouldDumpFrameLoadCallbacks() const; | |
| 129 bool shouldDumpPingLoaderCallbacks() const; | |
| 130 bool shouldDumpUserGestureInFrameLoadCallbacks() const; | |
| 131 bool shouldDumpTitleChanges() const; | |
| 132 bool shouldDumpIconChanges() const; | |
| 133 bool shouldDumpCreateView() const; | |
| 134 bool canOpenWindows() const; | |
| 135 bool shouldDumpResourceLoadCallbacks() const; | |
| 136 bool shouldDumpResourceResponseMIMETypes() const; | |
| 137 bool shouldDumpStatusCallbacks() const; | |
| 138 bool shouldDumpSpellCheckCallbacks() const; | |
| 139 bool shouldWaitUntilExternalURLLoad() const; | |
| 140 const std::set<std::string>* httpHeadersToClear() const; | |
| 141 bool is_web_platform_tests_mode() const { | |
| 142 return is_web_platform_tests_mode_; | |
| 143 } | |
| 144 void set_is_web_platform_tests_mode() { is_web_platform_tests_mode_ = true; } | |
| 145 | |
| 146 // To be called when |frame| starts loading - TestRunner will check if | |
| 147 // there is currently no top-loading-frame being tracked and if so, then it | |
| 148 // will return true and start tracking |frame| as the top-loading-frame. | |
| 149 bool tryToSetTopLoadingFrame(blink::WebFrame* frame); | |
| 150 | |
| 151 // To be called when |frame| finishes loading - TestRunner will check if | |
| 152 // |frame| is currently tracked as the top-loading-frame, and if yes, then it | |
| 153 // will return true, stop top-loading-frame tracking, and potentially finish | |
| 154 // the test (unless testRunner.waitUntilDone() was called and/or there are | |
| 155 // pending load requests in WorkQueue). | |
| 156 bool tryToClearTopLoadingFrame(blink::WebFrame*); | |
| 157 | |
| 158 blink::WebFrame* mainFrame() const; | |
| 159 blink::WebFrame* topLoadingFrame() const; | |
| 160 void policyDelegateDone(); | |
| 161 bool policyDelegateEnabled() const; | |
| 162 bool policyDelegateIsPermissive() const; | |
| 163 bool policyDelegateShouldNotifyDone() const; | |
| 164 void setToolTipText(const blink::WebString&); | |
| 165 void setDragImage(const blink::WebImage& drag_image); | |
| 166 bool shouldDumpNavigationPolicy() const; | |
| 167 | |
| 168 midi::mojom::Result midiAccessorResult(); | |
| 169 | |
| 170 // Methods used by MockColorChooser: | |
| 171 void DidOpenChooser(); | |
| 172 void DidCloseChooser(); | |
| 173 | |
| 174 bool ShouldDumpConsoleMessages() const; | |
| 175 bool ShouldDumpJavaScriptDialogs() const; | |
| 176 | |
| 177 blink::WebEffectiveConnectionType effective_connection_type() const { | |
| 178 return effective_connection_type_; | |
| 179 } | |
| 180 | |
| 181 // A single item in the work queue. | |
| 182 class WorkItem { | |
| 183 public: | |
| 184 virtual ~WorkItem() {} | |
| 185 | |
| 186 // Returns true if this started a load. | |
| 187 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0; | |
| 188 }; | |
| 189 | |
| 190 private: | |
| 191 friend class TestRunnerBindings; | |
| 192 friend class WorkQueue; | |
| 193 | |
| 194 // Helper class for managing events queued by methods like queueLoad or | |
| 195 // queueScript. | |
| 196 class WorkQueue { | |
| 197 public: | |
| 198 explicit WorkQueue(TestRunner* controller); | |
| 199 virtual ~WorkQueue(); | |
| 200 void ProcessWorkSoon(); | |
| 201 | |
| 202 // Reset the state of the class between tests. | |
| 203 void Reset(); | |
| 204 | |
| 205 void AddWork(WorkItem*); | |
| 206 | |
| 207 void set_frozen(bool frozen) { frozen_ = frozen; } | |
| 208 bool is_empty() { return queue_.empty(); } | |
| 209 | |
| 210 private: | |
| 211 void ProcessWork(); | |
| 212 | |
| 213 std::deque<WorkItem*> queue_; | |
| 214 bool frozen_; | |
| 215 TestRunner* controller_; | |
| 216 | |
| 217 base::WeakPtrFactory<WorkQueue> weak_factory_; | |
| 218 }; | |
| 219 | |
| 220 /////////////////////////////////////////////////////////////////////////// | |
| 221 // Methods dealing with the test logic | |
| 222 | |
| 223 // By default, tests end when page load is complete. These methods are used | |
| 224 // to delay the completion of the test until notifyDone is called. | |
| 225 void NotifyDone(); | |
| 226 void WaitUntilDone(); | |
| 227 | |
| 228 // Methods for adding actions to the work queue. Used in conjunction with | |
| 229 // waitUntilDone/notifyDone above. | |
| 230 void QueueBackNavigation(int how_far_back); | |
| 231 void QueueForwardNavigation(int how_far_forward); | |
| 232 void QueueReload(); | |
| 233 void QueueLoadingScript(const std::string& script); | |
| 234 void QueueNonLoadingScript(const std::string& script); | |
| 235 void QueueLoad(const std::string& url, const std::string& target); | |
| 236 | |
| 237 // Causes navigation actions just printout the intended navigation instead | |
| 238 // of taking you to the page. This is used for cases like mailto, where you | |
| 239 // don't actually want to open the mail program. | |
| 240 void SetCustomPolicyDelegate(gin::Arguments* args); | |
| 241 | |
| 242 // Delays completion of the test until the policy delegate runs. | |
| 243 void WaitForPolicyDelegate(); | |
| 244 | |
| 245 // Functions for dealing with windows. By default we block all new windows. | |
| 246 int WindowCount(); | |
| 247 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows); | |
| 248 void ResetTestHelperControllers(); | |
| 249 | |
| 250 // Allows layout tests to manage origins' whitelisting. | |
| 251 void AddOriginAccessWhitelistEntry(const std::string& source_origin, | |
| 252 const std::string& destination_protocol, | |
| 253 const std::string& destination_host, | |
| 254 bool allow_destination_subdomains); | |
| 255 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, | |
| 256 const std::string& destination_protocol, | |
| 257 const std::string& destination_host, | |
| 258 bool allow_destination_subdomains); | |
| 259 | |
| 260 // Add |source_code| as an injected stylesheet to the active document of the | |
| 261 // window of the current V8 context. | |
| 262 void InsertStyleSheet(const std::string& source_code); | |
| 263 | |
| 264 // Enables or disables subpixel positioning (i.e. fractional X positions for | |
| 265 // glyphs) in text rendering on Linux. Since this method changes global | |
| 266 // settings, tests that call it must use their own custom font family for | |
| 267 // all text that they render. If not, an already-cached style will be used, | |
| 268 // resulting in the changed setting being ignored. | |
| 269 void SetTextSubpixelPositioning(bool value); | |
| 270 | |
| 271 // After this function is called, all window-sizing machinery is | |
| 272 // short-circuited inside the renderer. This mode is necessary for | |
| 273 // some tests that were written before browsers had multi-process architecture | |
| 274 // and rely on window resizes to happen synchronously. | |
| 275 // The function has "unfortunate" it its name because we must strive to remove | |
| 276 // all tests that rely on this... well, unfortunate behavior. See | |
| 277 // http://crbug.com/309760 for the plan. | |
| 278 void UseUnfortunateSynchronousResizeMode(); | |
| 279 | |
| 280 bool EnableAutoResizeMode(int min_width, | |
| 281 int min_height, | |
| 282 int max_width, | |
| 283 int max_height); | |
| 284 bool DisableAutoResizeMode(int new_width, int new_height); | |
| 285 | |
| 286 void SetMockDeviceLight(double value); | |
| 287 void ResetDeviceLight(); | |
| 288 // Device Motion / Device Orientation related functions | |
| 289 void SetMockDeviceMotion(bool has_acceleration_x, double acceleration_x, | |
| 290 bool has_acceleration_y, double acceleration_y, | |
| 291 bool has_acceleration_z, double acceleration_z, | |
| 292 bool has_acceleration_including_gravity_x, | |
| 293 double acceleration_including_gravity_x, | |
| 294 bool has_acceleration_including_gravity_y, | |
| 295 double acceleration_including_gravity_y, | |
| 296 bool has_acceleration_including_gravity_z, | |
| 297 double acceleration_including_gravity_z, | |
| 298 bool has_rotation_rate_alpha, | |
| 299 double rotation_rate_alpha, | |
| 300 bool has_rotation_rate_beta, | |
| 301 double rotation_rate_beta, | |
| 302 bool has_rotation_rate_gamma, | |
| 303 double rotation_rate_gamma, | |
| 304 double interval); | |
| 305 void SetMockDeviceOrientation(bool has_alpha, double alpha, | |
| 306 bool has_beta, double beta, | |
| 307 bool has_gamma, double gamma, | |
| 308 bool absolute); | |
| 309 | |
| 310 void SetMockScreenOrientation(const std::string& orientation); | |
| 311 void DisableMockScreenOrientation(); | |
| 312 | |
| 313 /////////////////////////////////////////////////////////////////////////// | |
| 314 // Methods modifying WebPreferences. | |
| 315 | |
| 316 // Set the WebPreference that controls webkit's popup blocking. | |
| 317 void SetPopupBlockingEnabled(bool block_popups); | |
| 318 | |
| 319 void SetJavaScriptCanAccessClipboard(bool can_access); | |
| 320 void SetXSSAuditorEnabled(bool enabled); | |
| 321 void SetAllowUniversalAccessFromFileURLs(bool allow); | |
| 322 void SetAllowFileAccessFromFileURLs(bool allow); | |
| 323 void OverridePreference(const std::string& key, v8::Local<v8::Value> value); | |
| 324 | |
| 325 // Modify accept_languages in RendererPreferences. | |
| 326 void SetAcceptLanguages(const std::string& accept_languages); | |
| 327 | |
| 328 // Enable or disable plugins. | |
| 329 void SetPluginsEnabled(bool enabled); | |
| 330 | |
| 331 /////////////////////////////////////////////////////////////////////////// | |
| 332 // Methods that modify the state of TestRunner | |
| 333 | |
| 334 // This function sets a flag that tells the test_shell to print a line of | |
| 335 // descriptive text for each editing command. It takes no arguments, and | |
| 336 // ignores any that may be present. | |
| 337 void DumpEditingCallbacks(); | |
| 338 | |
| 339 // This function sets a flag that tells the test_shell to dump pages as | |
| 340 // plain text, rather than as a text representation of the renderer's state. | |
| 341 // The pixel results will not be generated for this test. | |
| 342 void DumpAsText(); | |
| 343 | |
| 344 // This function sets a flag that tells the test_shell to dump pages as | |
| 345 // the DOM contents, rather than as a text representation of the renderer's | |
| 346 // state. The pixel results will not be generated for this test. | |
| 347 void DumpAsMarkup(); | |
| 348 | |
| 349 // This function sets a flag that tells the test_shell to dump pages as | |
| 350 // plain text, rather than as a text representation of the renderer's state. | |
| 351 // It will also generate a pixel dump for the test. | |
| 352 void DumpAsTextWithPixelResults(); | |
| 353 | |
| 354 // This function sets a flag that tells the test_shell to print out the | |
| 355 // scroll offsets of the child frames. It ignores all. | |
| 356 void DumpChildFrameScrollPositions(); | |
| 357 | |
| 358 // This function sets a flag that tells the test_shell to recursively | |
| 359 // dump all frames as plain text if the DumpAsText flag is set. | |
| 360 // It takes no arguments, and ignores any that may be present. | |
| 361 void DumpChildFramesAsText(); | |
| 362 | |
| 363 // This function sets a flag that tells the test_shell to recursively | |
| 364 // dump all frames as the DOM contents if the DumpAsMarkup flag is set. | |
| 365 // It takes no arguments, and ignores any that may be present. | |
| 366 void DumpChildFramesAsMarkup(); | |
| 367 | |
| 368 // This function sets a flag that tells the test_shell to print out the | |
| 369 // information about icon changes notifications from WebKit. | |
| 370 void DumpIconChanges(); | |
| 371 | |
| 372 // Deals with Web Audio WAV file data. | |
| 373 void SetAudioData(const gin::ArrayBufferView& view); | |
| 374 | |
| 375 // This function sets a flag that tells the test_shell to print a line of | |
| 376 // descriptive text for each frame load callback. It takes no arguments, and | |
| 377 // ignores any that may be present. | |
| 378 void DumpFrameLoadCallbacks(); | |
| 379 | |
| 380 // This function sets a flag that tells the test_shell to print a line of | |
| 381 // descriptive text for each PingLoader dispatch. It takes no arguments, and | |
| 382 // ignores any that may be present. | |
| 383 void DumpPingLoaderCallbacks(); | |
| 384 | |
| 385 // This function sets a flag that tells the test_shell to print a line of | |
| 386 // user gesture status text for some frame load callbacks. It takes no | |
| 387 // arguments, and ignores any that may be present. | |
| 388 void DumpUserGestureInFrameLoadCallbacks(); | |
| 389 | |
| 390 void DumpTitleChanges(); | |
| 391 | |
| 392 // This function sets a flag that tells the test_shell to dump all calls to | |
| 393 // WebViewClient::createView(). | |
| 394 // It takes no arguments, and ignores any that may be present. | |
| 395 void DumpCreateView(); | |
| 396 | |
| 397 void SetCanOpenWindows(); | |
| 398 | |
| 399 // This function sets a flag that tells the test_shell to dump a descriptive | |
| 400 // line for each resource load callback. It takes no arguments, and ignores | |
| 401 // any that may be present. | |
| 402 void DumpResourceLoadCallbacks(); | |
| 403 | |
| 404 // This function sets a flag that tells the test_shell to dump the MIME type | |
| 405 // for each resource that was loaded. It takes no arguments, and ignores any | |
| 406 // that may be present. | |
| 407 void DumpResourceResponseMIMETypes(); | |
| 408 | |
| 409 // WebContentSettingsClient related. | |
| 410 void SetImagesAllowed(bool allowed); | |
| 411 void SetScriptsAllowed(bool allowed); | |
| 412 void SetStorageAllowed(bool allowed); | |
| 413 void SetPluginsAllowed(bool allowed); | |
| 414 void SetAllowRunningOfInsecureContent(bool allowed); | |
| 415 void SetAutoplayAllowed(bool allowed); | |
| 416 void DumpPermissionClientCallbacks(); | |
| 417 | |
| 418 // Sets up a mock DocumentSubresourceFilter to disallow subsequent subresource | |
| 419 // loads within the current document with the given path |suffixes|. The | |
| 420 // filter is created and injected even if |suffixes| is empty. If |suffixes| | |
| 421 // contains the empty string, all subresource loads will be disallowed. | |
| 422 void SetDisallowedSubresourcePathSuffixes( | |
| 423 const std::vector<std::string>& suffixes); | |
| 424 | |
| 425 // This function sets a flag that tells the test_shell to dump all calls | |
| 426 // to window.status(). | |
| 427 // It takes no arguments, and ignores any that may be present. | |
| 428 void DumpWindowStatusChanges(); | |
| 429 | |
| 430 // This function sets a flag that tells the test_shell to dump all | |
| 431 // the lines of descriptive text about spellcheck execution. | |
| 432 void DumpSpellCheckCallbacks(); | |
| 433 | |
| 434 // This function sets a flag that tells the test_shell to print out a text | |
| 435 // representation of the back/forward list. It ignores all arguments. | |
| 436 void DumpBackForwardList(); | |
| 437 | |
| 438 void DumpSelectionRect(); | |
| 439 | |
| 440 // Causes layout to happen as if targetted to printed pages. | |
| 441 void SetPrinting(); | |
| 442 | |
| 443 // Clears the state from SetPrinting(). | |
| 444 void ClearPrinting(); | |
| 445 | |
| 446 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); | |
| 447 | |
| 448 // Causes WillSendRequest to clear certain headers. | |
| 449 void SetWillSendRequestClearHeader(const std::string& header); | |
| 450 | |
| 451 // Sets a flag to enable the mock theme. | |
| 452 void SetUseMockTheme(bool use); | |
| 453 | |
| 454 // Sets a flag that causes the test to be marked as completed when the | |
| 455 // WebFrameClient receives a loadURLExternally() call. | |
| 456 void WaitUntilExternalURLLoad(); | |
| 457 | |
| 458 // This function sets a flag to dump the drag image when the next drag&drop is | |
| 459 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel | |
| 460 // results will be the drag image instead of a snapshot of the page. | |
| 461 void DumpDragImage(); | |
| 462 | |
| 463 // Sets a flag that tells the WebViewTestProxy to dump the default navigation | |
| 464 // policy passed to the decidePolicyForNavigation callback. | |
| 465 void DumpNavigationPolicy(); | |
| 466 | |
| 467 // Controls whether console messages produced by the page are dumped | |
| 468 // to test output. | |
| 469 void SetDumpConsoleMessages(bool value); | |
| 470 | |
| 471 // Controls whether JavaScript dialogs such as alert() are dumped to test | |
| 472 // output. | |
| 473 void SetDumpJavaScriptDialogs(bool value); | |
| 474 | |
| 475 // Overrides the NetworkQualityEstimator's estimated network type. If |type| | |
| 476 // is TypeUnknown the NQE's value is used. Be sure to call this with | |
| 477 // TypeUnknown at the end of your test if you use this. | |
| 478 void SetEffectiveConnectionType( | |
| 479 blink::WebEffectiveConnectionType connection_type); | |
| 480 | |
| 481 // Controls whether the mock spell checker is enabled. | |
| 482 void SetMockSpellCheckerEnabled(bool enabled); | |
| 483 | |
| 484 /////////////////////////////////////////////////////////////////////////// | |
| 485 // Methods interacting with the WebViewTestProxy | |
| 486 | |
| 487 /////////////////////////////////////////////////////////////////////////// | |
| 488 // Methods forwarding to the WebTestDelegate | |
| 489 | |
| 490 // Shows DevTools window. | |
| 491 void ShowWebInspector(const std::string& str, | |
| 492 const std::string& frontend_url); | |
| 493 void CloseWebInspector(); | |
| 494 | |
| 495 // Inspect chooser state | |
| 496 bool IsChooserShown(); | |
| 497 | |
| 498 // Allows layout tests to exec scripts at WebInspector side. | |
| 499 void EvaluateInWebInspector(int call_id, const std::string& script); | |
| 500 // Allows layout tests to evaluate scripts in InspectorOverlay page. | |
| 501 // Script may have an output represented as a string, return values of other | |
| 502 // types would be ignored. | |
| 503 std::string EvaluateInWebInspectorOverlay(const std::string& script); | |
| 504 | |
| 505 // Clears all databases. | |
| 506 void ClearAllDatabases(); | |
| 507 // Sets the default quota for all origins | |
| 508 void SetDatabaseQuota(int quota); | |
| 509 | |
| 510 // Sets the cookie policy to: | |
| 511 // - allow all cookies when |block| is false | |
| 512 // - block only third-party cookies when |block| is true | |
| 513 void SetBlockThirdPartyCookies(bool block); | |
| 514 | |
| 515 // Converts a URL starting with file:///tmp/ to the local mapping. | |
| 516 std::string PathToLocalResource(const std::string& path); | |
| 517 | |
| 518 // Sets the permission's |name| to |value| for a given {origin, embedder} | |
| 519 // tuple. | |
| 520 void SetPermission(const std::string& name, | |
| 521 const std::string& value, | |
| 522 const GURL& origin, | |
| 523 const GURL& embedding_origin); | |
| 524 | |
| 525 // Resolve the in-flight beforeinstallprompt event. | |
| 526 void ResolveBeforeInstallPromptPromise(const std::string& platform); | |
| 527 | |
| 528 // Calls setlocale(LC_ALL, ...) for a specified locale. | |
| 529 // Resets between tests. | |
| 530 void SetPOSIXLocale(const std::string& locale); | |
| 531 | |
| 532 // MIDI function to control permission handling. | |
| 533 void SetMIDIAccessorResult(midi::mojom::Result result); | |
| 534 | |
| 535 // Simulates a click on a Web Notification. | |
| 536 void SimulateWebNotificationClick(const std::string& title, | |
| 537 int action_index, | |
| 538 const base::NullableString16& reply); | |
| 539 | |
| 540 // Simulates closing a Web Notification. | |
| 541 void SimulateWebNotificationClose(const std::string& title, bool by_user); | |
| 542 | |
| 543 // Speech recognition related functions. | |
| 544 void AddMockSpeechRecognitionResult(const std::string& transcript, | |
| 545 double confidence); | |
| 546 void SetMockSpeechRecognitionError(const std::string& error, | |
| 547 const std::string& message); | |
| 548 | |
| 549 // Credential Manager mock functions | |
| 550 // TODO(mkwst): Support FederatedCredential. | |
| 551 void SetMockCredentialManagerResponse(const std::string& id, | |
| 552 const std::string& name, | |
| 553 const std::string& avatar, | |
| 554 const std::string& password); | |
| 555 void ClearMockCredentialManagerResponse(); | |
| 556 void SetMockCredentialManagerError(const std::string& error); | |
| 557 | |
| 558 // Takes care of notifying the delegate after a change to layout test runtime | |
| 559 // flags. | |
| 560 void OnLayoutTestRuntimeFlagsChanged(); | |
| 561 | |
| 562 /////////////////////////////////////////////////////////////////////////// | |
| 563 // Internal helpers | |
| 564 | |
| 565 bool IsFramePartOfMainTestWindow(blink::WebFrame*) const; | |
| 566 | |
| 567 void CheckResponseMimeType(); | |
| 568 | |
| 569 // In the Mac code, this is called to trigger the end of a test after the | |
| 570 // page has finished loading. From here, we can generate the dump for the | |
| 571 // test. | |
| 572 void LocationChangeDone(); | |
| 573 | |
| 574 bool test_is_running_; | |
| 575 | |
| 576 // When reset is called, go through and close all but the main test shell | |
| 577 // window. By default, set to true but toggled to false using | |
| 578 // setCloseRemainingWindowsWhenComplete(). | |
| 579 bool close_remaining_windows_; | |
| 580 | |
| 581 WorkQueue work_queue_; | |
| 582 | |
| 583 // Bound variable to return the name of this platform (chromium). | |
| 584 std::string platform_name_; | |
| 585 | |
| 586 // Bound variable to store the last tooltip text | |
| 587 std::string tooltip_text_; | |
| 588 | |
| 589 // Bound variable counting the number of top URLs visited. | |
| 590 int web_history_item_count_; | |
| 591 | |
| 592 // Flags controlling what content gets dumped as a layout text result. | |
| 593 LayoutTestRuntimeFlags layout_test_runtime_flags_; | |
| 594 | |
| 595 // If true, the test_shell will output a base64 encoded WAVE file. | |
| 596 bool dump_as_audio_; | |
| 597 | |
| 598 // If true, the test_shell will produce a dump of the back forward list as | |
| 599 // well. | |
| 600 bool dump_back_forward_list_; | |
| 601 | |
| 602 // If true, pixel dump will be produced as a series of 1px-tall, view-wide | |
| 603 // individual paints over the height of the view. | |
| 604 bool test_repaint_; | |
| 605 | |
| 606 // If true and test_repaint_ is true as well, pixel dump will be produced as | |
| 607 // a series of 1px-wide, view-tall paints across the width of the view. | |
| 608 bool sweep_horizontally_; | |
| 609 | |
| 610 // startSession() result of MockWebMIDIAccessor for testing. | |
| 611 midi::mojom::Result midi_accessor_result_; | |
| 612 | |
| 613 std::set<std::string> http_headers_to_clear_; | |
| 614 | |
| 615 // WAV audio data is stored here. | |
| 616 std::vector<unsigned char> audio_data_; | |
| 617 | |
| 618 TestInterfaces* test_interfaces_; | |
| 619 WebTestDelegate* delegate_; | |
| 620 blink::WebView* main_view_; | |
| 621 | |
| 622 // This is non-0 IFF a load is in progress. | |
| 623 blink::WebFrame* top_loading_frame_; | |
| 624 | |
| 625 // WebContentSettingsClient mock object. | |
| 626 std::unique_ptr<MockContentSettingsClient> mock_content_settings_client_; | |
| 627 | |
| 628 bool use_mock_theme_; | |
| 629 | |
| 630 // This is true in the period between the start of a navigation and when the | |
| 631 // provisional load for that navigation is started. Note that when | |
| 632 // browser-side navigation is enabled there is an arbitrary gap between these | |
| 633 // two events. | |
| 634 bool will_navigate_; | |
| 635 | |
| 636 std::unique_ptr<MockCredentialManagerClient> credential_manager_client_; | |
| 637 std::unique_ptr<MockScreenOrientationClient> mock_screen_orientation_client_; | |
| 638 std::unique_ptr<MockWebSpeechRecognizer> speech_recognizer_; | |
| 639 std::unique_ptr<MockWebUserMediaClient> user_media_client_; | |
| 640 std::unique_ptr<SpellCheckClient> spellcheck_; | |
| 641 | |
| 642 // Number of currently active color choosers. | |
| 643 int chooser_count_; | |
| 644 | |
| 645 // Captured drag image. | |
| 646 blink::WebImage drag_image_; | |
| 647 | |
| 648 // View that was focused by a previous call to TestRunner::SetFocus method. | |
| 649 // Note - this can be a dangling pointer to an already destroyed WebView (this | |
| 650 // is ok, because this is taken care of in WebTestDelegate::SetFocus). | |
| 651 blink::WebView* previously_focused_view_; | |
| 652 | |
| 653 // True if we run a test in LayoutTests/imported/{csswg-test,wpt}/. | |
| 654 bool is_web_platform_tests_mode_; | |
| 655 | |
| 656 // An effective connection type settable by layout tests. | |
| 657 blink::WebEffectiveConnectionType effective_connection_type_; | |
| 658 | |
| 659 // Forces v8 compilation cache to be disabled (used for inspector tests). | |
| 660 bool disable_v8_cache_ = false; | |
| 661 | |
| 662 base::WeakPtrFactory<TestRunner> weak_factory_; | |
| 663 | |
| 664 DISALLOW_COPY_AND_ASSIGN(TestRunner); | |
| 665 }; | |
| 666 | |
| 667 } // namespace test_runner | |
| 668 | |
| 669 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | |
| OLD | NEW |