| 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 #include "components/test_runner/test_runner.h" | 5 #include "components/test_runner/test_runner.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void QueueBackNavigation(int how_far_back); | 174 void QueueBackNavigation(int how_far_back); |
| 175 void QueueForwardNavigation(int how_far_forward); | 175 void QueueForwardNavigation(int how_far_forward); |
| 176 void QueueLoad(gin::Arguments* args); | 176 void QueueLoad(gin::Arguments* args); |
| 177 void QueueLoadingScript(const std::string& script); | 177 void QueueLoadingScript(const std::string& script); |
| 178 void QueueNonLoadingScript(const std::string& script); | 178 void QueueNonLoadingScript(const std::string& script); |
| 179 void QueueReload(); | 179 void QueueReload(); |
| 180 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, | 180 void RemoveOriginAccessWhitelistEntry(const std::string& source_origin, |
| 181 const std::string& destination_protocol, | 181 const std::string& destination_protocol, |
| 182 const std::string& destination_host, | 182 const std::string& destination_host, |
| 183 bool allow_destination_subdomains); | 183 bool allow_destination_subdomains); |
| 184 void RemoveSpellCheckResolvedCallback(); |
| 184 void RemoveWebPageOverlay(); | 185 void RemoveWebPageOverlay(); |
| 185 void ResetDeviceLight(); | 186 void ResetDeviceLight(); |
| 186 void ResetTestHelperControllers(); | 187 void ResetTestHelperControllers(); |
| 187 void ResolveBeforeInstallPromptPromise(const std::string& platform); | 188 void ResolveBeforeInstallPromptPromise(const std::string& platform); |
| 188 void RunIdleTasks(v8::Local<v8::Function> callback); | 189 void RunIdleTasks(v8::Local<v8::Function> callback); |
| 189 void SendBluetoothManualChooserEvent(const std::string& event, | 190 void SendBluetoothManualChooserEvent(const std::string& event, |
| 190 const std::string& argument); | 191 const std::string& argument); |
| 191 void SetAcceptLanguages(const std::string& accept_languages); | 192 void SetAcceptLanguages(const std::string& accept_languages); |
| 192 void SetAllowFileAccessFromFileURLs(bool allow); | 193 void SetAllowFileAccessFromFileURLs(bool allow); |
| 193 void SetAllowRunningOfInsecureContent(bool allowed); | 194 void SetAllowRunningOfInsecureContent(bool allowed); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 const std::string& origin, | 235 const std::string& origin, |
| 235 const std::string& embedding_origin); | 236 const std::string& embedding_origin); |
| 236 void SetPluginsAllowed(bool allowed); | 237 void SetPluginsAllowed(bool allowed); |
| 237 void SetPluginsEnabled(bool enabled); | 238 void SetPluginsEnabled(bool enabled); |
| 238 void SetPointerLockWillFailSynchronously(); | 239 void SetPointerLockWillFailSynchronously(); |
| 239 void SetPointerLockWillRespondAsynchronously(); | 240 void SetPointerLockWillRespondAsynchronously(); |
| 240 void SetPopupBlockingEnabled(bool block_popups); | 241 void SetPopupBlockingEnabled(bool block_popups); |
| 241 void SetPrinting(); | 242 void SetPrinting(); |
| 242 void SetScriptsAllowed(bool allowed); | 243 void SetScriptsAllowed(bool allowed); |
| 243 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); | 244 void SetShouldStayOnPageAfterHandlingBeforeUnload(bool value); |
| 245 void SetSpellCheckResolvedCallback(v8::Local<v8::Function> callback); |
| 244 void SetStorageAllowed(bool allowed); | 246 void SetStorageAllowed(bool allowed); |
| 245 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); | 247 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements); |
| 246 void SetTextDirection(const std::string& direction_name); | 248 void SetTextDirection(const std::string& direction_name); |
| 247 void SetTextSubpixelPositioning(bool value); | 249 void SetTextSubpixelPositioning(bool value); |
| 248 void SetUseMockTheme(bool use); | 250 void SetUseMockTheme(bool use); |
| 249 void SetViewSourceForFrame(const std::string& name, bool enabled); | 251 void SetViewSourceForFrame(const std::string& name, bool enabled); |
| 250 void SetWillSendRequestClearHeader(const std::string& header); | 252 void SetWillSendRequestClearHeader(const std::string& header); |
| 251 void SetWindowIsKey(bool value); | 253 void SetWindowIsKey(bool value); |
| 252 void SetXSSAuditorEnabled(bool enabled); | 254 void SetXSSAuditorEnabled(bool enabled); |
| 253 void ShowWebInspector(gin::Arguments* args); | 255 void ShowWebInspector(gin::Arguments* args); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 &TestRunnerBindings::QueueBackNavigation) | 464 &TestRunnerBindings::QueueBackNavigation) |
| 463 .SetMethod("queueForwardNavigation", | 465 .SetMethod("queueForwardNavigation", |
| 464 &TestRunnerBindings::QueueForwardNavigation) | 466 &TestRunnerBindings::QueueForwardNavigation) |
| 465 .SetMethod("queueLoad", &TestRunnerBindings::QueueLoad) | 467 .SetMethod("queueLoad", &TestRunnerBindings::QueueLoad) |
| 466 .SetMethod("queueLoadingScript", &TestRunnerBindings::QueueLoadingScript) | 468 .SetMethod("queueLoadingScript", &TestRunnerBindings::QueueLoadingScript) |
| 467 .SetMethod("queueNonLoadingScript", | 469 .SetMethod("queueNonLoadingScript", |
| 468 &TestRunnerBindings::QueueNonLoadingScript) | 470 &TestRunnerBindings::QueueNonLoadingScript) |
| 469 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) | 471 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) |
| 470 .SetMethod("removeOriginAccessWhitelistEntry", | 472 .SetMethod("removeOriginAccessWhitelistEntry", |
| 471 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) | 473 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) |
| 474 .SetMethod("removeSpellCheckResolvedCallback", |
| 475 &TestRunnerBindings::RemoveSpellCheckResolvedCallback) |
| 472 .SetMethod("removeWebPageOverlay", | 476 .SetMethod("removeWebPageOverlay", |
| 473 &TestRunnerBindings::RemoveWebPageOverlay) | 477 &TestRunnerBindings::RemoveWebPageOverlay) |
| 474 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) | 478 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) |
| 475 .SetMethod("resetTestHelperControllers", | 479 .SetMethod("resetTestHelperControllers", |
| 476 &TestRunnerBindings::ResetTestHelperControllers) | 480 &TestRunnerBindings::ResetTestHelperControllers) |
| 477 .SetMethod("resolveBeforeInstallPromptPromise", | 481 .SetMethod("resolveBeforeInstallPromptPromise", |
| 478 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) | 482 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) |
| 479 .SetMethod("runIdleTasks", &TestRunnerBindings::RunIdleTasks) | 483 .SetMethod("runIdleTasks", &TestRunnerBindings::RunIdleTasks) |
| 480 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) | 484 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) |
| 481 | 485 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 .SetMethod("setPointerLockWillRespondAsynchronously", | 557 .SetMethod("setPointerLockWillRespondAsynchronously", |
| 554 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) | 558 &TestRunnerBindings::SetPointerLockWillRespondAsynchronously) |
| 555 .SetMethod("setPopupBlockingEnabled", | 559 .SetMethod("setPopupBlockingEnabled", |
| 556 &TestRunnerBindings::SetPopupBlockingEnabled) | 560 &TestRunnerBindings::SetPopupBlockingEnabled) |
| 557 .SetMethod("setPrinting", &TestRunnerBindings::SetPrinting) | 561 .SetMethod("setPrinting", &TestRunnerBindings::SetPrinting) |
| 558 .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) | 562 .SetMethod("setScriptsAllowed", &TestRunnerBindings::SetScriptsAllowed) |
| 559 .SetMethod("setScrollbarPolicy", &TestRunnerBindings::NotImplemented) | 563 .SetMethod("setScrollbarPolicy", &TestRunnerBindings::NotImplemented) |
| 560 .SetMethod( | 564 .SetMethod( |
| 561 "setShouldStayOnPageAfterHandlingBeforeUnload", | 565 "setShouldStayOnPageAfterHandlingBeforeUnload", |
| 562 &TestRunnerBindings::SetShouldStayOnPageAfterHandlingBeforeUnload) | 566 &TestRunnerBindings::SetShouldStayOnPageAfterHandlingBeforeUnload) |
| 567 .SetMethod("setSpellCheckResolvedCallback", |
| 568 &TestRunnerBindings::SetSpellCheckResolvedCallback) |
| 563 .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) | 569 .SetMethod("setStorageAllowed", &TestRunnerBindings::SetStorageAllowed) |
| 564 .SetMethod("setTabKeyCyclesThroughElements", | 570 .SetMethod("setTabKeyCyclesThroughElements", |
| 565 &TestRunnerBindings::SetTabKeyCyclesThroughElements) | 571 &TestRunnerBindings::SetTabKeyCyclesThroughElements) |
| 566 .SetMethod("setTextDirection", &TestRunnerBindings::SetTextDirection) | 572 .SetMethod("setTextDirection", &TestRunnerBindings::SetTextDirection) |
| 567 .SetMethod("setTextSubpixelPositioning", | 573 .SetMethod("setTextSubpixelPositioning", |
| 568 &TestRunnerBindings::SetTextSubpixelPositioning) | 574 &TestRunnerBindings::SetTextSubpixelPositioning) |
| 569 .SetMethod("setUseDashboardCompatibilityMode", | 575 .SetMethod("setUseDashboardCompatibilityMode", |
| 570 &TestRunnerBindings::NotImplemented) | 576 &TestRunnerBindings::NotImplemented) |
| 571 .SetMethod("setUseMockTheme", &TestRunnerBindings::SetUseMockTheme) | 577 .SetMethod("setUseMockTheme", &TestRunnerBindings::SetUseMockTheme) |
| 572 .SetMethod("setViewSourceForFrame", | 578 .SetMethod("setViewSourceForFrame", |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 747 |
| 742 if (runner_) | 748 if (runner_) |
| 743 runner_->SetEffectiveConnectionType(web_type); | 749 runner_->SetEffectiveConnectionType(web_type); |
| 744 } | 750 } |
| 745 | 751 |
| 746 void TestRunnerBindings::SetMockSpellCheckerEnabled(bool enabled) { | 752 void TestRunnerBindings::SetMockSpellCheckerEnabled(bool enabled) { |
| 747 if (runner_) | 753 if (runner_) |
| 748 runner_->SetMockSpellCheckerEnabled(enabled); | 754 runner_->SetMockSpellCheckerEnabled(enabled); |
| 749 } | 755 } |
| 750 | 756 |
| 757 void TestRunnerBindings::SetSpellCheckResolvedCallback( |
| 758 v8::Local<v8::Function> callback) { |
| 759 if (runner_) |
| 760 runner_->spellcheck_->SetSpellCheckResolvedCallback(callback); |
| 761 } |
| 762 |
| 763 void TestRunnerBindings::RemoveSpellCheckResolvedCallback() { |
| 764 if (runner_) |
| 765 runner_->spellcheck_->RemoveSpellCheckResolvedCallback(); |
| 766 } |
| 767 |
| 751 v8::Local<v8::Value> | 768 v8::Local<v8::Value> |
| 752 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( | 769 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 753 int world_id, const std::string& script) { | 770 int world_id, const std::string& script) { |
| 754 if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29)) | 771 if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29)) |
| 755 return v8::Local<v8::Value>(); | 772 return v8::Local<v8::Value>(); |
| 756 return view_runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, | 773 return view_runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, |
| 757 script); | 774 script); |
| 758 } | 775 } |
| 759 | 776 |
| 760 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( | 777 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 SetUseMockTheme(true); | 1690 SetUseMockTheme(true); |
| 1674 | 1691 |
| 1675 weak_factory_.InvalidateWeakPtrs(); | 1692 weak_factory_.InvalidateWeakPtrs(); |
| 1676 work_queue_.Reset(); | 1693 work_queue_.Reset(); |
| 1677 | 1694 |
| 1678 if (close_remaining_windows_ && delegate_) | 1695 if (close_remaining_windows_ && delegate_) |
| 1679 delegate_->CloseRemainingWindows(); | 1696 delegate_->CloseRemainingWindows(); |
| 1680 else | 1697 else |
| 1681 close_remaining_windows_ = true; | 1698 close_remaining_windows_ = true; |
| 1682 | 1699 |
| 1683 spellcheck_->SetEnabled(false); | 1700 spellcheck_->Reset(); |
| 1684 } | 1701 } |
| 1685 | 1702 |
| 1686 void TestRunner::SetTestIsRunning(bool running) { | 1703 void TestRunner::SetTestIsRunning(bool running) { |
| 1687 test_is_running_ = running; | 1704 test_is_running_ = running; |
| 1688 } | 1705 } |
| 1689 | 1706 |
| 1690 bool TestRunner::shouldDumpEditingCallbacks() const { | 1707 bool TestRunner::shouldDumpEditingCallbacks() const { |
| 1691 return layout_test_runtime_flags_.dump_editting_callbacks(); | 1708 return layout_test_runtime_flags_.dump_editting_callbacks(); |
| 1692 } | 1709 } |
| 1693 | 1710 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 OnLayoutTestRuntimeFlagsChanged(); | 1932 OnLayoutTestRuntimeFlagsChanged(); |
| 1916 | 1933 |
| 1917 LocationChangeDone(); | 1934 LocationChangeDone(); |
| 1918 return true; | 1935 return true; |
| 1919 } | 1936 } |
| 1920 | 1937 |
| 1921 WebFrame* TestRunner::topLoadingFrame() const { | 1938 WebFrame* TestRunner::topLoadingFrame() const { |
| 1922 return top_loading_frame_; | 1939 return top_loading_frame_; |
| 1923 } | 1940 } |
| 1924 | 1941 |
| 1942 WebFrame* TestRunner::mainFrame() const { |
| 1943 return main_view_->mainFrame(); |
| 1944 } |
| 1945 |
| 1925 void TestRunner::policyDelegateDone() { | 1946 void TestRunner::policyDelegateDone() { |
| 1926 DCHECK(layout_test_runtime_flags_.wait_until_done()); | 1947 DCHECK(layout_test_runtime_flags_.wait_until_done()); |
| 1927 delegate_->TestFinished(); | 1948 delegate_->TestFinished(); |
| 1928 layout_test_runtime_flags_.set_wait_until_done(false); | 1949 layout_test_runtime_flags_.set_wait_until_done(false); |
| 1929 OnLayoutTestRuntimeFlagsChanged(); | 1950 OnLayoutTestRuntimeFlagsChanged(); |
| 1930 } | 1951 } |
| 1931 | 1952 |
| 1932 bool TestRunner::policyDelegateEnabled() const { | 1953 bool TestRunner::policyDelegateEnabled() const { |
| 1933 return layout_test_runtime_flags_.policy_delegate_enabled(); | 1954 return layout_test_runtime_flags_.policy_delegate_enabled(); |
| 1934 } | 1955 } |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 | 2801 |
| 2781 void TestRunner::NotifyDone() { | 2802 void TestRunner::NotifyDone() { |
| 2782 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2803 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
| 2783 !will_navigate_ && work_queue_.is_empty()) | 2804 !will_navigate_ && work_queue_.is_empty()) |
| 2784 delegate_->TestFinished(); | 2805 delegate_->TestFinished(); |
| 2785 layout_test_runtime_flags_.set_wait_until_done(false); | 2806 layout_test_runtime_flags_.set_wait_until_done(false); |
| 2786 OnLayoutTestRuntimeFlagsChanged(); | 2807 OnLayoutTestRuntimeFlagsChanged(); |
| 2787 } | 2808 } |
| 2788 | 2809 |
| 2789 } // namespace test_runner | 2810 } // namespace test_runner |
| OLD | NEW |