Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: components/test_runner/test_runner.cc

Issue 1908183002: Use correct WebView from TestRunner methods called via testRunner bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accessibility-controller-per-view
Patch Set: Explicit constructor for TestRunnerForSpecificView. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 return 1.f; 95 return 1.f;
96 } 96 }
97 97
98 } // namespace 98 } // namespace
99 99
100 class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> { 100 class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
101 public: 101 public:
102 static gin::WrapperInfo kWrapperInfo; 102 static gin::WrapperInfo kWrapperInfo;
103 103
104 static void Install(base::WeakPtr<TestRunner> controller, 104 static void Install(base::WeakPtr<TestRunner> test_runner,
105 WebFrame* frame); 105 base::WeakPtr<TestRunnerForSpecificView> view_test_runner,
106 WebLocalFrame* frame);
106 107
107 private: 108 private:
108 explicit TestRunnerBindings( 109 explicit TestRunnerBindings(
109 base::WeakPtr<TestRunner> controller); 110 base::WeakPtr<TestRunner> test_runner,
111 base::WeakPtr<TestRunnerForSpecificView> view_test_runner);
110 ~TestRunnerBindings() override; 112 ~TestRunnerBindings() override;
111 113
112 // gin::Wrappable: 114 // gin::Wrappable:
113 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 115 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
114 v8::Isolate* isolate) override; 116 v8::Isolate* isolate) override;
115 117
116 void AddMockSpeechRecognitionResult(const std::string& transcript, 118 void AddMockSpeechRecognitionResult(const std::string& transcript,
117 double confidence); 119 double confidence);
118 void AddOriginAccessWhitelistEntry(const std::string& source_origin, 120 void AddOriginAccessWhitelistEntry(const std::string& source_origin,
119 const std::string& destination_protocol, 121 const std::string& destination_protocol,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool IsCommandEnabled(const std::string& command); 287 bool IsCommandEnabled(const std::string& command);
286 std::string PathToLocalResource(const std::string& path); 288 std::string PathToLocalResource(const std::string& path);
287 std::string PlatformName(); 289 std::string PlatformName();
288 std::string SelectionAsMarkup(); 290 std::string SelectionAsMarkup();
289 std::string TooltipText(); 291 std::string TooltipText();
290 292
291 int WebHistoryItemCount(); 293 int WebHistoryItemCount();
292 int WindowCount(); 294 int WindowCount();
293 295
294 base::WeakPtr<TestRunner> runner_; 296 base::WeakPtr<TestRunner> runner_;
297 base::WeakPtr<TestRunnerForSpecificView> view_runner_;
295 298
296 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings); 299 DISALLOW_COPY_AND_ASSIGN(TestRunnerBindings);
297 }; 300 };
298 301
299 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = { 302 gin::WrapperInfo TestRunnerBindings::kWrapperInfo = {
300 gin::kEmbedderNativeGin}; 303 gin::kEmbedderNativeGin};
301 304
302 // static 305 // static
303 void TestRunnerBindings::Install(base::WeakPtr<TestRunner> runner, 306 void TestRunnerBindings::Install(
304 WebFrame* frame) { 307 base::WeakPtr<TestRunner> test_runner,
308 base::WeakPtr<TestRunnerForSpecificView> view_test_runner,
309 WebLocalFrame* frame) {
305 v8::Isolate* isolate = blink::mainThreadIsolate(); 310 v8::Isolate* isolate = blink::mainThreadIsolate();
306 v8::HandleScope handle_scope(isolate); 311 v8::HandleScope handle_scope(isolate);
307 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 312 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
308 if (context.IsEmpty()) 313 if (context.IsEmpty())
309 return; 314 return;
310 315
311 v8::Context::Scope context_scope(context); 316 v8::Context::Scope context_scope(context);
312 317
313 TestRunnerBindings* wrapped = new TestRunnerBindings(runner); 318 TestRunnerBindings* wrapped =
319 new TestRunnerBindings(test_runner, view_test_runner);
314 gin::Handle<TestRunnerBindings> bindings = 320 gin::Handle<TestRunnerBindings> bindings =
315 gin::CreateHandle(isolate, wrapped); 321 gin::CreateHandle(isolate, wrapped);
316 if (bindings.IsEmpty()) 322 if (bindings.IsEmpty())
317 return; 323 return;
318 v8::Local<v8::Object> global = context->Global(); 324 v8::Local<v8::Object> global = context->Global();
319 v8::Local<v8::Value> v8_bindings = bindings.ToV8(); 325 v8::Local<v8::Value> v8_bindings = bindings.ToV8();
320 326
321 std::vector<std::string> names; 327 std::vector<std::string> names;
322 names.push_back("testRunner"); 328 names.push_back("testRunner");
323 names.push_back("layoutTestController"); 329 names.push_back("layoutTestController");
324 for (size_t i = 0; i < names.size(); ++i) 330 for (size_t i = 0; i < names.size(); ++i)
325 global->Set(gin::StringToV8(isolate, names[i].c_str()), v8_bindings); 331 global->Set(gin::StringToV8(isolate, names[i].c_str()), v8_bindings);
326 } 332 }
327 333
328 TestRunnerBindings::TestRunnerBindings(base::WeakPtr<TestRunner> runner) 334 TestRunnerBindings::TestRunnerBindings(
329 : runner_(runner) {} 335 base::WeakPtr<TestRunner> runner,
336 base::WeakPtr<TestRunnerForSpecificView> view_runner)
337 : runner_(runner), view_runner_(view_runner) {}
330 338
331 TestRunnerBindings::~TestRunnerBindings() {} 339 TestRunnerBindings::~TestRunnerBindings() {}
332 340
333 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( 341 gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
334 v8::Isolate* isolate) { 342 v8::Isolate* isolate) {
335 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate) 343 return gin::Wrappable<TestRunnerBindings>::GetObjectTemplateBuilder(isolate)
336 .SetMethod("abortModal", &TestRunnerBindings::NotImplemented) 344 .SetMethod("abortModal", &TestRunnerBindings::NotImplemented)
337 .SetMethod("addDisallowedURL", &TestRunnerBindings::NotImplemented) 345 .SetMethod("addDisallowedURL", &TestRunnerBindings::NotImplemented)
338 .SetMethod("addMockCredentialManagerError", 346 .SetMethod("addMockCredentialManagerError",
339 &TestRunnerBindings::AddMockCredentialManagerError) 347 &TestRunnerBindings::AddMockCredentialManagerError)
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 runner_->SetCloseRemainingWindowsWhenComplete(close_remaining_windows); 680 runner_->SetCloseRemainingWindowsWhenComplete(close_remaining_windows);
673 } 681 }
674 682
675 void TestRunnerBindings::ResetTestHelperControllers() { 683 void TestRunnerBindings::ResetTestHelperControllers() {
676 if (runner_) 684 if (runner_)
677 runner_->ResetTestHelperControllers(); 685 runner_->ResetTestHelperControllers();
678 } 686 }
679 687
680 void TestRunnerBindings::SetTabKeyCyclesThroughElements( 688 void TestRunnerBindings::SetTabKeyCyclesThroughElements(
681 bool tab_key_cycles_through_elements) { 689 bool tab_key_cycles_through_elements) {
682 if (runner_) 690 if (view_runner_)
683 runner_->SetTabKeyCyclesThroughElements(tab_key_cycles_through_elements); 691 view_runner_->SetTabKeyCyclesThroughElements(
692 tab_key_cycles_through_elements);
684 } 693 }
685 694
686 void TestRunnerBindings::ExecCommand(gin::Arguments* args) { 695 void TestRunnerBindings::ExecCommand(gin::Arguments* args) {
687 if (runner_) 696 if (view_runner_)
688 runner_->ExecCommand(args); 697 view_runner_->ExecCommand(args);
689 } 698 }
690 699
691 bool TestRunnerBindings::IsCommandEnabled(const std::string& command) { 700 bool TestRunnerBindings::IsCommandEnabled(const std::string& command) {
692 if (runner_) 701 if (view_runner_)
693 return runner_->IsCommandEnabled(command); 702 return view_runner_->IsCommandEnabled(command);
694 return false; 703 return false;
695 } 704 }
696 705
697 bool TestRunnerBindings::CallShouldCloseOnWebView() { 706 bool TestRunnerBindings::CallShouldCloseOnWebView() {
698 if (runner_) 707 if (view_runner_)
699 return runner_->CallShouldCloseOnWebView(); 708 return view_runner_->CallShouldCloseOnWebView();
700 return false; 709 return false;
701 } 710 }
702 711
703 void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme( 712 void TestRunnerBindings::SetDomainRelaxationForbiddenForURLScheme(
704 bool forbidden, const std::string& scheme) { 713 bool forbidden, const std::string& scheme) {
705 if (runner_) 714 if (view_runner_)
706 runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme); 715 view_runner_->SetDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
707 } 716 }
708 717
709 v8::Local<v8::Value> 718 v8::Local<v8::Value>
710 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue( 719 TestRunnerBindings::EvaluateScriptInIsolatedWorldAndReturnValue(
711 int world_id, const std::string& script) { 720 int world_id, const std::string& script) {
712 if (!runner_ || world_id <= 0 || world_id >= (1 << 29)) 721 if (!view_runner_ || world_id <= 0 || world_id >= (1 << 29))
713 return v8::Local<v8::Value>(); 722 return v8::Local<v8::Value>();
714 return runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id, 723 return view_runner_->EvaluateScriptInIsolatedWorldAndReturnValue(world_id,
715 script); 724 script);
716 } 725 }
717 726
718 void TestRunnerBindings::EvaluateScriptInIsolatedWorld( 727 void TestRunnerBindings::EvaluateScriptInIsolatedWorld(
719 int world_id, const std::string& script) { 728 int world_id, const std::string& script) {
720 if (runner_ && world_id > 0 && world_id < (1 << 29)) 729 if (view_runner_ && world_id > 0 && world_id < (1 << 29))
721 runner_->EvaluateScriptInIsolatedWorld(world_id, script); 730 view_runner_->EvaluateScriptInIsolatedWorld(world_id, script);
722 } 731 }
723 732
724 void TestRunnerBindings::SetIsolatedWorldSecurityOrigin( 733 void TestRunnerBindings::SetIsolatedWorldSecurityOrigin(
725 int world_id, v8::Local<v8::Value> origin) { 734 int world_id, v8::Local<v8::Value> origin) {
726 if (runner_) 735 if (view_runner_)
727 runner_->SetIsolatedWorldSecurityOrigin(world_id, origin); 736 view_runner_->SetIsolatedWorldSecurityOrigin(world_id, origin);
728 } 737 }
729 738
730 void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy( 739 void TestRunnerBindings::SetIsolatedWorldContentSecurityPolicy(
731 int world_id, const std::string& policy) { 740 int world_id, const std::string& policy) {
732 if (runner_) 741 if (view_runner_)
733 runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy); 742 view_runner_->SetIsolatedWorldContentSecurityPolicy(world_id, policy);
734 } 743 }
735 744
736 void TestRunnerBindings::AddOriginAccessWhitelistEntry( 745 void TestRunnerBindings::AddOriginAccessWhitelistEntry(
737 const std::string& source_origin, 746 const std::string& source_origin,
738 const std::string& destination_protocol, 747 const std::string& destination_protocol,
739 const std::string& destination_host, 748 const std::string& destination_host,
740 bool allow_destination_subdomains) { 749 bool allow_destination_subdomains) {
741 if (runner_) { 750 if (runner_) {
742 runner_->AddOriginAccessWhitelistEntry(source_origin, 751 runner_->AddOriginAccessWhitelistEntry(source_origin,
743 destination_protocol, 752 destination_protocol,
744 destination_host, 753 destination_host,
745 allow_destination_subdomains); 754 allow_destination_subdomains);
746 } 755 }
747 } 756 }
748 757
749 void TestRunnerBindings::RemoveOriginAccessWhitelistEntry( 758 void TestRunnerBindings::RemoveOriginAccessWhitelistEntry(
750 const std::string& source_origin, 759 const std::string& source_origin,
751 const std::string& destination_protocol, 760 const std::string& destination_protocol,
752 const std::string& destination_host, 761 const std::string& destination_host,
753 bool allow_destination_subdomains) { 762 bool allow_destination_subdomains) {
754 if (runner_) { 763 if (runner_) {
755 runner_->RemoveOriginAccessWhitelistEntry(source_origin, 764 runner_->RemoveOriginAccessWhitelistEntry(source_origin,
756 destination_protocol, 765 destination_protocol,
757 destination_host, 766 destination_host,
758 allow_destination_subdomains); 767 allow_destination_subdomains);
759 } 768 }
760 } 769 }
761 770
762 bool TestRunnerBindings::HasCustomPageSizeStyle(int page_index) { 771 bool TestRunnerBindings::HasCustomPageSizeStyle(int page_index) {
763 if (runner_) 772 if (view_runner_)
764 return runner_->HasCustomPageSizeStyle(page_index); 773 return view_runner_->HasCustomPageSizeStyle(page_index);
765 return false; 774 return false;
766 } 775 }
767 776
768 void TestRunnerBindings::ForceRedSelectionColors() { 777 void TestRunnerBindings::ForceRedSelectionColors() {
769 if (runner_) 778 if (view_runner_)
770 runner_->ForceRedSelectionColors(); 779 view_runner_->ForceRedSelectionColors();
771 } 780 }
772 781
773 void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) { 782 void TestRunnerBindings::InsertStyleSheet(const std::string& source_code) {
774 if (runner_) 783 if (runner_)
775 runner_->InsertStyleSheet(source_code); 784 runner_->InsertStyleSheet(source_code);
776 } 785 }
777 786
778 bool TestRunnerBindings::FindString( 787 bool TestRunnerBindings::FindString(
779 const std::string& search_text, 788 const std::string& search_text,
780 const std::vector<std::string>& options_array) { 789 const std::vector<std::string>& options_array) {
781 if (runner_) 790 if (view_runner_)
782 return runner_->FindString(search_text, options_array); 791 return view_runner_->FindString(search_text, options_array);
783 return false; 792 return false;
784 } 793 }
785 794
786 std::string TestRunnerBindings::SelectionAsMarkup() { 795 std::string TestRunnerBindings::SelectionAsMarkup() {
787 if (runner_) 796 if (view_runner_)
788 return runner_->SelectionAsMarkup(); 797 return view_runner_->SelectionAsMarkup();
789 return std::string(); 798 return std::string();
790 } 799 }
791 800
792 void TestRunnerBindings::SetTextSubpixelPositioning(bool value) { 801 void TestRunnerBindings::SetTextSubpixelPositioning(bool value) {
793 if (runner_) 802 if (runner_)
794 runner_->SetTextSubpixelPositioning(value); 803 runner_->SetTextSubpixelPositioning(value);
795 } 804 }
796 805
797 void TestRunnerBindings::SetPageVisibility(const std::string& new_visibility) { 806 void TestRunnerBindings::SetPageVisibility(const std::string& new_visibility) {
798 if (runner_) 807 if (view_runner_)
799 runner_->SetPageVisibility(new_visibility); 808 view_runner_->SetPageVisibility(new_visibility);
800 } 809 }
801 810
802 void TestRunnerBindings::SetTextDirection(const std::string& direction_name) { 811 void TestRunnerBindings::SetTextDirection(const std::string& direction_name) {
803 if (runner_) 812 if (view_runner_)
804 runner_->SetTextDirection(direction_name); 813 view_runner_->SetTextDirection(direction_name);
805 } 814 }
806 815
807 void TestRunnerBindings::UseUnfortunateSynchronousResizeMode() { 816 void TestRunnerBindings::UseUnfortunateSynchronousResizeMode() {
808 if (runner_) 817 if (runner_)
809 runner_->UseUnfortunateSynchronousResizeMode(); 818 runner_->UseUnfortunateSynchronousResizeMode();
810 } 819 }
811 820
812 bool TestRunnerBindings::EnableAutoResizeMode(int min_width, 821 bool TestRunnerBindings::EnableAutoResizeMode(int min_width,
813 int min_height, 822 int min_height,
814 int max_width, 823 int max_width,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 941
933 runner_->SetMockScreenOrientation(orientation); 942 runner_->SetMockScreenOrientation(orientation);
934 } 943 }
935 944
936 void TestRunnerBindings::DisableMockScreenOrientation() { 945 void TestRunnerBindings::DisableMockScreenOrientation() {
937 if (runner_) 946 if (runner_)
938 runner_->DisableMockScreenOrientation(); 947 runner_->DisableMockScreenOrientation();
939 } 948 }
940 949
941 void TestRunnerBindings::DidAcquirePointerLock() { 950 void TestRunnerBindings::DidAcquirePointerLock() {
942 if (runner_) 951 if (view_runner_)
943 runner_->DidAcquirePointerLock(); 952 view_runner_->DidAcquirePointerLock();
944 } 953 }
945 954
946 void TestRunnerBindings::DidNotAcquirePointerLock() { 955 void TestRunnerBindings::DidNotAcquirePointerLock() {
947 if (runner_) 956 if (view_runner_)
948 runner_->DidNotAcquirePointerLock(); 957 view_runner_->DidNotAcquirePointerLock();
949 } 958 }
950 959
951 void TestRunnerBindings::DidLosePointerLock() { 960 void TestRunnerBindings::DidLosePointerLock() {
952 if (runner_) 961 if (view_runner_)
953 runner_->DidLosePointerLock(); 962 view_runner_->DidLosePointerLock();
954 } 963 }
955 964
956 void TestRunnerBindings::SetPointerLockWillFailSynchronously() { 965 void TestRunnerBindings::SetPointerLockWillFailSynchronously() {
957 if (runner_) 966 if (view_runner_)
958 runner_->SetPointerLockWillFailSynchronously(); 967 view_runner_->SetPointerLockWillFailSynchronously();
959 } 968 }
960 969
961 void TestRunnerBindings::SetPointerLockWillRespondAsynchronously() { 970 void TestRunnerBindings::SetPointerLockWillRespondAsynchronously() {
962 if (runner_) 971 if (view_runner_)
963 runner_->SetPointerLockWillRespondAsynchronously(); 972 view_runner_->SetPointerLockWillRespondAsynchronously();
964 } 973 }
965 974
966 void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) { 975 void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) {
967 if (runner_) 976 if (runner_)
968 runner_->SetPopupBlockingEnabled(block_popups); 977 runner_->SetPopupBlockingEnabled(block_popups);
969 } 978 }
970 979
971 void TestRunnerBindings::SetJavaScriptCanAccessClipboard(bool can_access) { 980 void TestRunnerBindings::SetJavaScriptCanAccessClipboard(bool can_access) {
972 if (runner_) 981 if (runner_)
973 runner_->SetJavaScriptCanAccessClipboard(can_access); 982 runner_->SetJavaScriptCanAccessClipboard(can_access);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 if (runner_) 1209 if (runner_)
1201 runner_->DumpDragImage(); 1210 runner_->DumpDragImage();
1202 } 1211 }
1203 1212
1204 void TestRunnerBindings::DumpNavigationPolicy() { 1213 void TestRunnerBindings::DumpNavigationPolicy() {
1205 if (runner_) 1214 if (runner_)
1206 runner_->DumpNavigationPolicy(); 1215 runner_->DumpNavigationPolicy();
1207 } 1216 }
1208 1217
1209 void TestRunnerBindings::DumpPageImportanceSignals() { 1218 void TestRunnerBindings::DumpPageImportanceSignals() {
1210 if (runner_) 1219 if (view_runner_)
1211 runner_->DumpPageImportanceSignals(); 1220 view_runner_->DumpPageImportanceSignals();
1212 } 1221 }
1213 1222
1214 void TestRunnerBindings::ShowWebInspector(gin::Arguments* args) { 1223 void TestRunnerBindings::ShowWebInspector(gin::Arguments* args) {
1215 if (runner_) { 1224 if (runner_) {
1216 std::string settings; 1225 std::string settings;
1217 args->GetNext(&settings); 1226 args->GetNext(&settings);
1218 std::string frontend_url; 1227 std::string frontend_url;
1219 args->GetNext(&frontend_url); 1228 args->GetNext(&frontend_url);
1220 runner_->ShowWebInspector(settings, frontend_url); 1229 runner_->ShowWebInspector(settings, frontend_url);
1221 } 1230 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 if (runner_) 1264 if (runner_)
1256 runner_->SetDatabaseQuota(quota); 1265 runner_->SetDatabaseQuota(quota);
1257 } 1266 }
1258 1267
1259 void TestRunnerBindings::SetAlwaysAcceptCookies(bool accept) { 1268 void TestRunnerBindings::SetAlwaysAcceptCookies(bool accept) {
1260 if (runner_) 1269 if (runner_)
1261 runner_->SetAlwaysAcceptCookies(accept); 1270 runner_->SetAlwaysAcceptCookies(accept);
1262 } 1271 }
1263 1272
1264 void TestRunnerBindings::SetWindowIsKey(bool value) { 1273 void TestRunnerBindings::SetWindowIsKey(bool value) {
1265 if (runner_) 1274 if (view_runner_)
1266 runner_->SetWindowIsKey(value); 1275 view_runner_->SetWindowIsKey(value);
1267 } 1276 }
1268 1277
1269 std::string TestRunnerBindings::PathToLocalResource(const std::string& path) { 1278 std::string TestRunnerBindings::PathToLocalResource(const std::string& path) {
1270 if (runner_) 1279 if (runner_)
1271 return runner_->PathToLocalResource(path); 1280 return runner_->PathToLocalResource(path);
1272 return std::string(); 1281 return std::string();
1273 } 1282 }
1274 1283
1275 void TestRunnerBindings::SetBackingScaleFactor( 1284 void TestRunnerBindings::SetBackingScaleFactor(
1276 double value, v8::Local<v8::Function> callback) { 1285 double value, v8::Local<v8::Function> callback) {
1277 if (runner_) 1286 if (view_runner_)
1278 runner_->SetBackingScaleFactor(value, callback); 1287 view_runner_->SetBackingScaleFactor(value, callback);
1279 } 1288 }
1280 1289
1281 void TestRunnerBindings::EnableUseZoomForDSF( 1290 void TestRunnerBindings::EnableUseZoomForDSF(
1282 v8::Local<v8::Function> callback) { 1291 v8::Local<v8::Function> callback) {
1283 if (runner_) 1292 if (view_runner_)
1284 runner_->EnableUseZoomForDSF(callback); 1293 view_runner_->EnableUseZoomForDSF(callback);
1285 } 1294 }
1286 1295
1287 void TestRunnerBindings::SetColorProfile( 1296 void TestRunnerBindings::SetColorProfile(
1288 const std::string& name, v8::Local<v8::Function> callback) { 1297 const std::string& name, v8::Local<v8::Function> callback) {
1289 if (runner_) 1298 if (view_runner_)
1290 runner_->SetColorProfile(name, callback); 1299 view_runner_->SetColorProfile(name, callback);
1291 } 1300 }
1292 1301
1293 void TestRunnerBindings::SetBluetoothFakeAdapter( 1302 void TestRunnerBindings::SetBluetoothFakeAdapter(
1294 const std::string& adapter_name, 1303 const std::string& adapter_name,
1295 v8::Local<v8::Function> callback) { 1304 v8::Local<v8::Function> callback) {
1296 if (runner_) 1305 if (view_runner_)
1297 runner_->SetBluetoothFakeAdapter(adapter_name, callback); 1306 view_runner_->SetBluetoothFakeAdapter(adapter_name, callback);
1298 } 1307 }
1299 1308
1300 void TestRunnerBindings::SetBluetoothManualChooser(bool enable) { 1309 void TestRunnerBindings::SetBluetoothManualChooser(bool enable) {
1301 if (runner_) 1310 if (view_runner_)
1302 runner_->SetBluetoothManualChooser(enable); 1311 view_runner_->SetBluetoothManualChooser(enable);
1303 } 1312 }
1304 1313
1305 void TestRunnerBindings::GetBluetoothManualChooserEvents( 1314 void TestRunnerBindings::GetBluetoothManualChooserEvents(
1306 v8::Local<v8::Function> callback) { 1315 v8::Local<v8::Function> callback) {
1307 if (runner_) 1316 if (view_runner_)
1308 return runner_->GetBluetoothManualChooserEvents(callback); 1317 return view_runner_->GetBluetoothManualChooserEvents(callback);
1309 } 1318 }
1310 1319
1311 void TestRunnerBindings::SendBluetoothManualChooserEvent( 1320 void TestRunnerBindings::SendBluetoothManualChooserEvent(
1312 const std::string& event, 1321 const std::string& event,
1313 const std::string& argument) { 1322 const std::string& argument) {
1314 if (runner_) 1323 if (view_runner_)
1315 runner_->SendBluetoothManualChooserEvent(event, argument); 1324 view_runner_->SendBluetoothManualChooserEvent(event, argument);
1316 } 1325 }
1317 1326
1318 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) { 1327 void TestRunnerBindings::SetPOSIXLocale(const std::string& locale) {
1319 if (runner_) 1328 if (runner_)
1320 runner_->SetPOSIXLocale(locale); 1329 runner_->SetPOSIXLocale(locale);
1321 } 1330 }
1322 1331
1323 void TestRunnerBindings::SetMIDIAccessorResult(bool result) { 1332 void TestRunnerBindings::SetMIDIAccessorResult(bool result) {
1324 if (runner_) 1333 if (runner_)
1325 runner_->SetMIDIAccessorResult(result); 1334 runner_->SetMIDIAccessorResult(result);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 runner_->AddMockCredentialManagerResponse(id, name, avatar, password); 1369 runner_->AddMockCredentialManagerResponse(id, name, avatar, password);
1361 } 1370 }
1362 1371
1363 void TestRunnerBindings::AddMockCredentialManagerError( 1372 void TestRunnerBindings::AddMockCredentialManagerError(
1364 const std::string& error) { 1373 const std::string& error) {
1365 if (runner_) 1374 if (runner_)
1366 runner_->AddMockCredentialManagerError(error); 1375 runner_->AddMockCredentialManagerError(error);
1367 } 1376 }
1368 1377
1369 void TestRunnerBindings::AddWebPageOverlay() { 1378 void TestRunnerBindings::AddWebPageOverlay() {
1370 if (runner_) 1379 if (view_runner_)
1371 runner_->AddWebPageOverlay(); 1380 view_runner_->AddWebPageOverlay();
1372 } 1381 }
1373 1382
1374 void TestRunnerBindings::RemoveWebPageOverlay() { 1383 void TestRunnerBindings::RemoveWebPageOverlay() {
1375 if (runner_) 1384 if (view_runner_)
1376 runner_->RemoveWebPageOverlay(); 1385 view_runner_->RemoveWebPageOverlay();
1377 } 1386 }
1378 1387
1379 void TestRunnerBindings::LayoutAndPaintAsync() { 1388 void TestRunnerBindings::LayoutAndPaintAsync() {
1380 if (runner_) 1389 if (view_runner_)
1381 runner_->LayoutAndPaintAsync(); 1390 view_runner_->LayoutAndPaintAsync();
1382 } 1391 }
1383 1392
1384 void TestRunnerBindings::LayoutAndPaintAsyncThen( 1393 void TestRunnerBindings::LayoutAndPaintAsyncThen(
1385 v8::Local<v8::Function> callback) { 1394 v8::Local<v8::Function> callback) {
1386 if (runner_) 1395 if (view_runner_)
1387 runner_->LayoutAndPaintAsyncThen(callback); 1396 view_runner_->LayoutAndPaintAsyncThen(callback);
1388 } 1397 }
1389 1398
1390 void TestRunnerBindings::GetManifestThen(v8::Local<v8::Function> callback) { 1399 void TestRunnerBindings::GetManifestThen(v8::Local<v8::Function> callback) {
1391 if (runner_) 1400 if (view_runner_)
1392 runner_->GetManifestThen(callback); 1401 view_runner_->GetManifestThen(callback);
1393 } 1402 }
1394 1403
1395 void TestRunnerBindings::CapturePixelsAsyncThen( 1404 void TestRunnerBindings::CapturePixelsAsyncThen(
1396 v8::Local<v8::Function> callback) { 1405 v8::Local<v8::Function> callback) {
1397 if (runner_) 1406 if (view_runner_)
1398 runner_->CapturePixelsAsyncThen(callback); 1407 view_runner_->CapturePixelsAsyncThen(callback);
1399 } 1408 }
1400 1409
1401 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen( 1410 void TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen(
1402 int x, int y, v8::Local<v8::Function> callback) { 1411 int x, int y, v8::Local<v8::Function> callback) {
1403 if (runner_) 1412 if (view_runner_)
1404 runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback); 1413 view_runner_->CopyImageAtAndCapturePixelsAsyncThen(x, y, callback);
1405 } 1414 }
1406 1415
1407 void TestRunnerBindings::SetCustomTextOutput(const std::string& output) { 1416 void TestRunnerBindings::SetCustomTextOutput(const std::string& output) {
1408 if (runner_) 1417 if (runner_)
1409 runner_->setCustomTextOutput(output); 1418 runner_->setCustomTextOutput(output);
1410 } 1419 }
1411 1420
1412 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name, 1421 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name,
1413 bool enabled) { 1422 bool enabled) {
1414 if (runner_ && runner_->web_view_) { 1423 if (view_runner_)
1415 WebFrame* target_frame = 1424 view_runner_->SetViewSourceForFrame(name, enabled);
1416 runner_->web_view_->findFrameByName(WebString::fromUTF8(name));
1417 if (target_frame)
1418 target_frame->enableViewSourceMode(enabled);
1419 }
1420 } 1425 }
1421 1426
1422 void TestRunnerBindings::SetGeofencingMockProvider(bool service_available) { 1427 void TestRunnerBindings::SetGeofencingMockProvider(bool service_available) {
1423 if (runner_) 1428 if (runner_)
1424 runner_->SetGeofencingMockProvider(service_available); 1429 runner_->SetGeofencingMockProvider(service_available);
1425 } 1430 }
1426 1431
1427 void TestRunnerBindings::ClearGeofencingMockProvider() { 1432 void TestRunnerBindings::ClearGeofencingMockProvider() {
1428 if (runner_) 1433 if (runner_)
1429 runner_->ClearGeofencingMockProvider(); 1434 runner_->ClearGeofencingMockProvider();
(...skipping 13 matching lines...) Expand all
1443 return; 1448 return;
1444 1449
1445 return runner_->SetPermission( 1450 return runner_->SetPermission(
1446 name, value, GURL(origin), GURL(embedding_origin)); 1451 name, value, GURL(origin), GURL(embedding_origin));
1447 } 1452 }
1448 1453
1449 void TestRunnerBindings::DispatchBeforeInstallPromptEvent( 1454 void TestRunnerBindings::DispatchBeforeInstallPromptEvent(
1450 int request_id, 1455 int request_id,
1451 const std::vector<std::string>& event_platforms, 1456 const std::vector<std::string>& event_platforms,
1452 v8::Local<v8::Function> callback) { 1457 v8::Local<v8::Function> callback) {
1453 if (!runner_) 1458 if (!view_runner_)
1454 return; 1459 return;
1455 1460
1456 return runner_->DispatchBeforeInstallPromptEvent(request_id, event_platforms, 1461 return view_runner_->DispatchBeforeInstallPromptEvent(
1457 callback); 1462 request_id, event_platforms, callback);
1458 } 1463 }
1459 1464
1460 void TestRunnerBindings::ResolveBeforeInstallPromptPromise( 1465 void TestRunnerBindings::ResolveBeforeInstallPromptPromise(
1461 int request_id, 1466 int request_id,
1462 const std::string& platform) { 1467 const std::string& platform) {
1463 if (!runner_) 1468 if (!runner_)
1464 return; 1469 return;
1465 1470
1466 runner_->ResolveBeforeInstallPromptPromise(request_id, platform); 1471 runner_->ResolveBeforeInstallPromptPromise(request_id, platform);
1467 } 1472 }
1468 1473
1469 void TestRunnerBindings::RunIdleTasks(v8::Local<v8::Function> callback) { 1474 void TestRunnerBindings::RunIdleTasks(v8::Local<v8::Function> callback) {
1470 if (!runner_) 1475 if (!view_runner_)
1471 return; 1476 return;
1472 runner_->RunIdleTasks(callback); 1477 view_runner_->RunIdleTasks(callback);
1473 } 1478 }
1474 1479
1475 std::string TestRunnerBindings::PlatformName() { 1480 std::string TestRunnerBindings::PlatformName() {
1476 if (runner_) 1481 if (runner_)
1477 return runner_->platform_name_; 1482 return runner_->platform_name_;
1478 return std::string(); 1483 return std::string();
1479 } 1484 }
1480 1485
1481 std::string TestRunnerBindings::TooltipText() { 1486 std::string TestRunnerBindings::TooltipText() {
1482 if (runner_) 1487 if (runner_)
(...skipping 14 matching lines...) Expand all
1497 } 1502 }
1498 1503
1499 void TestRunnerBindings::SetInterceptPostMessage(bool value) { 1504 void TestRunnerBindings::SetInterceptPostMessage(bool value) {
1500 if (runner_) { 1505 if (runner_) {
1501 runner_->layout_test_runtime_flags_.set_intercept_post_message(value); 1506 runner_->layout_test_runtime_flags_.set_intercept_post_message(value);
1502 runner_->OnLayoutTestRuntimeFlagsChanged(); 1507 runner_->OnLayoutTestRuntimeFlagsChanged();
1503 } 1508 }
1504 } 1509 }
1505 1510
1506 void TestRunnerBindings::ForceNextWebGLContextCreationToFail() { 1511 void TestRunnerBindings::ForceNextWebGLContextCreationToFail() {
1507 if (runner_) 1512 if (view_runner_)
1508 runner_->ForceNextWebGLContextCreationToFail(); 1513 view_runner_->ForceNextWebGLContextCreationToFail();
1509 } 1514 }
1510 1515
1511 void TestRunnerBindings::ForceNextDrawingBufferCreationToFail() { 1516 void TestRunnerBindings::ForceNextDrawingBufferCreationToFail() {
1512 if (runner_) 1517 if (view_runner_)
1513 runner_->ForceNextDrawingBufferCreationToFail(); 1518 view_runner_->ForceNextDrawingBufferCreationToFail();
1514 } 1519 }
1515 1520
1516 void TestRunnerBindings::NotImplemented(const gin::Arguments& args) { 1521 void TestRunnerBindings::NotImplemented(const gin::Arguments& args) {
1517 } 1522 }
1518 1523
1519 TestRunner::WorkQueue::WorkQueue(TestRunner* controller) 1524 TestRunner::WorkQueue::WorkQueue(TestRunner* controller)
1520 : frozen_(false), controller_(controller), weak_factory_(this) {} 1525 : frozen_(false), controller_(controller), weak_factory_(this) {}
1521 1526
1522 TestRunner::WorkQueue::~WorkQueue() { 1527 TestRunner::WorkQueue::~WorkQueue() {
1523 Reset(); 1528 Reset();
1524 } 1529 }
1525 1530
1526 void TestRunner::WorkQueue::ProcessWorkSoon() { 1531 void TestRunner::WorkQueue::ProcessWorkSoon() {
1527 if (controller_->topLoadingFrame()) 1532 if (controller_->topLoadingFrame())
1528 return; 1533 return;
1529 1534
1530 if (!queue_.empty()) { 1535 if (!queue_.empty()) {
1531 // We delay processing queued work to avoid recursion problems. 1536 // We delay processing queued work to avoid recursion problems.
1532 controller_->PostTask(base::Bind(&TestRunner::WorkQueue::ProcessWork, 1537 controller_->delegate_->PostTask(new WebCallbackTask(base::Bind(
1533 weak_factory_.GetWeakPtr())); 1538 &TestRunner::WorkQueue::ProcessWork, weak_factory_.GetWeakPtr())));
1534 } else if (!controller_->layout_test_runtime_flags_.wait_until_done()) { 1539 } else if (!controller_->layout_test_runtime_flags_.wait_until_done()) {
1535 controller_->delegate_->TestFinished(); 1540 controller_->delegate_->TestFinished();
1536 } 1541 }
1537 } 1542 }
1538 1543
1539 void TestRunner::WorkQueue::Reset() { 1544 void TestRunner::WorkQueue::Reset() {
1540 frozen_ = false; 1545 frozen_ = false;
1541 while (!queue_.empty()) { 1546 while (!queue_.empty()) {
1542 delete queue_.front(); 1547 delete queue_.front();
1543 queue_.pop_front(); 1548 queue_.pop_front();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 new MockContentSettingsClient(&layout_test_runtime_flags_)), 1585 new MockContentSettingsClient(&layout_test_runtime_flags_)),
1581 credential_manager_client_(new MockCredentialManagerClient), 1586 credential_manager_client_(new MockCredentialManagerClient),
1582 mock_screen_orientation_client_(new MockScreenOrientationClient), 1587 mock_screen_orientation_client_(new MockScreenOrientationClient),
1583 spellcheck_(new SpellCheckClient(this)), 1588 spellcheck_(new SpellCheckClient(this)),
1584 chooser_count_(0), 1589 chooser_count_(0),
1585 previously_focused_view_(nullptr), 1590 previously_focused_view_(nullptr),
1586 weak_factory_(this) {} 1591 weak_factory_(this) {}
1587 1592
1588 TestRunner::~TestRunner() {} 1593 TestRunner::~TestRunner() {}
1589 1594
1590 void TestRunner::Install(WebFrame* frame) { 1595 void TestRunner::Install(
1591 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); 1596 WebLocalFrame* frame,
1597 base::WeakPtr<TestRunnerForSpecificView> view_test_runner) {
1598 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner,
1599 frame);
1592 } 1600 }
1593 1601
1594 void TestRunner::SetDelegate(WebTestDelegate* delegate) { 1602 void TestRunner::SetDelegate(WebTestDelegate* delegate) {
1595 delegate_ = delegate; 1603 delegate_ = delegate;
1596 mock_content_settings_client_->SetDelegate(delegate); 1604 mock_content_settings_client_->SetDelegate(delegate);
1597 spellcheck_->SetDelegate(delegate); 1605 spellcheck_->SetDelegate(delegate);
1598 if (speech_recognizer_) 1606 if (speech_recognizer_)
1599 speech_recognizer_->SetDelegate(delegate); 1607 speech_recognizer_->SetDelegate(delegate);
1600 } 1608 }
1601 1609
1602 void TestRunner::SetWebView(WebView* webView) { 1610 void TestRunner::SetWebView(WebView* webView) {
1603 web_view_ = webView; 1611 web_view_ = webView;
1604 } 1612 }
1605 1613
1606 void TestRunner::Reset() { 1614 void TestRunner::Reset() {
1607 if (web_view_) {
1608 web_view_->setZoomLevel(0);
1609 web_view_->setTextZoomFactor(1);
1610 web_view_->setTabKeyCyclesThroughElements(true);
1611 #if !defined(OS_MACOSX) && !defined(OS_WIN)
1612 // (Constants copied because we can't depend on the header that defined
1613 // them from this file.)
1614 web_view_->setSelectionColors(
1615 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
1616 #endif
1617 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true);
1618 web_view_->mainFrame()->enableViewSourceMode(false);
1619
1620 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
1621 }
1622
1623 top_loading_frame_ = nullptr; 1615 top_loading_frame_ = nullptr;
1624 layout_test_runtime_flags_.Reset(); 1616 layout_test_runtime_flags_.Reset();
1625 mock_screen_orientation_client_->ResetData(); 1617 mock_screen_orientation_client_->ResetData();
1626 drag_image_.reset(); 1618 drag_image_.reset();
1627 views_with_scheduled_animations_.clear(); 1619 views_with_scheduled_animations_.clear();
1628 1620
1629 WebSecurityPolicy::resetOriginAccessWhitelists(); 1621 WebSecurityPolicy::resetOriginAccessWhitelists();
1630 #if defined(__linux__) || defined(ANDROID) 1622 #if defined(__linux__) || defined(ANDROID)
1631 WebFontRendering::setSubpixelPositioning(false); 1623 WebFontRendering::setSubpixelPositioning(false);
1632 #endif 1624 #endif
(...skipping 27 matching lines...) Expand all
1660 custom_text_output_.clear(); 1652 custom_text_output_.clear();
1661 1653
1662 http_headers_to_clear_.clear(); 1654 http_headers_to_clear_.clear();
1663 1655
1664 platform_name_ = "chromium"; 1656 platform_name_ = "chromium";
1665 tooltip_text_ = std::string(); 1657 tooltip_text_ = std::string();
1666 web_history_item_count_ = 0; 1658 web_history_item_count_ = 0;
1667 1659
1668 SetUseMockTheme(true); 1660 SetUseMockTheme(true);
1669 1661
1670 pointer_locked_ = false;
1671 pointer_lock_planned_result_ = PointerLockWillSucceed;
1672
1673 weak_factory_.InvalidateWeakPtrs(); 1662 weak_factory_.InvalidateWeakPtrs();
1674 work_queue_.Reset(); 1663 work_queue_.Reset();
1675 1664
1676 if (close_remaining_windows_ && delegate_) 1665 if (close_remaining_windows_ && delegate_)
1677 delegate_->CloseRemainingWindows(); 1666 delegate_->CloseRemainingWindows();
1678 else 1667 else
1679 close_remaining_windows_ = true; 1668 close_remaining_windows_ = true;
1680 } 1669 }
1681 1670
1682 void TestRunner::SetTestIsRunning(bool running) { 1671 void TestRunner::SetTestIsRunning(bool running) {
1683 test_is_running_ = running; 1672 test_is_running_ = running;
1684 } 1673 }
1685 1674
1686 void TestRunner::PostTask(const base::Closure& callback) { 1675 void TestRunnerForSpecificView::PostTask(const base::Closure& callback) {
1687 delegate_->PostTask(new WebCallbackTask(callback)); 1676 delegate()->PostTask(new WebCallbackTask(callback));
1688 } 1677 }
1689 1678
1690 void TestRunner::PostDelayedTask(long long delay, 1679 void TestRunnerForSpecificView::PostDelayedTask(long long delay,
1691 const base::Closure& callback) { 1680 const base::Closure& callback) {
1692 delegate_->PostDelayedTask(new WebCallbackTask(callback), delay); 1681 delegate()->PostDelayedTask(new WebCallbackTask(callback), delay);
1693 } 1682 }
1694 1683
1695 void TestRunner::PostV8Callback(const v8::Local<v8::Function>& callback) { 1684 void TestRunnerForSpecificView::PostV8Callback(
1696 PostTask(base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(), 1685 const v8::Local<v8::Function>& callback) {
1686 PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
1687 weak_factory_.GetWeakPtr(),
1697 v8::UniquePersistent<v8::Function>( 1688 v8::UniquePersistent<v8::Function>(
1698 blink::mainThreadIsolate(), callback))); 1689 blink::mainThreadIsolate(), callback)));
1699 } 1690 }
1700 1691
1701 void TestRunner::PostV8CallbackWithArgs( 1692 void TestRunnerForSpecificView::PostV8CallbackWithArgs(
1702 v8::UniquePersistent<v8::Function> callback, 1693 v8::UniquePersistent<v8::Function> callback,
1703 int argc, 1694 int argc,
1704 v8::Local<v8::Value> argv[]) { 1695 v8::Local<v8::Value> argv[]) {
1705 std::vector<v8::UniquePersistent<v8::Value>> args; 1696 std::vector<v8::UniquePersistent<v8::Value>> args;
1706 for (int i = 0; i < argc; i++) { 1697 for (int i = 0; i < argc; i++) {
1707 args.push_back( 1698 args.push_back(
1708 v8::UniquePersistent<v8::Value>(blink::mainThreadIsolate(), argv[i])); 1699 v8::UniquePersistent<v8::Value>(blink::mainThreadIsolate(), argv[i]));
1709 } 1700 }
1710 1701
1711 PostTask(base::Bind(&TestRunner::InvokeV8CallbackWithArgs, 1702 PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8CallbackWithArgs,
1712 weak_factory_.GetWeakPtr(), std::move(callback), 1703 weak_factory_.GetWeakPtr(), std::move(callback),
1713 std::move(args))); 1704 std::move(args)));
1714 } 1705 }
1715 1706
1716 void TestRunner::InvokeV8Callback( 1707 void TestRunnerForSpecificView::InvokeV8Callback(
1717 const v8::UniquePersistent<v8::Function>& callback) { 1708 const v8::UniquePersistent<v8::Function>& callback) {
1718 std::vector<v8::UniquePersistent<v8::Value>> empty_args; 1709 std::vector<v8::UniquePersistent<v8::Value>> empty_args;
1719 InvokeV8CallbackWithArgs(callback, std::move(empty_args)); 1710 InvokeV8CallbackWithArgs(callback, std::move(empty_args));
1720 } 1711 }
1721 1712
1722 void TestRunner::InvokeV8CallbackWithArgs( 1713 void TestRunnerForSpecificView::InvokeV8CallbackWithArgs(
1723 const v8::UniquePersistent<v8::Function>& callback, 1714 const v8::UniquePersistent<v8::Function>& callback,
1724 const std::vector<v8::UniquePersistent<v8::Value>>& args) { 1715 const std::vector<v8::UniquePersistent<v8::Value>>& args) {
1725 v8::Isolate* isolate = blink::mainThreadIsolate(); 1716 v8::Isolate* isolate = blink::mainThreadIsolate();
1726 v8::HandleScope handle_scope(isolate); 1717 v8::HandleScope handle_scope(isolate);
1727 1718
1728 if (!web_view_) 1719 WebFrame* frame = web_view()->mainFrame();
1729 return;
1730 WebFrame* frame = web_view_->mainFrame();
1731 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 1720 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
1732 if (context.IsEmpty()) 1721 if (context.IsEmpty())
1733 return; 1722 return;
1734 v8::Context::Scope context_scope(context); 1723 v8::Context::Scope context_scope(context);
1735 1724
1736 std::vector<v8::Local<v8::Value>> local_args; 1725 std::vector<v8::Local<v8::Value>> local_args;
1737 for (const auto& arg : args) { 1726 for (const auto& arg : args) {
1738 local_args.push_back(v8::Local<v8::Value>::New(isolate, arg)); 1727 local_args.push_back(v8::Local<v8::Value>::New(isolate, arg));
1739 } 1728 }
1740 1729
1741 frame->callFunctionEvenIfScriptDisabled( 1730 frame->callFunctionEvenIfScriptDisabled(
1742 v8::Local<v8::Function>::New(isolate, callback), context->Global(), 1731 v8::Local<v8::Function>::New(isolate, callback), context->Global(),
1743 local_args.size(), local_args.data()); 1732 local_args.size(), local_args.data());
1744 } 1733 }
1745 1734
1746 base::Closure TestRunner::CreateClosureThatPostsV8Callback( 1735 base::Closure TestRunnerForSpecificView::CreateClosureThatPostsV8Callback(
1747 const v8::Local<v8::Function>& callback) { 1736 const v8::Local<v8::Function>& callback) {
1748 return base::Bind( 1737 return base::Bind(&TestRunnerForSpecificView::PostTask,
1749 &TestRunner::PostTask, weak_factory_.GetWeakPtr(), 1738 weak_factory_.GetWeakPtr(),
1750 base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(), 1739 base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
1751 v8::UniquePersistent<v8::Function>(blink::mainThreadIsolate(), 1740 weak_factory_.GetWeakPtr(),
1752 callback))); 1741 v8::UniquePersistent<v8::Function>(
1742 blink::mainThreadIsolate(), callback)));
1753 } 1743 }
1754 1744
1755 bool TestRunner::shouldDumpEditingCallbacks() const { 1745 bool TestRunner::shouldDumpEditingCallbacks() const {
1756 return layout_test_runtime_flags_.dump_editting_callbacks(); 1746 return layout_test_runtime_flags_.dump_editting_callbacks();
1757 } 1747 }
1758 1748
1759 void TestRunner::setShouldDumpAsText(bool value) { 1749 void TestRunner::setShouldDumpAsText(bool value) {
1760 layout_test_runtime_flags_.set_dump_as_text(value); 1750 layout_test_runtime_flags_.set_dump_as_text(value);
1761 OnLayoutTestRuntimeFlagsChanged(); 1751 OnLayoutTestRuntimeFlagsChanged();
1762 } 1752 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 bitmap.eraseColor(0); 1816 bitmap.eraseColor(0);
1827 } 1817 }
1828 callback.Run(bitmap); 1818 callback.Run(bitmap);
1829 return; 1819 return;
1830 } 1820 }
1831 1821
1832 callback.Run(drag_image_.getSkBitmap()); 1822 callback.Run(drag_image_.getSkBitmap());
1833 return; 1823 return;
1834 } 1824 }
1835 1825
1836 test_runner::DumpPixelsAsync(web_view_, layout_test_runtime_flags_, 1826 test_runner::DumpPixelsAsync(web_view, layout_test_runtime_flags_,
1837 delegate_->GetDeviceScaleFactorForTest(), 1827 delegate_->GetDeviceScaleFactorForTest(),
1838 callback); 1828 callback);
1839 } 1829 }
1840 1830
1841 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1831 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1842 const base::DictionaryValue& changed_values) { 1832 const base::DictionaryValue& changed_values) {
1843 DCHECK(test_is_running_); 1833 DCHECK(test_is_running_);
1844 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1834 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1845 changed_values); 1835 changed_values);
1846 } 1836 }
(...skipping 16 matching lines...) Expand all
1863 layout_test_runtime_flags_.set_dump_frame_load_callbacks(value); 1853 layout_test_runtime_flags_.set_dump_frame_load_callbacks(value);
1864 OnLayoutTestRuntimeFlagsChanged(); 1854 OnLayoutTestRuntimeFlagsChanged();
1865 } 1855 }
1866 1856
1867 bool TestRunner::shouldDumpPingLoaderCallbacks() const { 1857 bool TestRunner::shouldDumpPingLoaderCallbacks() const {
1868 return test_is_running_ && 1858 return test_is_running_ &&
1869 layout_test_runtime_flags_.dump_ping_loader_callbacks(); 1859 layout_test_runtime_flags_.dump_ping_loader_callbacks();
1870 } 1860 }
1871 1861
1872 void TestRunner::setShouldEnableViewSource(bool value) { 1862 void TestRunner::setShouldEnableViewSource(bool value) {
1863 // TODO(lukasza): This flag should be 1) replicated across OOPIFs and
1864 // 2) applied to all views, not just the main window view.
1873 web_view_->mainFrame()->enableViewSourceMode(value); 1865 web_view_->mainFrame()->enableViewSourceMode(value);
1874 } 1866 }
1875 1867
1876 bool TestRunner::shouldDumpUserGestureInFrameLoadCallbacks() const { 1868 bool TestRunner::shouldDumpUserGestureInFrameLoadCallbacks() const {
1877 return test_is_running_ && 1869 return test_is_running_ &&
1878 layout_test_runtime_flags_.dump_user_gesture_in_frame_load_callbacks(); 1870 layout_test_runtime_flags_.dump_user_gesture_in_frame_load_callbacks();
1879 } 1871 }
1880 1872
1881 bool TestRunner::shouldDumpTitleChanges() const { 1873 bool TestRunner::shouldDumpTitleChanges() const {
1882 return layout_test_runtime_flags_.dump_title_changes(); 1874 return layout_test_runtime_flags_.dump_title_changes();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 } 1966 }
1975 1967
1976 bool TestRunner::shouldInterceptPostMessage() const { 1968 bool TestRunner::shouldInterceptPostMessage() const {
1977 return layout_test_runtime_flags_.intercept_post_message(); 1969 return layout_test_runtime_flags_.intercept_post_message();
1978 } 1970 }
1979 1971
1980 bool TestRunner::shouldDumpResourcePriorities() const { 1972 bool TestRunner::shouldDumpResourcePriorities() const {
1981 return layout_test_runtime_flags_.dump_resource_priorities(); 1973 return layout_test_runtime_flags_.dump_resource_priorities();
1982 } 1974 }
1983 1975
1984 bool TestRunner::RequestPointerLock() { 1976 bool TestRunnerForSpecificView::RequestPointerLock() {
1985 switch (pointer_lock_planned_result_) { 1977 switch (pointer_lock_planned_result_) {
1986 case PointerLockWillSucceed: 1978 case PointerLockWillSucceed:
1987 PostDelayedTask(0, base::Bind(&TestRunner::DidAcquirePointerLockInternal, 1979 PostDelayedTask(
1988 weak_factory_.GetWeakPtr())); 1980 0,
1981 base::Bind(&TestRunnerForSpecificView::DidAcquirePointerLockInternal,
1982 weak_factory_.GetWeakPtr()));
1989 return true; 1983 return true;
1990 case PointerLockWillRespondAsync: 1984 case PointerLockWillRespondAsync:
1991 DCHECK(!pointer_locked_); 1985 DCHECK(!pointer_locked_);
1992 return true; 1986 return true;
1993 case PointerLockWillFailSync: 1987 case PointerLockWillFailSync:
1994 DCHECK(!pointer_locked_); 1988 DCHECK(!pointer_locked_);
1995 return false; 1989 return false;
1996 default: 1990 default:
1997 NOTREACHED(); 1991 NOTREACHED();
1998 return false; 1992 return false;
1999 } 1993 }
2000 } 1994 }
2001 1995
2002 void TestRunner::RequestPointerUnlock() { 1996 void TestRunnerForSpecificView::RequestPointerUnlock() {
2003 PostDelayedTask(0, base::Bind(&TestRunner::DidLosePointerLockInternal, 1997 PostDelayedTask(
2004 weak_factory_.GetWeakPtr())); 1998 0, base::Bind(&TestRunnerForSpecificView::DidLosePointerLockInternal,
1999 weak_factory_.GetWeakPtr()));
2005 } 2000 }
2006 2001
2007 bool TestRunner::isPointerLocked() { 2002 bool TestRunnerForSpecificView::isPointerLocked() {
2008 return pointer_locked_; 2003 return pointer_locked_;
2009 } 2004 }
2010 2005
2011 void TestRunner::setToolTipText(const WebString& text) { 2006 void TestRunner::setToolTipText(const WebString& text) {
2012 tooltip_text_ = text.utf8(); 2007 tooltip_text_ = text.utf8();
2013 } 2008 }
2014 2009
2015 void TestRunner::setDragImage( 2010 void TestRunner::setDragImage(
2016 const blink::WebImage& drag_image) { 2011 const blink::WebImage& drag_image) {
2017 if (layout_test_runtime_flags_.dump_drag_image()) { 2012 if (layout_test_runtime_flags_.dump_drag_image()) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2163
2169 void TestRunner::SetCloseRemainingWindowsWhenComplete( 2164 void TestRunner::SetCloseRemainingWindowsWhenComplete(
2170 bool close_remaining_windows) { 2165 bool close_remaining_windows) {
2171 close_remaining_windows_ = close_remaining_windows; 2166 close_remaining_windows_ = close_remaining_windows;
2172 } 2167 }
2173 2168
2174 void TestRunner::ResetTestHelperControllers() { 2169 void TestRunner::ResetTestHelperControllers() {
2175 test_interfaces_->ResetTestHelperControllers(); 2170 test_interfaces_->ResetTestHelperControllers();
2176 } 2171 }
2177 2172
2178 void TestRunner::SetTabKeyCyclesThroughElements( 2173 void TestRunnerForSpecificView::SetTabKeyCyclesThroughElements(
2179 bool tab_key_cycles_through_elements) { 2174 bool tab_key_cycles_through_elements) {
2180 web_view_->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements); 2175 web_view()->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements);
2181 } 2176 }
2182 2177
2183 void TestRunner::ExecCommand(gin::Arguments* args) { 2178 void TestRunnerForSpecificView::ExecCommand(gin::Arguments* args) {
2184 std::string command; 2179 std::string command;
2185 args->GetNext(&command); 2180 args->GetNext(&command);
2186 2181
2187 std::string value; 2182 std::string value;
2188 if (args->Length() >= 3) { 2183 if (args->Length() >= 3) {
2189 // Ignore the second parameter (which is userInterface) 2184 // Ignore the second parameter (which is userInterface)
2190 // since this command emulates a manual action. 2185 // since this command emulates a manual action.
2191 args->Skip(); 2186 args->Skip();
2192 args->GetNext(&value); 2187 args->GetNext(&value);
2193 } 2188 }
2194 2189
2195 // Note: webkit's version does not return the boolean, so neither do we. 2190 // Note: webkit's version does not return the boolean, so neither do we.
2196 web_view_->focusedFrame()->executeCommand(WebString::fromUTF8(command), 2191 web_view()->focusedFrame()->executeCommand(WebString::fromUTF8(command),
2197 WebString::fromUTF8(value)); 2192 WebString::fromUTF8(value));
2198 } 2193 }
2199 2194
2200 bool TestRunner::IsCommandEnabled(const std::string& command) { 2195 bool TestRunnerForSpecificView::IsCommandEnabled(const std::string& command) {
2201 return web_view_->focusedFrame()->isCommandEnabled( 2196 return web_view()->focusedFrame()->isCommandEnabled(
2202 WebString::fromUTF8(command)); 2197 WebString::fromUTF8(command));
2203 } 2198 }
2204 2199
2205 bool TestRunner::CallShouldCloseOnWebView() { 2200 bool TestRunnerForSpecificView::CallShouldCloseOnWebView() {
2206 return web_view_->mainFrame()->dispatchBeforeUnloadEvent(); 2201 return web_view()->mainFrame()->dispatchBeforeUnloadEvent();
2207 } 2202 }
2208 2203
2209 void TestRunner::SetDomainRelaxationForbiddenForURLScheme( 2204 void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme(
2210 bool forbidden, const std::string& scheme) { 2205 bool forbidden,
2211 web_view_->setDomainRelaxationForbidden(forbidden, 2206 const std::string& scheme) {
2212 WebString::fromUTF8(scheme)); 2207 web_view()->setDomainRelaxationForbidden(forbidden,
2208 WebString::fromUTF8(scheme));
2213 } 2209 }
2214 2210
2215 v8::Local<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue( 2211 v8::Local<v8::Value>
2212 TestRunnerForSpecificView::EvaluateScriptInIsolatedWorldAndReturnValue(
2216 int world_id, 2213 int world_id,
2217 const std::string& script) { 2214 const std::string& script) {
2218 WebVector<v8::Local<v8::Value>> values; 2215 WebVector<v8::Local<v8::Value>> values;
2219 WebScriptSource source(WebString::fromUTF8(script)); 2216 WebScriptSource source(WebString::fromUTF8(script));
2220 // This relies on the iframe focusing itself when it loads. This is a bit 2217 // This relies on the iframe focusing itself when it loads. This is a bit
2221 // sketchy, but it seems to be what other tests do. 2218 // sketchy, but it seems to be what other tests do.
2222 web_view_->focusedFrame()->executeScriptInIsolatedWorld( 2219 web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
2223 world_id, &source, 1, 1, &values); 2220 1, &values);
2224 // Since only one script was added, only one result is expected 2221 // Since only one script was added, only one result is expected
2225 if (values.size() == 1 && !values[0].IsEmpty()) 2222 if (values.size() == 1 && !values[0].IsEmpty())
2226 return values[0]; 2223 return values[0];
2227 return v8::Local<v8::Value>(); 2224 return v8::Local<v8::Value>();
2228 } 2225 }
2229 2226
2230 void TestRunner::EvaluateScriptInIsolatedWorld(int world_id, 2227 void TestRunnerForSpecificView::EvaluateScriptInIsolatedWorld(
2231 const std::string& script) { 2228 int world_id,
2229 const std::string& script) {
2232 WebScriptSource source(WebString::fromUTF8(script)); 2230 WebScriptSource source(WebString::fromUTF8(script));
2233 web_view_->focusedFrame()->executeScriptInIsolatedWorld( 2231 web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
2234 world_id, &source, 1, 1); 2232 1);
2235 } 2233 }
2236 2234
2237 void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id, 2235 void TestRunnerForSpecificView::SetIsolatedWorldSecurityOrigin(
2238 v8::Local<v8::Value> origin) { 2236 int world_id,
2237 v8::Local<v8::Value> origin) {
2239 if (!(origin->IsString() || !origin->IsNull())) 2238 if (!(origin->IsString() || !origin->IsNull()))
2240 return; 2239 return;
2241 2240
2242 WebSecurityOrigin web_origin; 2241 WebSecurityOrigin web_origin;
2243 if (origin->IsString()) { 2242 if (origin->IsString()) {
2244 web_origin = WebSecurityOrigin::createFromString( 2243 web_origin = WebSecurityOrigin::createFromString(
2245 V8StringToWebString(origin.As<v8::String>())); 2244 V8StringToWebString(origin.As<v8::String>()));
2246 } 2245 }
2247 web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id, 2246 web_view()->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id,
2248 web_origin); 2247 web_origin);
2249 } 2248 }
2250 2249
2251 void TestRunner::SetIsolatedWorldContentSecurityPolicy( 2250 void TestRunnerForSpecificView::SetIsolatedWorldContentSecurityPolicy(
2252 int world_id, 2251 int world_id,
2253 const std::string& policy) { 2252 const std::string& policy) {
2254 web_view_->focusedFrame()->setIsolatedWorldContentSecurityPolicy( 2253 web_view()->focusedFrame()->setIsolatedWorldContentSecurityPolicy(
2255 world_id, WebString::fromUTF8(policy)); 2254 world_id, WebString::fromUTF8(policy));
2256 } 2255 }
2257 2256
2258 void TestRunner::AddOriginAccessWhitelistEntry( 2257 void TestRunner::AddOriginAccessWhitelistEntry(
2259 const std::string& source_origin, 2258 const std::string& source_origin,
2260 const std::string& destination_protocol, 2259 const std::string& destination_protocol,
2261 const std::string& destination_host, 2260 const std::string& destination_host,
2262 bool allow_destination_subdomains) { 2261 bool allow_destination_subdomains) {
2263 WebURL url((GURL(source_origin))); 2262 WebURL url((GURL(source_origin)));
2264 if (!url.isValid()) 2263 if (!url.isValid())
(...skipping 15 matching lines...) Expand all
2280 if (!url.isValid()) 2279 if (!url.isValid())
2281 return; 2280 return;
2282 2281
2283 WebSecurityPolicy::removeOriginAccessWhitelistEntry( 2282 WebSecurityPolicy::removeOriginAccessWhitelistEntry(
2284 url, 2283 url,
2285 WebString::fromUTF8(destination_protocol), 2284 WebString::fromUTF8(destination_protocol),
2286 WebString::fromUTF8(destination_host), 2285 WebString::fromUTF8(destination_host),
2287 allow_destination_subdomains); 2286 allow_destination_subdomains);
2288 } 2287 }
2289 2288
2290 bool TestRunner::HasCustomPageSizeStyle(int page_index) { 2289 bool TestRunnerForSpecificView::HasCustomPageSizeStyle(int page_index) {
2291 WebFrame* frame = web_view_->mainFrame(); 2290 WebFrame* frame = web_view()->mainFrame();
2292 if (!frame) 2291 if (!frame)
2293 return false; 2292 return false;
2294 return frame->hasCustomPageSizeStyle(page_index); 2293 return frame->hasCustomPageSizeStyle(page_index);
2295 } 2294 }
2296 2295
2297 void TestRunner::ForceRedSelectionColors() { 2296 void TestRunnerForSpecificView::ForceRedSelectionColors() {
2298 web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0); 2297 web_view()->setSelectionColors(
2298 0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0);
2299 } 2299 }
2300 2300
2301 void TestRunner::InsertStyleSheet(const std::string& source_code) { 2301 void TestRunner::InsertStyleSheet(const std::string& source_code) {
2302 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet( 2302 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet(
2303 WebString::fromUTF8(source_code)); 2303 WebString::fromUTF8(source_code));
2304 } 2304 }
2305 2305
2306 bool TestRunner::FindString(const std::string& search_text, 2306 bool TestRunnerForSpecificView::FindString(
2307 const std::vector<std::string>& options_array) { 2307 const std::string& search_text,
2308 const std::vector<std::string>& options_array) {
2308 WebFindOptions find_options; 2309 WebFindOptions find_options;
2309 bool wrap_around = false; 2310 bool wrap_around = false;
2310 find_options.matchCase = true; 2311 find_options.matchCase = true;
2311 find_options.findNext = true; 2312 find_options.findNext = true;
2312 2313
2313 for (const std::string& option : options_array) { 2314 for (const std::string& option : options_array) {
2314 if (option == "CaseInsensitive") 2315 if (option == "CaseInsensitive")
2315 find_options.matchCase = false; 2316 find_options.matchCase = false;
2316 else if (option == "Backwards") 2317 else if (option == "Backwards")
2317 find_options.forward = false; 2318 find_options.forward = false;
2318 else if (option == "StartInSelection") 2319 else if (option == "StartInSelection")
2319 find_options.findNext = false; 2320 find_options.findNext = false;
2320 else if (option == "AtWordStarts") 2321 else if (option == "AtWordStarts")
2321 find_options.wordStart = true; 2322 find_options.wordStart = true;
2322 else if (option == "TreatMedialCapitalAsWordStart") 2323 else if (option == "TreatMedialCapitalAsWordStart")
2323 find_options.medialCapitalAsWordStart = true; 2324 find_options.medialCapitalAsWordStart = true;
2324 else if (option == "WrapAround") 2325 else if (option == "WrapAround")
2325 wrap_around = true; 2326 wrap_around = true;
2326 } 2327 }
2327 2328
2328 WebLocalFrame* frame = web_view_->mainFrame()->toWebLocalFrame(); 2329 WebLocalFrame* frame = web_view()->mainFrame()->toWebLocalFrame();
2329 const bool find_result = frame->find(0, WebString::fromUTF8(search_text), 2330 const bool find_result = frame->find(0, WebString::fromUTF8(search_text),
2330 find_options, wrap_around, 0); 2331 find_options, wrap_around, 0);
2331 frame->stopFinding(false); 2332 frame->stopFinding(false);
2332 return find_result; 2333 return find_result;
2333 } 2334 }
2334 2335
2335 std::string TestRunner::SelectionAsMarkup() { 2336 std::string TestRunnerForSpecificView::SelectionAsMarkup() {
2336 return web_view_->mainFrame()->selectionAsMarkup().utf8(); 2337 return web_view()->mainFrame()->selectionAsMarkup().utf8();
2337 } 2338 }
2338 2339
2339 void TestRunner::SetTextSubpixelPositioning(bool value) { 2340 void TestRunner::SetTextSubpixelPositioning(bool value) {
2340 #if defined(__linux__) || defined(ANDROID) 2341 #if defined(__linux__) || defined(ANDROID)
2341 // Since FontConfig doesn't provide a variable to control subpixel 2342 // Since FontConfig doesn't provide a variable to control subpixel
2342 // positioning, we'll fall back to setting it globally for all fonts. 2343 // positioning, we'll fall back to setting it globally for all fonts.
2343 WebFontRendering::setSubpixelPositioning(value); 2344 WebFontRendering::setSubpixelPositioning(value);
2344 #endif 2345 #endif
2345 } 2346 }
2346 2347
2347 void TestRunner::SetPageVisibility(const std::string& new_visibility) { 2348 void TestRunnerForSpecificView::SetPageVisibility(
2349 const std::string& new_visibility) {
2348 if (new_visibility == "visible") 2350 if (new_visibility == "visible")
2349 web_view_->setVisibilityState(WebPageVisibilityStateVisible, false); 2351 web_view()->setVisibilityState(WebPageVisibilityStateVisible, false);
2350 else if (new_visibility == "hidden") 2352 else if (new_visibility == "hidden")
2351 web_view_->setVisibilityState(WebPageVisibilityStateHidden, false); 2353 web_view()->setVisibilityState(WebPageVisibilityStateHidden, false);
2352 else if (new_visibility == "prerender") 2354 else if (new_visibility == "prerender")
2353 web_view_->setVisibilityState(WebPageVisibilityStatePrerender, false); 2355 web_view()->setVisibilityState(WebPageVisibilityStatePrerender, false);
2354 } 2356 }
2355 2357
2356 void TestRunner::SetTextDirection(const std::string& direction_name) { 2358 void TestRunnerForSpecificView::SetTextDirection(
2359 const std::string& direction_name) {
2357 // Map a direction name to a WebTextDirection value. 2360 // Map a direction name to a WebTextDirection value.
2358 WebTextDirection direction; 2361 WebTextDirection direction;
2359 if (direction_name == "auto") 2362 if (direction_name == "auto")
2360 direction = WebTextDirectionDefault; 2363 direction = WebTextDirectionDefault;
2361 else if (direction_name == "rtl") 2364 else if (direction_name == "rtl")
2362 direction = WebTextDirectionRightToLeft; 2365 direction = WebTextDirectionRightToLeft;
2363 else if (direction_name == "ltr") 2366 else if (direction_name == "ltr")
2364 direction = WebTextDirectionLeftToRight; 2367 direction = WebTextDirectionLeftToRight;
2365 else 2368 else
2366 return; 2369 return;
2367 2370
2368 web_view_->setTextDirection(direction); 2371 web_view()->setTextDirection(direction);
2369 } 2372 }
2370 2373
2371 void TestRunner::UseUnfortunateSynchronousResizeMode() { 2374 void TestRunner::UseUnfortunateSynchronousResizeMode() {
2372 delegate_->UseUnfortunateSynchronousResizeMode(true); 2375 delegate_->UseUnfortunateSynchronousResizeMode(true);
2373 } 2376 }
2374 2377
2375 bool TestRunner::EnableAutoResizeMode(int min_width, 2378 bool TestRunner::EnableAutoResizeMode(int min_width,
2376 int min_height, 2379 int min_height,
2377 int max_width, 2380 int max_width,
2378 int max_height) { 2381 int max_height) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 orientation = WebScreenOrientationPortraitPrimary; 2497 orientation = WebScreenOrientationPortraitPrimary;
2495 } else if (orientation_str == "portrait-secondary") { 2498 } else if (orientation_str == "portrait-secondary") {
2496 orientation = WebScreenOrientationPortraitSecondary; 2499 orientation = WebScreenOrientationPortraitSecondary;
2497 } else if (orientation_str == "landscape-primary") { 2500 } else if (orientation_str == "landscape-primary") {
2498 orientation = WebScreenOrientationLandscapePrimary; 2501 orientation = WebScreenOrientationLandscapePrimary;
2499 } else { 2502 } else {
2500 DCHECK_EQ("landscape-secondary", orientation_str); 2503 DCHECK_EQ("landscape-secondary", orientation_str);
2501 orientation = WebScreenOrientationLandscapeSecondary; 2504 orientation = WebScreenOrientationLandscapeSecondary;
2502 } 2505 }
2503 2506
2504 // TODO(lukasza): This is broken for OOPIFs. 2507 for (WebTestProxyBase* window : test_interfaces_->GetWindowList()) {
2505 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); 2508 WebFrame* main_frame = window->web_view()->mainFrame();
2506 mock_screen_orientation_client_->UpdateDeviceOrientation( 2509 // TODO(lukasza): Need to make this work for remote frames.
2507 main_frame, orientation); 2510 if (main_frame->isWebLocalFrame()) {
2511 mock_screen_orientation_client_->UpdateDeviceOrientation(
2512 main_frame->toWebLocalFrame(), orientation);
2513 }
2514 }
2508 } 2515 }
2509 2516
2510 void TestRunner::DisableMockScreenOrientation() { 2517 void TestRunner::DisableMockScreenOrientation() {
2511 mock_screen_orientation_client_->SetDisabled(true); 2518 mock_screen_orientation_client_->SetDisabled(true);
2512 } 2519 }
2513 2520
2514 void TestRunner::DidOpenChooser() { 2521 void TestRunner::DidOpenChooser() {
2515 chooser_count_++; 2522 chooser_count_++;
2516 } 2523 }
2517 2524
2518 void TestRunner::DidCloseChooser() { 2525 void TestRunner::DidCloseChooser() {
2519 chooser_count_--; 2526 chooser_count_--;
2520 DCHECK_LE(0, chooser_count_); 2527 DCHECK_LE(0, chooser_count_);
2521 } 2528 }
2522 2529
2523 void TestRunner::DidAcquirePointerLock() { 2530 void TestRunnerForSpecificView::DidAcquirePointerLock() {
2524 DidAcquirePointerLockInternal(); 2531 DidAcquirePointerLockInternal();
2525 } 2532 }
2526 2533
2527 void TestRunner::DidNotAcquirePointerLock() { 2534 void TestRunnerForSpecificView::DidNotAcquirePointerLock() {
2528 DidNotAcquirePointerLockInternal(); 2535 DidNotAcquirePointerLockInternal();
2529 } 2536 }
2530 2537
2531 void TestRunner::DidLosePointerLock() { 2538 void TestRunnerForSpecificView::DidLosePointerLock() {
2532 DidLosePointerLockInternal(); 2539 DidLosePointerLockInternal();
2533 } 2540 }
2534 2541
2535 void TestRunner::SetPointerLockWillFailSynchronously() { 2542 void TestRunnerForSpecificView::SetPointerLockWillFailSynchronously() {
2536 pointer_lock_planned_result_ = PointerLockWillFailSync; 2543 pointer_lock_planned_result_ = PointerLockWillFailSync;
2537 } 2544 }
2538 2545
2539 void TestRunner::SetPointerLockWillRespondAsynchronously() { 2546 void TestRunnerForSpecificView::SetPointerLockWillRespondAsynchronously() {
2540 pointer_lock_planned_result_ = PointerLockWillRespondAsync; 2547 pointer_lock_planned_result_ = PointerLockWillRespondAsync;
2541 } 2548 }
2542 2549
2543 void TestRunner::SetPopupBlockingEnabled(bool block_popups) { 2550 void TestRunner::SetPopupBlockingEnabled(bool block_popups) {
2544 delegate_->Preferences()->java_script_can_open_windows_automatically = 2551 delegate_->Preferences()->java_script_can_open_windows_automatically =
2545 !block_popups; 2552 !block_popups;
2546 delegate_->ApplyPreferences(); 2553 delegate_->ApplyPreferences();
2547 } 2554 }
2548 2555
2549 void TestRunner::SetJavaScriptCanAccessClipboard(bool can_access) { 2556 void TestRunner::SetJavaScriptCanAccessClipboard(bool can_access) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 std::string TestRunner::GetAcceptLanguages() const { 2627 std::string TestRunner::GetAcceptLanguages() const {
2621 return layout_test_runtime_flags_.accept_languages(); 2628 return layout_test_runtime_flags_.accept_languages();
2622 } 2629 }
2623 2630
2624 void TestRunner::SetAcceptLanguages(const std::string& accept_languages) { 2631 void TestRunner::SetAcceptLanguages(const std::string& accept_languages) {
2625 if (accept_languages == GetAcceptLanguages()) 2632 if (accept_languages == GetAcceptLanguages())
2626 return; 2633 return;
2627 2634
2628 layout_test_runtime_flags_.set_accept_languages(accept_languages); 2635 layout_test_runtime_flags_.set_accept_languages(accept_languages);
2629 OnLayoutTestRuntimeFlagsChanged(); 2636 OnLayoutTestRuntimeFlagsChanged();
2630 web_view_->acceptLanguagesChanged(); 2637
2638 for (WebTestProxyBase* window : test_interfaces_->GetWindowList())
2639 window->web_view()->acceptLanguagesChanged();
2631 } 2640 }
2632 2641
2633 void TestRunner::SetPluginsEnabled(bool enabled) { 2642 void TestRunner::SetPluginsEnabled(bool enabled) {
2634 delegate_->Preferences()->plugins_enabled = enabled; 2643 delegate_->Preferences()->plugins_enabled = enabled;
2635 delegate_->ApplyPreferences(); 2644 delegate_->ApplyPreferences();
2636 } 2645 }
2637 2646
2638 bool TestRunner::GetAnimationScheduled() const { 2647 bool TestRunner::GetAnimationScheduled() const {
2639 bool is_animation_scheduled = !views_with_scheduled_animations_.empty(); 2648 bool is_animation_scheduled = !views_with_scheduled_animations_.empty();
2640 return is_animation_scheduled; 2649 return is_animation_scheduled;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 layout_test_runtime_flags_.set_dump_drag_image(true); 2849 layout_test_runtime_flags_.set_dump_drag_image(true);
2841 DumpAsTextWithPixelResults(); 2850 DumpAsTextWithPixelResults();
2842 OnLayoutTestRuntimeFlagsChanged(); 2851 OnLayoutTestRuntimeFlagsChanged();
2843 } 2852 }
2844 2853
2845 void TestRunner::DumpNavigationPolicy() { 2854 void TestRunner::DumpNavigationPolicy() {
2846 layout_test_runtime_flags_.set_dump_navigation_policy(true); 2855 layout_test_runtime_flags_.set_dump_navigation_policy(true);
2847 OnLayoutTestRuntimeFlagsChanged(); 2856 OnLayoutTestRuntimeFlagsChanged();
2848 } 2857 }
2849 2858
2850 void TestRunner::DumpPageImportanceSignals() { 2859 void TestRunnerForSpecificView::DumpPageImportanceSignals() {
2851 blink::WebPageImportanceSignals* signals = 2860 blink::WebPageImportanceSignals* signals =
2852 web_view_->pageImportanceSignals(); 2861 web_view()->pageImportanceSignals();
2853 if (!signals) 2862 if (!signals)
2854 return; 2863 return;
2855 2864
2856 std::string message = base::StringPrintf( 2865 std::string message = base::StringPrintf(
2857 "WebPageImportanceSignals:\n" 2866 "WebPageImportanceSignals:\n"
2858 " hadFormInteraction: %s\n" 2867 " hadFormInteraction: %s\n"
2859 " issuedNonGetFetchFromScript: %s\n", 2868 " issuedNonGetFetchFromScript: %s\n",
2860 signals->hadFormInteraction() ? "true" : "false", 2869 signals->hadFormInteraction() ? "true" : "false",
2861 signals->issuedNonGetFetchFromScript() ? "true" : "false"); 2870 signals->issuedNonGetFetchFromScript() ? "true" : "false");
2862 if (delegate_) 2871 if (delegate())
2863 delegate_->PrintMessage(message); 2872 delegate()->PrintMessage(message);
2864 } 2873 }
2865 2874
2866 void TestRunner::CloseWebInspector() { 2875 void TestRunner::CloseWebInspector() {
2867 delegate_->CloseDevTools(); 2876 delegate_->CloseDevTools();
2868 } 2877 }
2869 2878
2870 bool TestRunner::IsChooserShown() { 2879 bool TestRunner::IsChooserShown() {
2871 return 0 < chooser_count_; 2880 return 0 < chooser_count_;
2872 } 2881 }
2873 2882
(...skipping 12 matching lines...) Expand all
2886 } 2895 }
2887 2896
2888 void TestRunner::SetDatabaseQuota(int quota) { 2897 void TestRunner::SetDatabaseQuota(int quota) {
2889 delegate_->SetDatabaseQuota(quota); 2898 delegate_->SetDatabaseQuota(quota);
2890 } 2899 }
2891 2900
2892 void TestRunner::SetAlwaysAcceptCookies(bool accept) { 2901 void TestRunner::SetAlwaysAcceptCookies(bool accept) {
2893 delegate_->SetAcceptAllCookies(accept); 2902 delegate_->SetAcceptAllCookies(accept);
2894 } 2903 }
2895 2904
2896 void TestRunner::SetWindowIsKey(bool value) { 2905 void TestRunnerForSpecificView::SetWindowIsKey(bool value) {
2897 SetFocus(web_view_, value); 2906 web_test_proxy_base_->test_interfaces()->GetTestRunner()->SetFocus(web_view(),
2907 value);
2898 } 2908 }
2899 2909
2900 void TestRunner::SetFocus(blink::WebView* web_view, bool focus) { 2910 void TestRunner::SetFocus(blink::WebView* web_view, bool focus) {
2901 if (focus) { 2911 if (focus) {
2902 if (previously_focused_view_ != web_view) { 2912 if (previously_focused_view_ != web_view) {
2903 delegate_->SetFocus(previously_focused_view_, false); 2913 delegate_->SetFocus(previously_focused_view_, false);
2904 delegate_->SetFocus(web_view, true); 2914 delegate_->SetFocus(web_view, true);
2905 previously_focused_view_ = web_view; 2915 previously_focused_view_ = web_view;
2906 } 2916 }
2907 } else { 2917 } else {
2908 if (previously_focused_view_ == web_view) { 2918 if (previously_focused_view_ == web_view) {
2909 delegate_->SetFocus(web_view, false); 2919 delegate_->SetFocus(web_view, false);
2910 previously_focused_view_ = nullptr; 2920 previously_focused_view_ = nullptr;
2911 } 2921 }
2912 } 2922 }
2913 } 2923 }
2914 2924
2915 std::string TestRunner::PathToLocalResource(const std::string& path) { 2925 std::string TestRunner::PathToLocalResource(const std::string& path) {
2916 return delegate_->PathToLocalResource(path); 2926 return delegate_->PathToLocalResource(path);
2917 } 2927 }
2918 2928
2919 void TestRunner::SetBackingScaleFactor(double value, 2929 void TestRunnerForSpecificView::SetBackingScaleFactor(
2920 v8::Local<v8::Function> callback) { 2930 double value,
2921 delegate_->SetDeviceScaleFactor(value); 2931 v8::Local<v8::Function> callback) {
2932 delegate()->SetDeviceScaleFactor(value);
2922 PostV8Callback(callback); 2933 PostV8Callback(callback);
2923 } 2934 }
2924 2935
2925 void TestRunner::EnableUseZoomForDSF(v8::Local<v8::Function> callback) { 2936 void TestRunnerForSpecificView::EnableUseZoomForDSF(
2926 delegate_->EnableUseZoomForDSF(); 2937 v8::Local<v8::Function> callback) {
2938 delegate()->EnableUseZoomForDSF();
2927 PostV8Callback(callback); 2939 PostV8Callback(callback);
2928 } 2940 }
2929 2941
2930 void TestRunner::SetColorProfile(const std::string& name, 2942 void TestRunnerForSpecificView::SetColorProfile(
2931 v8::Local<v8::Function> callback) { 2943 const std::string& name,
2932 delegate_->SetDeviceColorProfile(name); 2944 v8::Local<v8::Function> callback) {
2945 delegate()->SetDeviceColorProfile(name);
2933 PostV8Callback(callback); 2946 PostV8Callback(callback);
2934 } 2947 }
2935 2948
2936 void TestRunner::SetBluetoothFakeAdapter(const std::string& adapter_name, 2949 void TestRunnerForSpecificView::SetBluetoothFakeAdapter(
2937 v8::Local<v8::Function> callback) { 2950 const std::string& adapter_name,
2938 delegate_->SetBluetoothFakeAdapter( 2951 v8::Local<v8::Function> callback) {
2952 delegate()->SetBluetoothFakeAdapter(
2939 adapter_name, CreateClosureThatPostsV8Callback(callback)); 2953 adapter_name, CreateClosureThatPostsV8Callback(callback));
2940 } 2954 }
2941 2955
2942 void TestRunner::SetBluetoothManualChooser(bool enable) { 2956 void TestRunnerForSpecificView::SetBluetoothManualChooser(bool enable) {
2943 delegate_->SetBluetoothManualChooser(enable); 2957 delegate()->SetBluetoothManualChooser(enable);
2944 } 2958 }
2945 2959
2946 void TestRunner::GetBluetoothManualChooserEvents( 2960 void TestRunnerForSpecificView::GetBluetoothManualChooserEvents(
2947 v8::Local<v8::Function> callback) { 2961 v8::Local<v8::Function> callback) {
2948 return delegate_->GetBluetoothManualChooserEvents( 2962 return delegate()->GetBluetoothManualChooserEvents(base::Bind(
2949 base::Bind(&TestRunner::GetBluetoothManualChooserEventsCallback, 2963 &TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback,
2950 weak_factory_.GetWeakPtr(), 2964 weak_factory_.GetWeakPtr(),
2951 base::Passed(v8::UniquePersistent<v8::Function>( 2965 base::Passed(v8::UniquePersistent<v8::Function>(
2952 blink::mainThreadIsolate(), callback)))); 2966 blink::mainThreadIsolate(), callback))));
2953 } 2967 }
2954 2968
2955 void TestRunner::SendBluetoothManualChooserEvent(const std::string& event, 2969 void TestRunnerForSpecificView::SendBluetoothManualChooserEvent(
2956 const std::string& argument) { 2970 const std::string& event,
2957 delegate_->SendBluetoothManualChooserEvent(event, argument); 2971 const std::string& argument) {
2972 delegate()->SendBluetoothManualChooserEvent(event, argument);
2958 } 2973 }
2959 2974
2960 void TestRunner::SetGeofencingMockProvider(bool service_available) { 2975 void TestRunner::SetGeofencingMockProvider(bool service_available) {
2961 delegate_->SetGeofencingMockProvider(service_available); 2976 delegate_->SetGeofencingMockProvider(service_available);
2962 } 2977 }
2963 2978
2964 void TestRunner::ClearGeofencingMockProvider() { 2979 void TestRunner::ClearGeofencingMockProvider() {
2965 delegate_->ClearGeofencingMockProvider(); 2980 delegate_->ClearGeofencingMockProvider();
2966 } 2981 }
2967 2982
2968 void TestRunner::SetGeofencingMockPosition(double latitude, double longitude) { 2983 void TestRunner::SetGeofencingMockPosition(double latitude, double longitude) {
2969 delegate_->SetGeofencingMockPosition(latitude, longitude); 2984 delegate_->SetGeofencingMockPosition(latitude, longitude);
2970 } 2985 }
2971 2986
2972 void TestRunner::SetPermission(const std::string& name, 2987 void TestRunner::SetPermission(const std::string& name,
2973 const std::string& value, 2988 const std::string& value,
2974 const GURL& origin, 2989 const GURL& origin,
2975 const GURL& embedding_origin) { 2990 const GURL& embedding_origin) {
2976 delegate_->SetPermission(name, value, origin, embedding_origin); 2991 delegate_->SetPermission(name, value, origin, embedding_origin);
2977 } 2992 }
2978 2993
2979 void TestRunner::DispatchBeforeInstallPromptEvent( 2994 void TestRunnerForSpecificView::DispatchBeforeInstallPromptEvent(
2980 int request_id, 2995 int request_id,
2981 const std::vector<std::string>& event_platforms, 2996 const std::vector<std::string>& event_platforms,
2982 v8::Local<v8::Function> callback) { 2997 v8::Local<v8::Function> callback) {
2983 delegate_->DispatchBeforeInstallPromptEvent( 2998 delegate()->DispatchBeforeInstallPromptEvent(
2984 request_id, event_platforms, 2999 request_id, event_platforms,
2985 base::Bind(&TestRunner::DispatchBeforeInstallPromptCallback, 3000 base::Bind(
2986 weak_factory_.GetWeakPtr(), 3001 &TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback,
2987 base::Passed(v8::UniquePersistent<v8::Function>( 3002 weak_factory_.GetWeakPtr(),
2988 blink::mainThreadIsolate(), callback)))); 3003 base::Passed(v8::UniquePersistent<v8::Function>(
3004 blink::mainThreadIsolate(), callback))));
2989 } 3005 }
2990 3006
2991 void TestRunner::ResolveBeforeInstallPromptPromise( 3007 void TestRunner::ResolveBeforeInstallPromptPromise(
2992 int request_id, 3008 int request_id,
2993 const std::string& platform) { 3009 const std::string& platform) {
2994 if (!test_interfaces_->GetAppBannerClient()) 3010 if (!test_interfaces_->GetAppBannerClient())
2995 return; 3011 return;
2996 test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform); 3012 test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform);
2997 } 3013 }
2998 3014
2999 void TestRunner::RunIdleTasks(v8::Local<v8::Function> callback) { 3015 void TestRunnerForSpecificView::RunIdleTasks(v8::Local<v8::Function> callback) {
3000 delegate_->RunIdleTasks( 3016 delegate()->RunIdleTasks(CreateClosureThatPostsV8Callback(callback));
3001 CreateClosureThatPostsV8Callback(callback));
3002 } 3017 }
3003 3018
3004 void TestRunner::SetPOSIXLocale(const std::string& locale) { 3019 void TestRunner::SetPOSIXLocale(const std::string& locale) {
3005 delegate_->SetLocale(locale); 3020 delegate_->SetLocale(locale);
3006 } 3021 }
3007 3022
3008 void TestRunner::SetMIDIAccessorResult(bool result) { 3023 void TestRunner::SetMIDIAccessorResult(bool result) {
3009 midi_accessor_result_ = result; 3024 midi_accessor_result_ = result;
3010 } 3025 }
3011 3026
(...skipping 25 matching lines...) Expand all
3037 const std::string& password) { 3052 const std::string& password) {
3038 credential_manager_client_->SetResponse(new WebPasswordCredential( 3053 credential_manager_client_->SetResponse(new WebPasswordCredential(
3039 WebString::fromUTF8(id), WebString::fromUTF8(password), 3054 WebString::fromUTF8(id), WebString::fromUTF8(password),
3040 WebString::fromUTF8(name), WebURL(GURL(avatar)))); 3055 WebString::fromUTF8(name), WebURL(GURL(avatar))));
3041 } 3056 }
3042 3057
3043 void TestRunner::AddMockCredentialManagerError(const std::string& error) { 3058 void TestRunner::AddMockCredentialManagerError(const std::string& error) {
3044 credential_manager_client_->SetError(error); 3059 credential_manager_client_->SetError(error);
3045 } 3060 }
3046 3061
3047 void TestRunner::AddWebPageOverlay() { 3062 void TestRunnerForSpecificView::AddWebPageOverlay() {
3048 if (web_view_) 3063 web_view()->setPageOverlayColor(SK_ColorCYAN);
3049 web_view_->setPageOverlayColor(SK_ColorCYAN);
3050 } 3064 }
3051 3065
3052 void TestRunner::RemoveWebPageOverlay() { 3066 void TestRunnerForSpecificView::RemoveWebPageOverlay() {
3053 if (web_view_) 3067 web_view()->setPageOverlayColor(SK_ColorTRANSPARENT);
3054 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
3055 } 3068 }
3056 3069
3057 void TestRunner::LayoutAndPaintAsync() { 3070 void TestRunnerForSpecificView::LayoutAndPaintAsync() {
3058 test_runner::LayoutAndPaintAsyncThen(web_view_, base::Closure()); 3071 test_runner::LayoutAndPaintAsyncThen(web_view(), base::Closure());
3059 } 3072 }
3060 3073
3061 void TestRunner::LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback) { 3074 void TestRunnerForSpecificView::LayoutAndPaintAsyncThen(
3075 v8::Local<v8::Function> callback) {
3062 test_runner::LayoutAndPaintAsyncThen( 3076 test_runner::LayoutAndPaintAsyncThen(
3063 web_view_, CreateClosureThatPostsV8Callback(callback)); 3077 web_view(), CreateClosureThatPostsV8Callback(callback));
3064 } 3078 }
3065 3079
3066 void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) { 3080 void TestRunnerForSpecificView::GetManifestThen(
3081 v8::Local<v8::Function> callback) {
3067 v8::UniquePersistent<v8::Function> persistent_callback( 3082 v8::UniquePersistent<v8::Function> persistent_callback(
3068 blink::mainThreadIsolate(), callback); 3083 blink::mainThreadIsolate(), callback);
3069 3084
3070 if (!web_view_) { 3085 delegate()->FetchManifest(
3071 WebURLResponse response; 3086 web_view(), web_view()->mainFrame()->document().manifestURL(),
3072 response.setHTTPStatusCode(404); 3087 base::Bind(&TestRunnerForSpecificView::GetManifestCallback,
3073 GetManifestCallback(std::move(persistent_callback), response, ""); 3088 weak_factory_.GetWeakPtr(),
3074 return;
3075 }
3076
3077 delegate_->FetchManifest(
3078 web_view_, web_view_->mainFrame()->document().manifestURL(),
3079 base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(),
3080 base::Passed(std::move(persistent_callback)))); 3089 base::Passed(std::move(persistent_callback))));
3081 } 3090 }
3082 3091
3083 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { 3092 void TestRunnerForSpecificView::CapturePixelsAsyncThen(
3093 v8::Local<v8::Function> callback) {
3084 v8::UniquePersistent<v8::Function> persistent_callback( 3094 v8::UniquePersistent<v8::Function> persistent_callback(
3085 blink::mainThreadIsolate(), callback); 3095 blink::mainThreadIsolate(), callback);
3086 3096
3087 if (!web_view_) { 3097 web_test_proxy_base_->test_interfaces()->GetTestRunner()->DumpPixelsAsync(
3088 CapturePixelsCallback(std::move(persistent_callback), SkBitmap()); 3098 web_view(), base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
3089 return; 3099 weak_factory_.GetWeakPtr(),
3090 } 3100 base::Passed(std::move(persistent_callback))));
3091
3092 DumpPixelsAsync(
3093 web_view_,
3094 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(),
3095 base::Passed(std::move(persistent_callback))));
3096 } 3101 }
3097 3102
3098 void TestRunner::OnLayoutTestRuntimeFlagsChanged() { 3103 void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
3099 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty()) 3104 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty())
3100 return; 3105 return;
3101 3106
3102 delegate_->OnLayoutTestRuntimeFlagsChanged( 3107 delegate_->OnLayoutTestRuntimeFlagsChanged(
3103 layout_test_runtime_flags_.tracked_dictionary().changed_values()); 3108 layout_test_runtime_flags_.tracked_dictionary().changed_values());
3104 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking(); 3109 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking();
3105 } 3110 }
3106 3111
3107 void TestRunner::ForceNextWebGLContextCreationToFail() { 3112 void TestRunnerForSpecificView::ForceNextWebGLContextCreationToFail() {
3108 if (web_view_) 3113 web_view()->forceNextWebGLContextCreationToFail();
3109 web_view_->forceNextWebGLContextCreationToFail();
3110 } 3114 }
3111 3115
3112 void TestRunner::ForceNextDrawingBufferCreationToFail() { 3116 void TestRunnerForSpecificView::ForceNextDrawingBufferCreationToFail() {
3113 if (web_view_) 3117 web_view()->forceNextDrawingBufferCreationToFail();
3114 web_view_->forceNextDrawingBufferCreationToFail();
3115 } 3118 }
3116 3119
3117 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( 3120 void TestRunnerForSpecificView::CopyImageAtAndCapturePixelsAsyncThen(
3118 int x, int y, v8::Local<v8::Function> callback) { 3121 int x,
3122 int y,
3123 v8::Local<v8::Function> callback) {
3119 v8::UniquePersistent<v8::Function> persistent_callback( 3124 v8::UniquePersistent<v8::Function> persistent_callback(
3120 blink::mainThreadIsolate(), callback); 3125 blink::mainThreadIsolate(), callback);
3121 3126
3122 if (!web_view_) {
3123 CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
3124 return;
3125 }
3126
3127 CopyImageAtAndCapturePixels( 3127 CopyImageAtAndCapturePixels(
3128 web_view_, x, y, 3128 web_view(), x, y,
3129 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(), 3129 base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
3130 weak_factory_.GetWeakPtr(),
3130 base::Passed(std::move(persistent_callback)))); 3131 base::Passed(std::move(persistent_callback))));
3131 } 3132 }
3132 3133
3133 void TestRunner::GetManifestCallback( 3134 void TestRunnerForSpecificView::GetManifestCallback(
3134 v8::UniquePersistent<v8::Function> callback, 3135 v8::UniquePersistent<v8::Function> callback,
3135 const blink::WebURLResponse& response, 3136 const blink::WebURLResponse& response,
3136 const std::string& data) { 3137 const std::string& data) {
3137 PostV8CallbackWithArgs(std::move(callback), 0, nullptr); 3138 PostV8CallbackWithArgs(std::move(callback), 0, nullptr);
3138 } 3139 }
3139 3140
3140 void TestRunner::CapturePixelsCallback( 3141 void TestRunnerForSpecificView::CapturePixelsCallback(
3141 v8::UniquePersistent<v8::Function> callback, 3142 v8::UniquePersistent<v8::Function> callback,
3142 const SkBitmap& snapshot) { 3143 const SkBitmap& snapshot) {
3143 if (!web_view_)
3144 return;
3145
3146 v8::Isolate* isolate = blink::mainThreadIsolate(); 3144 v8::Isolate* isolate = blink::mainThreadIsolate();
3147 v8::HandleScope handle_scope(isolate); 3145 v8::HandleScope handle_scope(isolate);
3148 3146
3149 v8::Local<v8::Context> context = 3147 v8::Local<v8::Context> context =
3150 web_view_->mainFrame()->mainWorldScriptContext(); 3148 web_view()->mainFrame()->mainWorldScriptContext();
3151 if (context.IsEmpty()) 3149 if (context.IsEmpty())
3152 return; 3150 return;
3153 3151
3154 v8::Context::Scope context_scope(context); 3152 v8::Context::Scope context_scope(context);
3155 v8::Local<v8::Value> argv[3]; 3153 v8::Local<v8::Value> argv[3];
3156 SkAutoLockPixels snapshot_lock(snapshot); 3154 SkAutoLockPixels snapshot_lock(snapshot);
3157 3155
3158 // Size can be 0 for cases where copyImageAt was called on position 3156 // Size can be 0 for cases where copyImageAt was called on position
3159 // that doesn't have an image. 3157 // that doesn't have an image.
3160 int width = snapshot.info().width(); 3158 int width = snapshot.info().width();
(...skipping 16 matching lines...) Expand all
3177 // We only expect readPixels to fail for null bitmaps. 3175 // We only expect readPixels to fail for null bitmaps.
3178 DCHECK(snapshot.isNull()); 3176 DCHECK(snapshot.isNull());
3179 } 3177 }
3180 3178
3181 argv[2] = blink::WebArrayBufferConverter::toV8Value( 3179 argv[2] = blink::WebArrayBufferConverter::toV8Value(
3182 &buffer, context->Global(), isolate); 3180 &buffer, context->Global(), isolate);
3183 3181
3184 PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv); 3182 PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv);
3185 } 3183 }
3186 3184
3187 void TestRunner::DispatchBeforeInstallPromptCallback( 3185 void TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback(
3188 v8::UniquePersistent<v8::Function> callback, 3186 v8::UniquePersistent<v8::Function> callback,
3189 bool canceled) { 3187 bool canceled) {
3190 if (!web_view_)
3191 return;
3192
3193 v8::Isolate* isolate = blink::mainThreadIsolate(); 3188 v8::Isolate* isolate = blink::mainThreadIsolate();
3194 v8::HandleScope handle_scope(isolate); 3189 v8::HandleScope handle_scope(isolate);
3195 3190
3196 v8::Local<v8::Context> context = 3191 v8::Local<v8::Context> context =
3197 web_view_->mainFrame()->mainWorldScriptContext(); 3192 web_view()->mainFrame()->mainWorldScriptContext();
3198 if (context.IsEmpty()) 3193 if (context.IsEmpty())
3199 return; 3194 return;
3200 3195
3201 v8::Context::Scope context_scope(context); 3196 v8::Context::Scope context_scope(context);
3202 v8::Local<v8::Value> arg; 3197 v8::Local<v8::Value> arg;
3203 arg = v8::Boolean::New(isolate, canceled); 3198 arg = v8::Boolean::New(isolate, canceled);
3204 3199
3205 PostV8CallbackWithArgs(std::move(callback), 1, &arg); 3200 PostV8CallbackWithArgs(std::move(callback), 1, &arg);
3206 } 3201 }
3207 3202
3208 void TestRunner::GetBluetoothManualChooserEventsCallback( 3203 void TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback(
3209 v8::UniquePersistent<v8::Function> callback, 3204 v8::UniquePersistent<v8::Function> callback,
3210 const std::vector<std::string>& events) { 3205 const std::vector<std::string>& events) {
3211 if (!web_view_)
3212 return;
3213
3214 // Build the V8 context. 3206 // Build the V8 context.
3215 v8::Isolate* isolate = blink::mainThreadIsolate(); 3207 v8::Isolate* isolate = blink::mainThreadIsolate();
3216 v8::HandleScope handle_scope(isolate); 3208 v8::HandleScope handle_scope(isolate);
3217 v8::Local<v8::Context> context = 3209 v8::Local<v8::Context> context =
3218 web_view_->mainFrame()->mainWorldScriptContext(); 3210 web_view()->mainFrame()->mainWorldScriptContext();
3219 if (context.IsEmpty()) 3211 if (context.IsEmpty())
3220 return; 3212 return;
3221 v8::Context::Scope context_scope(context); 3213 v8::Context::Scope context_scope(context);
3222 3214
3223 // Convert the argument. 3215 // Convert the argument.
3224 v8::Local<v8::Value> arg; 3216 v8::Local<v8::Value> arg;
3225 if (!gin::TryConvertToV8(isolate, events, &arg)) 3217 if (!gin::TryConvertToV8(isolate, events, &arg))
3226 return; 3218 return;
3227 3219
3228 // Call the callback. 3220 // Call the callback.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 } 3252 }
3261 3253
3262 void TestRunner::CompleteNotifyDone() { 3254 void TestRunner::CompleteNotifyDone() {
3263 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 3255 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
3264 work_queue_.is_empty()) 3256 work_queue_.is_empty())
3265 delegate_->TestFinished(); 3257 delegate_->TestFinished();
3266 layout_test_runtime_flags_.set_wait_until_done(false); 3258 layout_test_runtime_flags_.set_wait_until_done(false);
3267 OnLayoutTestRuntimeFlagsChanged(); 3259 OnLayoutTestRuntimeFlagsChanged();
3268 } 3260 }
3269 3261
3270 void TestRunner::DidAcquirePointerLockInternal() { 3262 void TestRunnerForSpecificView::DidAcquirePointerLockInternal() {
3271 pointer_locked_ = true; 3263 pointer_locked_ = true;
3272 web_view_->didAcquirePointerLock(); 3264 web_view()->didAcquirePointerLock();
3273 3265
3274 // Reset planned result to default. 3266 // Reset planned result to default.
3275 pointer_lock_planned_result_ = PointerLockWillSucceed; 3267 pointer_lock_planned_result_ = PointerLockWillSucceed;
3276 } 3268 }
3277 3269
3278 void TestRunner::DidNotAcquirePointerLockInternal() { 3270 void TestRunnerForSpecificView::DidNotAcquirePointerLockInternal() {
3279 DCHECK(!pointer_locked_); 3271 DCHECK(!pointer_locked_);
3280 pointer_locked_ = false; 3272 pointer_locked_ = false;
3281 web_view_->didNotAcquirePointerLock(); 3273 web_view()->didNotAcquirePointerLock();
3282 3274
3283 // Reset planned result to default. 3275 // Reset planned result to default.
3284 pointer_lock_planned_result_ = PointerLockWillSucceed; 3276 pointer_lock_planned_result_ = PointerLockWillSucceed;
3285 } 3277 }
3286 3278
3287 void TestRunner::DidLosePointerLockInternal() { 3279 void TestRunnerForSpecificView::DidLosePointerLockInternal() {
3288 bool was_locked = pointer_locked_; 3280 bool was_locked = pointer_locked_;
3289 pointer_locked_ = false; 3281 pointer_locked_ = false;
3290 if (was_locked) 3282 if (was_locked)
3291 web_view_->didLosePointerLock(); 3283 web_view()->didLosePointerLock();
3284 }
3285
3286 TestRunnerForSpecificView::TestRunnerForSpecificView(
3287 WebTestProxyBase* web_test_proxy_base)
3288 : web_test_proxy_base_(web_test_proxy_base), weak_factory_(this) {
3289 Reset();
3290 }
3291
3292 TestRunnerForSpecificView::~TestRunnerForSpecificView() {}
3293
3294 void TestRunnerForSpecificView::Install(blink::WebLocalFrame* frame) {
3295 web_test_proxy_base_->test_interfaces()->GetTestRunner()->Install(
3296 frame, weak_factory_.GetWeakPtr());
3297 }
3298
3299 void TestRunnerForSpecificView::Reset() {
3300 pointer_locked_ = false;
3301 pointer_lock_planned_result_ = PointerLockWillSucceed;
3302
3303 if (web_view() && web_view()->mainFrame()) {
3304 RemoveWebPageOverlay();
3305 SetTabKeyCyclesThroughElements(true);
3306
3307 #if !defined(OS_MACOSX) && !defined(OS_WIN)
3308 // (Constants copied because we can't depend on the header that defined
3309 // them from this file.)
3310 web_view()->setSelectionColors(
3311 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
3312 #endif
3313 web_view()->setVisibilityState(WebPageVisibilityStateVisible, true);
3314 if (web_view()->mainFrame()->isWebLocalFrame()) {
3315 web_view()->mainFrame()->enableViewSourceMode(false);
3316 web_view()->setTextZoomFactor(1);
3317 web_view()->setZoomLevel(0);
3318 }
3319 }
3320 }
3321
3322 void TestRunnerForSpecificView::SetViewSourceForFrame(const std::string& name,
3323 bool enabled) {
3324 WebFrame* target_frame =
3325 web_view()->findFrameByName(WebString::fromUTF8(name));
3326 if (target_frame)
3327 target_frame->enableViewSourceMode(enabled);
3328 }
3329
3330 blink::WebView* TestRunnerForSpecificView::web_view() {
3331 return web_test_proxy_base_->web_view();
3332 }
3333
3334 WebTestDelegate* TestRunnerForSpecificView::delegate() {
3335 return web_test_proxy_base_->delegate();
3292 } 3336 }
3293 3337
3294 } // namespace test_runner 3338 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698