| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void SetColorProfile(const std::string& name, | 205 void SetColorProfile(const std::string& name, |
| 206 v8::Local<v8::Function> callback); | 206 v8::Local<v8::Function> callback); |
| 207 void SetCustomPolicyDelegate(gin::Arguments* args); | 207 void SetCustomPolicyDelegate(gin::Arguments* args); |
| 208 void SetCustomTextOutput(const std::string& output); | 208 void SetCustomTextOutput(const std::string& output); |
| 209 void SetDatabaseQuota(int quota); | 209 void SetDatabaseQuota(int quota); |
| 210 void SetDisallowedSubresourcePathSuffixes( | 210 void SetDisallowedSubresourcePathSuffixes( |
| 211 const std::vector<std::string>& suffixes); | 211 const std::vector<std::string>& suffixes); |
| 212 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | 212 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
| 213 const std::string& scheme); | 213 const std::string& scheme); |
| 214 void SetDumpConsoleMessages(bool value); | 214 void SetDumpConsoleMessages(bool value); |
| 215 void SetEffectiveConnectionType(const std::string& connection_type); |
| 215 void SetMockSpellCheckerEnabled(bool enabled); | 216 void SetMockSpellCheckerEnabled(bool enabled); |
| 216 void SetImagesAllowed(bool allowed); | 217 void SetImagesAllowed(bool allowed); |
| 217 void SetIsolatedWorldContentSecurityPolicy(int world_id, | 218 void SetIsolatedWorldContentSecurityPolicy(int world_id, |
| 218 const std::string& policy); | 219 const std::string& policy); |
| 219 void SetIsolatedWorldSecurityOrigin(int world_id, | 220 void SetIsolatedWorldSecurityOrigin(int world_id, |
| 220 v8::Local<v8::Value> origin); | 221 v8::Local<v8::Value> origin); |
| 221 void SetJavaScriptCanAccessClipboard(bool can_access); | 222 void SetJavaScriptCanAccessClipboard(bool can_access); |
| 222 void SetMIDIAccessorResult(bool result); | 223 void SetMIDIAccessorResult(bool result); |
| 223 void SetMockDeviceLight(double value); | 224 void SetMockDeviceLight(double value); |
| 224 void SetMockDeviceMotion(gin::Arguments* args); | 225 void SetMockDeviceMotion(gin::Arguments* args); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 .SetMethod("setColorProfile", &TestRunnerBindings::SetColorProfile) | 505 .SetMethod("setColorProfile", &TestRunnerBindings::SetColorProfile) |
| 505 .SetMethod("setCustomPolicyDelegate", | 506 .SetMethod("setCustomPolicyDelegate", |
| 506 &TestRunnerBindings::SetCustomPolicyDelegate) | 507 &TestRunnerBindings::SetCustomPolicyDelegate) |
| 507 .SetMethod("setCustomTextOutput", | 508 .SetMethod("setCustomTextOutput", |
| 508 &TestRunnerBindings::SetCustomTextOutput) | 509 &TestRunnerBindings::SetCustomTextOutput) |
| 509 .SetMethod("setDatabaseQuota", &TestRunnerBindings::SetDatabaseQuota) | 510 .SetMethod("setDatabaseQuota", &TestRunnerBindings::SetDatabaseQuota) |
| 510 .SetMethod("setDomainRelaxationForbiddenForURLScheme", | 511 .SetMethod("setDomainRelaxationForbiddenForURLScheme", |
| 511 &TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme) | 512 &TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme) |
| 512 .SetMethod("setDumpConsoleMessages", | 513 .SetMethod("setDumpConsoleMessages", |
| 513 &TestRunnerBindings::SetDumpConsoleMessages) | 514 &TestRunnerBindings::SetDumpConsoleMessages) |
| 515 .SetMethod("setEffectiveConnectionType", |
| 516 &TestRunnerBindings::SetEffectiveConnectionType) |
| 514 .SetMethod("setMockSpellCheckerEnabled", | 517 .SetMethod("setMockSpellCheckerEnabled", |
| 515 &TestRunnerBindings::SetMockSpellCheckerEnabled) | 518 &TestRunnerBindings::SetMockSpellCheckerEnabled) |
| 516 .SetMethod("setIconDatabaseEnabled", &TestRunnerBindings::NotImplemented) | 519 .SetMethod("setIconDatabaseEnabled", &TestRunnerBindings::NotImplemented) |
| 517 .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) | 520 .SetMethod("setImagesAllowed", &TestRunnerBindings::SetImagesAllowed) |
| 518 .SetMethod("setIsolatedWorldContentSecurityPolicy", | 521 .SetMethod("setIsolatedWorldContentSecurityPolicy", |
| 519 &TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy) | 522 &TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy) |
| 520 .SetMethod("setIsolatedWorldSecurityOrigin", | 523 .SetMethod("setIsolatedWorldSecurityOrigin", |
| 521 &TestRunnerBindings::SetIsolatedWorldSecurityOrigin) | 524 &TestRunnerBindings::SetIsolatedWorldSecurityOrigin) |
| 522 .SetMethod("setJavaScriptCanAccessClipboard", | 525 .SetMethod("setJavaScriptCanAccessClipboard", |
| 523 &TestRunnerBindings::SetJavaScriptCanAccessClipboard) | 526 &TestRunnerBindings::SetJavaScriptCanAccessClipboard) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 bool forbidden, const std::string& scheme) { | 700 bool forbidden, const std::string& scheme) { |
| 698 if (view_runner_) | 701 if (view_runner_) |
| 699 view_runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); | 702 view_runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); |
| 700 } | 703 } |
| 701 | 704 |
| 702 void TestRunnerBindings::SetDumpConsoleMessages(bool enabled) { | 705 void TestRunnerBindings::SetDumpConsoleMessages(bool enabled) { |
| 703 if (runner_) | 706 if (runner_) |
| 704 runner_->SetDumpConsoleMessages(enabled); | 707 runner_->SetDumpConsoleMessages(enabled); |
| 705 } | 708 } |
| 706 | 709 |
| 710 void TestRunnerBindings::SetEffectiveConnectionType( |
| 711 const std::string& connection_type) { |
| 712 blink::WebEffectiveConnectionType web_type = |
| 713 blink::WebEffectiveConnectionType::TypeUnknown; |
| 714 if (connection_type == "TypeUnknown") |
| 715 web_type = blink::WebEffectiveConnectionType::TypeUnknown; |
| 716 else if (connection_type == "TypeOffline") |
| 717 web_type = blink::WebEffectiveConnectionType::TypeOffline; |
| 718 else if (connection_type == "TypeSlow2G") |
| 719 web_type = blink::WebEffectiveConnectionType::TypeSlow2G; |
| 720 else if (connection_type == "Type2G") |
| 721 web_type = blink::WebEffectiveConnectionType::Type2G; |
| 722 else if (connection_type == "Type3G") |
| 723 web_type = blink::WebEffectiveConnectionType::Type3G; |
| 724 else if (connection_type == "Type4G") |
| 725 web_type = blink::WebEffectiveConnectionType::Type4G; |
| 726 else |
| 727 NOTREACHED(); |
| 728 |
| 729 if (runner_) |
| 730 runner_->SetEffectiveConnectionType(web_type); |
| 731 } |
| 732 |
| 707 void TestRunnerBindings::SetMockSpellCheckerEnabled(bool enabled) { | 733 void TestRunnerBindings::SetMockSpellCheckerEnabled(bool enabled) { |
| 708 if (runner_) | 734 if (runner_) |
| 709 runner_->SetMockSpellCheckerEnabled(enabled); | 735 runner_->SetMockSpellCheckerEnabled(enabled); |
| 710 } | 736 } |
| 711 | 737 |
| 712 v8::Local<v8::Value> | 738 v8::Local<v8::Value> |
| 713 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( | 739 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( |
| 714 int world_id, const std::string& script) { | 740 int world_id, const std::string& script) { |
| 715 if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29)) | 741 if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29)) |
| 716 return v8::Local<v8::Value>(); | 742 return v8::Local<v8::Value>(); |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 main_view_(nullptr), | 1572 main_view_(nullptr), |
| 1547 mock_content_settings_client_( | 1573 mock_content_settings_client_( |
| 1548 new MockContentSettingsClient(&layout_test_runtime_flags_)), | 1574 new MockContentSettingsClient(&layout_test_runtime_flags_)), |
| 1549 will_navigate_(false), | 1575 will_navigate_(false), |
| 1550 credential_manager_client_(new MockCredentialManagerClient), | 1576 credential_manager_client_(new MockCredentialManagerClient), |
| 1551 mock_screen_orientation_client_(new MockScreenOrientationClient), | 1577 mock_screen_orientation_client_(new MockScreenOrientationClient), |
| 1552 spellcheck_(new SpellCheckClient(this)), | 1578 spellcheck_(new SpellCheckClient(this)), |
| 1553 chooser_count_(0), | 1579 chooser_count_(0), |
| 1554 previously_focused_view_(nullptr), | 1580 previously_focused_view_(nullptr), |
| 1555 is_web_platform_tests_mode_(false), | 1581 is_web_platform_tests_mode_(false), |
| 1582 effective_connection_type_( |
| 1583 blink::WebEffectiveConnectionType::TypeUnknown), |
| 1556 weak_factory_(this) {} | 1584 weak_factory_(this) {} |
| 1557 | 1585 |
| 1558 TestRunner::~TestRunner() {} | 1586 TestRunner::~TestRunner() {} |
| 1559 | 1587 |
| 1560 void TestRunner::Install( | 1588 void TestRunner::Install( |
| 1561 WebLocalFrame* frame, | 1589 WebLocalFrame* frame, |
| 1562 base::WeakPtr<TestRunnerForSpecificView> view_test_runner) { | 1590 base::WeakPtr<TestRunnerForSpecificView> view_test_runner) { |
| 1563 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner, | 1591 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner, |
| 1564 frame); | 1592 frame); |
| 1565 } | 1593 } |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 void TestRunner::DumpNavigationPolicy() { | 2585 void TestRunner::DumpNavigationPolicy() { |
| 2558 layout_test_runtime_flags_.set_dump_navigation_policy(true); | 2586 layout_test_runtime_flags_.set_dump_navigation_policy(true); |
| 2559 OnLayoutTestRuntimeFlagsChanged(); | 2587 OnLayoutTestRuntimeFlagsChanged(); |
| 2560 } | 2588 } |
| 2561 | 2589 |
| 2562 void TestRunner::SetDumpConsoleMessages(bool value) { | 2590 void TestRunner::SetDumpConsoleMessages(bool value) { |
| 2563 layout_test_runtime_flags_.set_dump_console_messages(value); | 2591 layout_test_runtime_flags_.set_dump_console_messages(value); |
| 2564 OnLayoutTestRuntimeFlagsChanged(); | 2592 OnLayoutTestRuntimeFlagsChanged(); |
| 2565 } | 2593 } |
| 2566 | 2594 |
| 2595 void TestRunner::SetEffectiveConnectionType( |
| 2596 blink::WebEffectiveConnectionType connection_type) { |
| 2597 effective_connection_type_ = connection_type; |
| 2598 } |
| 2599 |
| 2567 void TestRunner::SetMockSpellCheckerEnabled(bool enabled) { | 2600 void TestRunner::SetMockSpellCheckerEnabled(bool enabled) { |
| 2568 spellcheck_->SetEnabled(enabled); | 2601 spellcheck_->SetEnabled(enabled); |
| 2569 } | 2602 } |
| 2570 | 2603 |
| 2571 bool TestRunner::ShouldDumpConsoleMessages() const { | 2604 bool TestRunner::ShouldDumpConsoleMessages() const { |
| 2572 return layout_test_runtime_flags_.dump_console_messages(); | 2605 return layout_test_runtime_flags_.dump_console_messages(); |
| 2573 } | 2606 } |
| 2574 | 2607 |
| 2575 void TestRunner::CloseWebInspector() { | 2608 void TestRunner::CloseWebInspector() { |
| 2576 delegate_->CloseDevTools(); | 2609 delegate_->CloseDevTools(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2725 | 2758 |
| 2726 void TestRunner::NotifyDone() { | 2759 void TestRunner::NotifyDone() { |
| 2727 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2760 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
| 2728 !will_navigate_ && work_queue_.is_empty()) | 2761 !will_navigate_ && work_queue_.is_empty()) |
| 2729 delegate_->TestFinished(); | 2762 delegate_->TestFinished(); |
| 2730 layout_test_runtime_flags_.set_wait_until_done(false); | 2763 layout_test_runtime_flags_.set_wait_until_done(false); |
| 2731 OnLayoutTestRuntimeFlagsChanged(); | 2764 OnLayoutTestRuntimeFlagsChanged(); |
| 2732 } | 2765 } |
| 2733 | 2766 |
| 2734 } // namespace test_runner | 2767 } // namespace test_runner |
| OLD | NEW |