Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | 5 #ifndef COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |
| 6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | 6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "components/test_runner/layout_test_runtime_flags.h" | 18 #include "components/test_runner/layout_test_runtime_flags.h" |
| 19 #include "components/test_runner/test_runner_export.h" | 19 #include "components/test_runner/test_runner_export.h" |
| 20 #include "components/test_runner/web_test_runner.h" | 20 #include "components/test_runner/web_test_runner.h" |
| 21 #include "third_party/WebKit/public/platform/WebImage.h" | 21 #include "third_party/WebKit/public/platform/WebImage.h" |
| 22 #include "v8/include/v8.h" | 22 #include "v8/include/v8.h" |
| 23 | 23 |
| 24 class GURL; | 24 class GURL; |
| 25 class SkBitmap; | 25 class SkBitmap; |
| 26 | 26 |
| 27 namespace blink { | 27 namespace blink { |
| 28 class WebContentSettingsClient; | 28 class WebContentSettingsClient; |
| 29 class WebFrame; | 29 class WebFrame; |
| 30 class WebLocalFrame; | |
| 30 class WebMediaStream; | 31 class WebMediaStream; |
| 31 class WebString; | 32 class WebString; |
| 32 class WebView; | 33 class WebView; |
| 33 class WebURLResponse; | 34 class WebURLResponse; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace gin { | 37 namespace gin { |
| 37 class ArrayBufferView; | 38 class ArrayBufferView; |
| 38 class Arguments; | 39 class Arguments; |
| 39 } | 40 } |
| 40 | 41 |
| 41 namespace test_runner { | 42 namespace test_runner { |
| 42 | 43 |
| 43 class InvokeCallbackTask; | 44 class InvokeCallbackTask; |
| 44 class MockContentSettingsClient; | 45 class MockContentSettingsClient; |
| 45 class MockCredentialManagerClient; | 46 class MockCredentialManagerClient; |
| 46 class MockScreenOrientationClient; | 47 class MockScreenOrientationClient; |
| 47 class MockWebSpeechRecognizer; | 48 class MockWebSpeechRecognizer; |
| 48 class MockWebUserMediaClient; | 49 class MockWebUserMediaClient; |
| 49 class SpellCheckClient; | 50 class SpellCheckClient; |
| 50 class TestInterfaces; | 51 class TestInterfaces; |
| 52 class TestRunnerForSpecificView; | |
| 51 class WebTestDelegate; | 53 class WebTestDelegate; |
| 52 class WebTestProxyBase; | 54 class WebTestProxyBase; |
| 53 | 55 |
| 54 class TestRunner : public WebTestRunner { | 56 class TestRunner : public WebTestRunner { |
| 55 public: | 57 public: |
| 56 explicit TestRunner(TestInterfaces*); | 58 explicit TestRunner(TestInterfaces*); |
| 57 virtual ~TestRunner(); | 59 virtual ~TestRunner(); |
| 58 | 60 |
| 59 void Install(blink::WebFrame* frame); | 61 void Install(blink::WebLocalFrame* frame, |
| 62 base::WeakPtr<TestRunnerForSpecificView> view_test_runner); | |
| 60 | 63 |
| 61 void SetDelegate(WebTestDelegate*); | 64 void SetDelegate(WebTestDelegate*); |
| 62 void SetWebView(blink::WebView*); | 65 void SetWebView(blink::WebView*); |
| 63 | 66 |
| 64 void Reset(); | 67 void Reset(); |
| 65 | 68 |
| 66 void SetTestIsRunning(bool); | 69 void SetTestIsRunning(bool); |
| 67 bool TestIsRunning() const { return test_is_running_; } | 70 bool TestIsRunning() const { return test_is_running_; } |
| 68 | 71 |
| 69 bool UseMockTheme() const { return use_mock_theme_; } | 72 bool UseMockTheme() const { return use_mock_theme_; } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 virtual ~WorkItem() {} | 149 virtual ~WorkItem() {} |
| 147 | 150 |
| 148 // Returns true if this started a load. | 151 // Returns true if this started a load. |
| 149 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0; | 152 virtual bool Run(WebTestDelegate*, blink::WebView*) = 0; |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 private: | 155 private: |
| 153 friend class TestRunnerBindings; | 156 friend class TestRunnerBindings; |
| 154 friend class WorkQueue; | 157 friend class WorkQueue; |
| 155 | 158 |
| 156 // Helpers for working with base and V8 callbacks. | 159 // Helpers for posting base::Closure via |delegate_|. |
| 157 void PostTask(const base::Closure& callback); | 160 void PostTask(const base::Closure& callback); |
| 158 void PostDelayedTask(long long delay, const base::Closure& callback); | 161 void PostDelayedTask(long long delay, const base::Closure& callback); |
| 159 void PostV8Callback(const v8::Local<v8::Function>& callback); | |
| 160 void PostV8CallbackWithArgs(v8::UniquePersistent<v8::Function> callback, | |
| 161 int argc, | |
| 162 v8::Local<v8::Value> argv[]); | |
| 163 void InvokeV8Callback(const v8::UniquePersistent<v8::Function>& callback); | |
| 164 void InvokeV8CallbackWithArgs( | |
| 165 const v8::UniquePersistent<v8::Function>& callback, | |
| 166 const std::vector<v8::UniquePersistent<v8::Value>>& args); | |
| 167 base::Closure CreateClosureThatPostsV8Callback( | |
| 168 const v8::Local<v8::Function>& callback); | |
| 169 | 162 |
| 170 // Helper class for managing events queued by methods like queueLoad or | 163 // Helper class for managing events queued by methods like queueLoad or |
| 171 // queueScript. | 164 // queueScript. |
| 172 class WorkQueue { | 165 class WorkQueue { |
| 173 public: | 166 public: |
| 174 explicit WorkQueue(TestRunner* controller); | 167 explicit WorkQueue(TestRunner* controller); |
| 175 virtual ~WorkQueue(); | 168 virtual ~WorkQueue(); |
| 176 void ProcessWorkSoon(); | 169 void ProcessWorkSoon(); |
| 177 | 170 |
| 178 // Reset the state of the class between tests. | 171 // Reset the state of the class between tests. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 void SetCustomPolicyDelegate(gin::Arguments* args); | 209 void SetCustomPolicyDelegate(gin::Arguments* args); |
| 217 | 210 |
| 218 // Delays completion of the test until the policy delegate runs. | 211 // Delays completion of the test until the policy delegate runs. |
| 219 void WaitForPolicyDelegate(); | 212 void WaitForPolicyDelegate(); |
| 220 | 213 |
| 221 // Functions for dealing with windows. By default we block all new windows. | 214 // Functions for dealing with windows. By default we block all new windows. |
| 222 int WindowCount(); | 215 int WindowCount(); |
| 223 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows); | 216 void SetCloseRemainingWindowsWhenComplete(bool close_remaining_windows); |
| 224 void ResetTestHelperControllers(); | 217 void ResetTestHelperControllers(); |
| 225 | 218 |
| 226 /////////////////////////////////////////////////////////////////////////// | |
| 227 // Methods implemented entirely in terms of chromium's public WebKit API | |
| 228 | |
| 229 // Method that controls whether pressing Tab key cycles through page elements | |
| 230 // or inserts a '\t' char in text area | |
| 231 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); | |
| 232 | |
| 233 // Executes an internal command (superset of document.execCommand() commands). | |
| 234 void ExecCommand(gin::Arguments* args); | |
| 235 | |
| 236 // Checks if an internal command is currently available. | |
| 237 bool IsCommandEnabled(const std::string& command); | |
| 238 | |
| 239 bool CallShouldCloseOnWebView(); | |
| 240 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | |
| 241 const std::string& scheme); | |
| 242 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( | |
| 243 int world_id, const std::string& script); | |
| 244 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); | |
| 245 void SetIsolatedWorldSecurityOrigin(int world_id, | |
| 246 v8::Local<v8::Value> origin); | |
| 247 void SetIsolatedWorldContentSecurityPolicy(int world_id, | |
| 248 const std::string& policy); | |
| 249 | |
| 250 // Allows layout tests to manage origins' whitelisting. | 219 // Allows layout tests to manage origins' whitelisting. |
| 251 void AddOriginAccessWhitelistEntry(const std::string& source_origin, | 220 void AddOriginAccessWhitelistEntry(const std::string& source_origin, |
| 252 const std::string& destination_protocol, | 221 const std::string& destination_protocol, |
| 253 const std::string& destination_host, | 222 const std::string& destination_host, |
| 254 bool allow_destination_subdomains); | 223 bool allow_destination_subdomains); |
| 255 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, | 224 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, |
| 256 const std::string& destination_protocol, | 225 const std::string& destination_protocol, |
| 257 const std::string& destination_host, | 226 const std::string& destination_host, |
| 258 bool allow_destination_subdomains); | 227 bool allow_destination_subdomains); |
| 259 | 228 |
| 260 // Returns true if the current page box has custom page size style for | |
| 261 // printing. | |
| 262 bool HasCustomPageSizeStyle(int page_index); | |
| 263 | |
| 264 // Forces the selection colors for testing under Linux. | |
| 265 void ForceRedSelectionColors(); | |
| 266 | |
| 267 // Add |source_code| as an injected stylesheet to the active document of the | 229 // Add |source_code| as an injected stylesheet to the active document of the |
| 268 // window of the current V8 context. | 230 // window of the current V8 context. |
| 269 void InsertStyleSheet(const std::string& source_code); | 231 void InsertStyleSheet(const std::string& source_code); |
| 270 | 232 |
| 271 bool FindString(const std::string& search_text, | |
| 272 const std::vector<std::string>& options_array); | |
| 273 | |
| 274 std::string SelectionAsMarkup(); | |
| 275 | |
| 276 // Enables or disables subpixel positioning (i.e. fractional X positions for | 233 // Enables or disables subpixel positioning (i.e. fractional X positions for |
| 277 // glyphs) in text rendering on Linux. Since this method changes global | 234 // glyphs) in text rendering on Linux. Since this method changes global |
| 278 // settings, tests that call it must use their own custom font family for | 235 // settings, tests that call it must use their own custom font family for |
| 279 // all text that they render. If not, an already-cached style will be used, | 236 // all text that they render. If not, an already-cached style will be used, |
| 280 // resulting in the changed setting being ignored. | 237 // resulting in the changed setting being ignored. |
| 281 void SetTextSubpixelPositioning(bool value); | 238 void SetTextSubpixelPositioning(bool value); |
| 282 | 239 |
| 283 // Switch the visibility of the page. | |
| 284 void SetPageVisibility(const std::string& new_visibility); | |
| 285 | |
| 286 // Changes the direction of the focused element. | |
| 287 void SetTextDirection(const std::string& direction_name); | |
| 288 | |
| 289 // After this function is called, all window-sizing machinery is | 240 // After this function is called, all window-sizing machinery is |
| 290 // short-circuited inside the renderer. This mode is necessary for | 241 // short-circuited inside the renderer. This mode is necessary for |
| 291 // some tests that were written before browsers had multi-process architecture | 242 // some tests that were written before browsers had multi-process architecture |
| 292 // and rely on window resizes to happen synchronously. | 243 // and rely on window resizes to happen synchronously. |
| 293 // The function has "unfortunate" it its name because we must strive to remove | 244 // The function has "unfortunate" it its name because we must strive to remove |
| 294 // all tests that rely on this... well, unfortunate behavior. See | 245 // all tests that rely on this... well, unfortunate behavior. See |
| 295 // http://crbug.com/309760 for the plan. | 246 // http://crbug.com/309760 for the plan. |
| 296 void UseUnfortunateSynchronousResizeMode(); | 247 void UseUnfortunateSynchronousResizeMode(); |
| 297 | 248 |
| 298 bool EnableAutoResizeMode(int min_width, | 249 bool EnableAutoResizeMode(int min_width, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 | 435 |
| 485 // This function sets a flag to dump the drag image when the next drag&drop is | 436 // This function sets a flag to dump the drag image when the next drag&drop is |
| 486 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel | 437 // initiated. It is equivalent to DumpAsTextWithPixelResults but the pixel |
| 487 // results will be the drag image instead of a snapshot of the page. | 438 // results will be the drag image instead of a snapshot of the page. |
| 488 void DumpDragImage(); | 439 void DumpDragImage(); |
| 489 | 440 |
| 490 // Sets a flag that tells the WebTestProxy to dump the default navigation | 441 // Sets a flag that tells the WebTestProxy to dump the default navigation |
| 491 // policy passed to the decidePolicyForNavigation callback. | 442 // policy passed to the decidePolicyForNavigation callback. |
| 492 void DumpNavigationPolicy(); | 443 void DumpNavigationPolicy(); |
| 493 | 444 |
| 494 // Dump current PageImportanceSignals for the page. | |
| 495 void DumpPageImportanceSignals(); | |
| 496 | |
| 497 /////////////////////////////////////////////////////////////////////////// | 445 /////////////////////////////////////////////////////////////////////////// |
| 498 // Methods interacting with the WebTestProxy | 446 // Methods interacting with the WebTestProxy |
| 499 | 447 |
| 500 /////////////////////////////////////////////////////////////////////////// | 448 /////////////////////////////////////////////////////////////////////////// |
| 501 // Methods forwarding to the WebTestDelegate | 449 // Methods forwarding to the WebTestDelegate |
| 502 | 450 |
| 503 // Shows DevTools window. | 451 // Shows DevTools window. |
| 504 void ShowWebInspector(const std::string& str, | 452 void ShowWebInspector(const std::string& str, |
| 505 const std::string& frontend_url); | 453 const std::string& frontend_url); |
| 506 void CloseWebInspector(); | 454 void CloseWebInspector(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 522 | 470 |
| 523 // Changes the cookie policy from the default to allow all cookies. | 471 // Changes the cookie policy from the default to allow all cookies. |
| 524 void SetAlwaysAcceptCookies(bool accept); | 472 void SetAlwaysAcceptCookies(bool accept); |
| 525 | 473 |
| 526 // Gives focus to the main test window. | 474 // Gives focus to the main test window. |
| 527 void SetWindowIsKey(bool value); | 475 void SetWindowIsKey(bool value); |
| 528 | 476 |
| 529 // Converts a URL starting with file:///tmp/ to the local mapping. | 477 // Converts a URL starting with file:///tmp/ to the local mapping. |
| 530 std::string PathToLocalResource(const std::string& path); | 478 std::string PathToLocalResource(const std::string& path); |
| 531 | 479 |
| 532 // Used to set the device scale factor. | |
| 533 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback); | |
| 534 | |
| 535 // Enable zoom-for-dsf option. | |
| 536 // TODO(oshima): Remove this once all platforms migrated. | |
| 537 void EnableUseZoomForDSF(v8::Local<v8::Function> callback); | |
| 538 | |
| 539 // Change the device color profile while running a layout test. | |
| 540 void SetColorProfile(const std::string& name, | |
| 541 v8::Local<v8::Function> callback); | |
| 542 | |
| 543 // Change the bluetooth test data while running a layout test. | |
| 544 void SetBluetoothFakeAdapter(const std::string& adapter_name, | |
| 545 v8::Local<v8::Function> callback); | |
| 546 | |
| 547 // If |enable| is true, makes the Bluetooth chooser record its input and wait | |
| 548 // for instructions from the test program on how to proceed. Otherwise falls | |
| 549 // back to the browser's default chooser. | |
| 550 void SetBluetoothManualChooser(bool enable); | |
| 551 | |
| 552 // Calls |callback| with a DOMString[] representing the events recorded since | |
| 553 // the last call to this function. | |
| 554 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback); | |
| 555 | |
| 556 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid | |
| 557 // event strings are: | |
| 558 // * "cancel" - simulates the user canceling the chooser. | |
| 559 // * "select" - simulates the user selecting a device whose device ID is in | |
| 560 // |argument|. | |
| 561 void SendBluetoothManualChooserEvent(const std::string& event, | |
| 562 const std::string& argument); | |
| 563 | |
| 564 // Enables mock geofencing service while running a layout test. | 480 // Enables mock geofencing service while running a layout test. |
| 565 // |service_available| indicates if the mock service should mock geofencing | 481 // |service_available| indicates if the mock service should mock geofencing |
| 566 // being available or not. | 482 // being available or not. |
| 567 void SetGeofencingMockProvider(bool service_available); | 483 void SetGeofencingMockProvider(bool service_available); |
| 568 | 484 |
| 569 // Disables mock geofencing service while running a layout test. | 485 // Disables mock geofencing service while running a layout test. |
| 570 void ClearGeofencingMockProvider(); | 486 void ClearGeofencingMockProvider(); |
| 571 | 487 |
| 572 // Set the mock geofencing position while running a layout test. | 488 // Set the mock geofencing position while running a layout test. |
| 573 void SetGeofencingMockPosition(double latitude, double longitude); | 489 void SetGeofencingMockPosition(double latitude, double longitude); |
| 574 | 490 |
| 575 // Sets the permission's |name| to |value| for a given {origin, embedder} | 491 // Sets the permission's |name| to |value| for a given {origin, embedder} |
| 576 // tuple. | 492 // tuple. |
| 577 void SetPermission(const std::string& name, | 493 void SetPermission(const std::string& name, |
| 578 const std::string& value, | 494 const std::string& value, |
| 579 const GURL& origin, | 495 const GURL& origin, |
| 580 const GURL& embedding_origin); | 496 const GURL& embedding_origin); |
| 581 | 497 |
| 582 // Causes the beforeinstallprompt event to be sent to the renderer. | |
| 583 void DispatchBeforeInstallPromptEvent( | |
| 584 int request_id, | |
| 585 const std::vector<std::string>& event_platforms, | |
| 586 v8::Local<v8::Function> callback); | |
| 587 | |
| 588 // Resolve the beforeinstallprompt event with the matching request id. | 498 // Resolve the beforeinstallprompt event with the matching request id. |
| 589 void ResolveBeforeInstallPromptPromise(int request_id, | 499 void ResolveBeforeInstallPromptPromise(int request_id, |
| 590 const std::string& platform); | 500 const std::string& platform); |
| 591 | 501 |
| 592 // Immediately run all pending idle tasks, including all pending | |
| 593 // requestIdleCallback calls. Invoke the callback when all | |
| 594 // idle tasks are complete. | |
| 595 void RunIdleTasks(v8::Local<v8::Function> callback); | |
| 596 | |
| 597 // Calls setlocale(LC_ALL, ...) for a specified locale. | 502 // Calls setlocale(LC_ALL, ...) for a specified locale. |
| 598 // Resets between tests. | 503 // Resets between tests. |
| 599 void SetPOSIXLocale(const std::string& locale); | 504 void SetPOSIXLocale(const std::string& locale); |
| 600 | 505 |
| 601 // MIDI function to control permission handling. | 506 // MIDI function to control permission handling. |
| 602 void SetMIDIAccessorResult(bool result); | 507 void SetMIDIAccessorResult(bool result); |
| 603 | 508 |
| 604 // Simulates a click on a Web Notification. | 509 // Simulates a click on a Web Notification. |
| 605 void SimulateWebNotificationClick(const std::string& title, int action_index); | 510 void SimulateWebNotificationClick(const std::string& title, int action_index); |
| 606 | 511 |
| 607 // Simulates closing a Web Notification. | 512 // Simulates closing a Web Notification. |
| 608 void SimulateWebNotificationClose(const std::string& title, bool by_user); | 513 void SimulateWebNotificationClose(const std::string& title, bool by_user); |
| 609 | 514 |
| 610 // Speech recognition related functions. | 515 // Speech recognition related functions. |
| 611 void AddMockSpeechRecognitionResult(const std::string& transcript, | 516 void AddMockSpeechRecognitionResult(const std::string& transcript, |
| 612 double confidence); | 517 double confidence); |
| 613 void SetMockSpeechRecognitionError(const std::string& error, | 518 void SetMockSpeechRecognitionError(const std::string& error, |
| 614 const std::string& message); | 519 const std::string& message); |
| 615 | 520 |
| 616 // Credential Manager mock functions | 521 // Credential Manager mock functions |
| 617 // TODO(mkwst): Support FederatedCredential. | 522 // TODO(mkwst): Support FederatedCredential. |
| 618 void AddMockCredentialManagerResponse(const std::string& id, | 523 void AddMockCredentialManagerResponse(const std::string& id, |
| 619 const std::string& name, | 524 const std::string& name, |
| 620 const std::string& avatar, | 525 const std::string& avatar, |
| 621 const std::string& password); | 526 const std::string& password); |
| 622 void AddMockCredentialManagerError(const std::string& error); | 527 void AddMockCredentialManagerError(const std::string& error); |
| 623 | 528 |
| 624 // WebPageOverlay related functions. Permits the adding and removing of only | |
| 625 // one opaque overlay. | |
| 626 void AddWebPageOverlay(); | |
| 627 void RemoveWebPageOverlay(); | |
| 628 | |
| 629 void LayoutAndPaintAsync(); | |
| 630 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback); | |
| 631 | |
| 632 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured | |
| 633 // snapshot (width, height, snapshot) to the callback. The snapshot is in | |
| 634 // uint8_t RGBA format. | |
| 635 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback); | |
| 636 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image | |
| 637 // located at a particular point in the WebView (if there is such an image), | |
| 638 // reads back its pixels, and provides the snapshot to the callback. If there | |
| 639 // is no image at that point, calls the callback with (0, 0, empty_snapshot). | |
| 640 void CopyImageAtAndCapturePixelsAsyncThen( | |
| 641 int x, int y, const v8::Local<v8::Function> callback); | |
| 642 | |
| 643 void GetManifestThen(v8::Local<v8::Function> callback); | |
| 644 | |
| 645 // Takes care of notifying the delegate after a change to layout test runtime | 529 // Takes care of notifying the delegate after a change to layout test runtime |
| 646 // flags. | 530 // flags. |
| 647 void OnLayoutTestRuntimeFlagsChanged(); | 531 void OnLayoutTestRuntimeFlagsChanged(); |
| 648 | 532 |
| 649 /////////////////////////////////////////////////////////////////////////// | 533 /////////////////////////////////////////////////////////////////////////// |
| 650 // Internal helpers | 534 // Internal helpers |
| 651 | 535 |
| 652 void GetManifestCallback(v8::UniquePersistent<v8::Function> callback, | |
| 653 const blink::WebURLResponse& response, | |
| 654 const std::string& data); | |
| 655 void CapturePixelsCallback(v8::UniquePersistent<v8::Function> callback, | |
| 656 const SkBitmap& snapshot); | |
| 657 void DispatchBeforeInstallPromptCallback( | |
| 658 v8::UniquePersistent<v8::Function> callback, | |
| 659 bool canceled); | |
| 660 void GetBluetoothManualChooserEventsCallback( | |
| 661 v8::UniquePersistent<v8::Function> callback, | |
| 662 const std::vector<std::string>& events); | |
| 663 | |
| 664 void CheckResponseMimeType(); | 536 void CheckResponseMimeType(); |
| 665 void CompleteNotifyDone(); | 537 void CompleteNotifyDone(); |
| 666 | 538 |
| 667 void DidAcquirePointerLockInternal(); | 539 void DidAcquirePointerLockInternal(); |
| 668 void DidNotAcquirePointerLockInternal(); | 540 void DidNotAcquirePointerLockInternal(); |
| 669 void DidLosePointerLockInternal(); | 541 void DidLosePointerLockInternal(); |
| 670 | 542 |
| 671 // In the Mac code, this is called to trigger the end of a test after the | 543 // In the Mac code, this is called to trigger the end of a test after the |
| 672 // page has finished loading. From here, we can generate the dump for the | 544 // page has finished loading. From here, we can generate the dump for the |
| 673 // test. | 545 // test. |
| 674 void LocationChangeDone(); | 546 void LocationChangeDone(); |
| 675 | 547 |
| 676 // Sets a flag causing the next call to WebGLRenderingContext::create to fail. | |
| 677 void ForceNextWebGLContextCreationToFail(); | |
| 678 | |
| 679 // Sets a flag causing the next call to DrawingBuffer::create to fail. | |
| 680 void ForceNextDrawingBufferCreationToFail(); | |
| 681 | |
| 682 bool test_is_running_; | 548 bool test_is_running_; |
| 683 | 549 |
| 684 // When reset is called, go through and close all but the main test shell | 550 // When reset is called, go through and close all but the main test shell |
| 685 // window. By default, set to true but toggled to false using | 551 // window. By default, set to true but toggled to false using |
| 686 // setCloseRemainingWindowsWhenComplete(). | 552 // setCloseRemainingWindowsWhenComplete(). |
| 687 bool close_remaining_windows_; | 553 bool close_remaining_windows_; |
| 688 | 554 |
| 689 WorkQueue work_queue_; | 555 WorkQueue work_queue_; |
| 690 | 556 |
| 691 // Bound variable to return the name of this platform (chromium). | 557 // Bound variable to return the name of this platform (chromium). |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 // is ok, because this is taken care of in WebTestDelegate::SetFocus). | 643 // is ok, because this is taken care of in WebTestDelegate::SetFocus). |
| 778 blink::WebView* previously_focused_view_; | 644 blink::WebView* previously_focused_view_; |
| 779 | 645 |
| 780 std::set<blink::WebView*> views_with_scheduled_animations_; | 646 std::set<blink::WebView*> views_with_scheduled_animations_; |
| 781 | 647 |
| 782 base::WeakPtrFactory<TestRunner> weak_factory_; | 648 base::WeakPtrFactory<TestRunner> weak_factory_; |
| 783 | 649 |
| 784 DISALLOW_COPY_AND_ASSIGN(TestRunner); | 650 DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 785 }; | 651 }; |
| 786 | 652 |
| 653 // Wraps TestRunner's functionality that needs to work with a specific view | |
| 654 // (that testRunner javascript bindings are exposed to; as opposed to | |
| 655 // working with the global main test window). | |
| 656 class TestRunnerForSpecificView { | |
|
Łukasz Anforowicz
2016/04/21 23:41:01
I don't like the name of the new class, but I coul
| |
| 657 public: | |
| 658 TestRunnerForSpecificView(WebTestProxyBase* web_test_proxy_base); | |
| 659 ~TestRunnerForSpecificView(); | |
| 660 | |
| 661 // Installs view-specific bindings (handled by |this|) and *also* global | |
| 662 // TestRunner bindings (both kinds of bindings are exposed via a single | |
| 663 // |testRunner| object in javascript). | |
| 664 void Install(blink::WebLocalFrame* frame); | |
| 665 | |
| 666 private: | |
| 667 friend class TestRunnerBindings; | |
| 668 | |
| 669 // Helpers for working with base and V8 callbacks. | |
| 670 void PostTask(const base::Closure& callback); | |
| 671 void PostV8Callback(const v8::Local<v8::Function>& callback); | |
| 672 void PostV8CallbackWithArgs(v8::UniquePersistent<v8::Function> callback, | |
| 673 int argc, | |
| 674 v8::Local<v8::Value> argv[]); | |
| 675 void InvokeV8Callback(const v8::UniquePersistent<v8::Function>& callback); | |
| 676 void InvokeV8CallbackWithArgs( | |
| 677 const v8::UniquePersistent<v8::Function>& callback, | |
| 678 const std::vector<v8::UniquePersistent<v8::Value>>& args); | |
| 679 base::Closure CreateClosureThatPostsV8Callback( | |
| 680 const v8::Local<v8::Function>& callback); | |
| 681 | |
| 682 void LayoutAndPaintAsync(); | |
| 683 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback); | |
| 684 | |
| 685 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured | |
| 686 // snapshot (width, height, snapshot) to the callback. The snapshot is in | |
| 687 // uint8_t RGBA format. | |
| 688 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback); | |
| 689 void CapturePixelsCallback(v8::UniquePersistent<v8::Function> callback, | |
| 690 const SkBitmap& snapshot); | |
| 691 | |
| 692 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image | |
| 693 // located at a particular point in the WebView (if there is such an image), | |
| 694 // reads back its pixels, and provides the snapshot to the callback. If there | |
| 695 // is no image at that point, calls the callback with (0, 0, empty_snapshot). | |
| 696 void CopyImageAtAndCapturePixelsAsyncThen( | |
| 697 int x, | |
| 698 int y, | |
| 699 const v8::Local<v8::Function> callback); | |
| 700 | |
| 701 void GetManifestThen(v8::Local<v8::Function> callback); | |
| 702 void GetManifestCallback(v8::UniquePersistent<v8::Function> callback, | |
| 703 const blink::WebURLResponse& response, | |
| 704 const std::string& data); | |
| 705 | |
| 706 // Calls |callback| with a DOMString[] representing the events recorded since | |
| 707 // the last call to this function. | |
| 708 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback); | |
| 709 void GetBluetoothManualChooserEventsCallback( | |
| 710 v8::UniquePersistent<v8::Function> callback, | |
| 711 const std::vector<std::string>& events); | |
| 712 | |
| 713 // Change the bluetooth test data while running a layout test. | |
| 714 void SetBluetoothFakeAdapter(const std::string& adapter_name, | |
| 715 v8::Local<v8::Function> callback); | |
| 716 | |
| 717 // If |enable| is true, makes the Bluetooth chooser record its input and wait | |
| 718 // for instructions from the test program on how to proceed. Otherwise falls | |
| 719 // back to the browser's default chooser. | |
| 720 void SetBluetoothManualChooser(bool enable); | |
| 721 | |
| 722 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid | |
| 723 // event strings are: | |
| 724 // * "cancel" - simulates the user canceling the chooser. | |
| 725 // * "select" - simulates the user selecting a device whose device ID is in | |
| 726 // |argument|. | |
| 727 void SendBluetoothManualChooserEvent(const std::string& event, | |
| 728 const std::string& argument); | |
| 729 | |
| 730 // Used to set the device scale factor. | |
| 731 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback); | |
| 732 | |
| 733 // Enable zoom-for-dsf option. | |
| 734 // TODO(oshima): Remove this once all platforms migrated. | |
| 735 void EnableUseZoomForDSF(v8::Local<v8::Function> callback); | |
| 736 | |
| 737 // Change the device color profile while running a layout test. | |
| 738 void SetColorProfile(const std::string& name, | |
| 739 v8::Local<v8::Function> callback); | |
| 740 | |
| 741 // Causes the beforeinstallprompt event to be sent to the renderer. | |
| 742 void DispatchBeforeInstallPromptEvent( | |
| 743 int request_id, | |
| 744 const std::vector<std::string>& event_platforms, | |
| 745 v8::Local<v8::Function> callback); | |
| 746 void DispatchBeforeInstallPromptCallback( | |
| 747 v8::UniquePersistent<v8::Function> callback, | |
| 748 bool canceled); | |
| 749 | |
| 750 // Immediately run all pending idle tasks, including all pending | |
| 751 // requestIdleCallback calls. Invoke the callback when all | |
| 752 // idle tasks are complete. | |
| 753 void RunIdleTasks(v8::Local<v8::Function> callback); | |
| 754 | |
| 755 // Method that controls whether pressing Tab key cycles through page elements | |
| 756 // or inserts a '\t' char in text area | |
| 757 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); | |
| 758 | |
| 759 // Executes an internal command (superset of document.execCommand() commands). | |
| 760 void ExecCommand(gin::Arguments* args); | |
| 761 | |
| 762 // Checks if an internal command is currently available. | |
| 763 bool IsCommandEnabled(const std::string& command); | |
| 764 | |
| 765 // Returns true if the current page box has custom page size style for | |
| 766 // printing. | |
| 767 bool HasCustomPageSizeStyle(int page_index); | |
| 768 | |
| 769 // Forces the selection colors for testing under Linux. | |
| 770 void ForceRedSelectionColors(); | |
| 771 | |
| 772 // Switch the visibility of the page. | |
| 773 void SetPageVisibility(const std::string& new_visibility); | |
| 774 | |
| 775 // Changes the direction of the focused element. | |
| 776 void SetTextDirection(const std::string& direction_name); | |
| 777 | |
| 778 // Dump current PageImportanceSignals for the page. | |
| 779 void DumpPageImportanceSignals(); | |
| 780 | |
| 781 // WebPageOverlay related functions. Permits the adding and removing of only | |
| 782 // one opaque overlay. | |
| 783 void AddWebPageOverlay(); | |
| 784 void RemoveWebPageOverlay(); | |
| 785 | |
| 786 // Sets a flag causing the next call to WebGLRenderingContext::create to fail. | |
| 787 void ForceNextWebGLContextCreationToFail(); | |
| 788 | |
| 789 // Sets a flag causing the next call to DrawingBuffer::create to fail. | |
| 790 void ForceNextDrawingBufferCreationToFail(); | |
| 791 | |
| 792 bool CallShouldCloseOnWebView(); | |
| 793 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | |
| 794 const std::string& scheme); | |
| 795 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue( | |
| 796 int world_id, | |
| 797 const std::string& script); | |
| 798 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script); | |
| 799 void SetIsolatedWorldSecurityOrigin(int world_id, | |
| 800 v8::Local<v8::Value> origin); | |
| 801 void SetIsolatedWorldContentSecurityPolicy(int world_id, | |
| 802 const std::string& policy); | |
| 803 bool FindString(const std::string& search_text, | |
| 804 const std::vector<std::string>& options_array); | |
| 805 std::string SelectionAsMarkup(); | |
| 806 void SetViewSourceForFrame(const std::string& name, bool enabled); | |
| 807 | |
| 808 // Helpers for accessing pointers exposed by |web_test_proxy_base_|. | |
| 809 blink::WebView* web_view(); | |
| 810 WebTestDelegate* delegate(); | |
| 811 WebTestProxyBase* web_test_proxy_base_; | |
| 812 | |
| 813 base::WeakPtrFactory<TestRunnerForSpecificView> weak_factory_; | |
| 814 | |
| 815 DISALLOW_COPY_AND_ASSIGN(TestRunnerForSpecificView); | |
| 816 }; | |
| 817 | |
| 787 } // namespace test_runner | 818 } // namespace test_runner |
| 788 | 819 |
| 789 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ | 820 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_H_ |
| OLD | NEW |