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

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: Created 4 years, 8 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
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 385 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
(...skipping 56 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
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 1693
1686 void TestRunner::PostTask(const base::Closure& callback) { 1694 void TestRunner::PostTask(const base::Closure& callback) {
1687 delegate_->PostTask(new WebCallbackTask(callback)); 1695 delegate_->PostTask(new WebCallbackTask(callback));
1688 } 1696 }
1689 1697
1690 void TestRunner::PostDelayedTask(long long delay, 1698 void TestRunner::PostDelayedTask(long long delay,
1691 const base::Closure& callback) { 1699 const base::Closure& callback) {
1692 delegate_->PostDelayedTask(new WebCallbackTask(callback), delay); 1700 delegate_->PostDelayedTask(new WebCallbackTask(callback), delay);
1693 } 1701 }
1694 1702
1695 void TestRunner::PostV8Callback(const v8::Local<v8::Function>& callback) { 1703 void TestRunnerForSpecificView::PostTask(const base::Closure& callback) {
1696 PostTask(base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(), 1704 delegate()->PostTask(new WebCallbackTask(callback));
1705 }
1706
1707 void TestRunnerForSpecificView::PostV8Callback(
1708 const v8::Local<v8::Function>& callback) {
1709 PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
1710 weak_factory_.GetWeakPtr(),
1697 v8::UniquePersistent<v8::Function>( 1711 v8::UniquePersistent<v8::Function>(
1698 blink::mainThreadIsolate(), callback))); 1712 blink::mainThreadIsolate(), callback)));
1699 } 1713 }
1700 1714
1701 void TestRunner::PostV8CallbackWithArgs( 1715 void TestRunnerForSpecificView::PostV8CallbackWithArgs(
1702 v8::UniquePersistent<v8::Function> callback, 1716 v8::UniquePersistent<v8::Function> callback,
1703 int argc, 1717 int argc,
1704 v8::Local<v8::Value> argv[]) { 1718 v8::Local<v8::Value> argv[]) {
1705 std::vector<v8::UniquePersistent<v8::Value>> args; 1719 std::vector<v8::UniquePersistent<v8::Value>> args;
1706 for (int i = 0; i < argc; i++) { 1720 for (int i = 0; i < argc; i++) {
1707 args.push_back( 1721 args.push_back(
1708 v8::UniquePersistent<v8::Value>(blink::mainThreadIsolate(), argv[i])); 1722 v8::UniquePersistent<v8::Value>(blink::mainThreadIsolate(), argv[i]));
1709 } 1723 }
1710 1724
1711 PostTask(base::Bind(&TestRunner::InvokeV8CallbackWithArgs, 1725 PostTask(base::Bind(&TestRunnerForSpecificView::InvokeV8CallbackWithArgs,
1712 weak_factory_.GetWeakPtr(), std::move(callback), 1726 weak_factory_.GetWeakPtr(), std::move(callback),
1713 std::move(args))); 1727 std::move(args)));
1714 } 1728 }
1715 1729
1716 void TestRunner::InvokeV8Callback( 1730 void TestRunnerForSpecificView::InvokeV8Callback(
1717 const v8::UniquePersistent<v8::Function>& callback) { 1731 const v8::UniquePersistent<v8::Function>& callback) {
1718 std::vector<v8::UniquePersistent<v8::Value>> empty_args; 1732 std::vector<v8::UniquePersistent<v8::Value>> empty_args;
1719 InvokeV8CallbackWithArgs(callback, std::move(empty_args)); 1733 InvokeV8CallbackWithArgs(callback, std::move(empty_args));
1720 } 1734 }
1721 1735
1722 void TestRunner::InvokeV8CallbackWithArgs( 1736 void TestRunnerForSpecificView::InvokeV8CallbackWithArgs(
1723 const v8::UniquePersistent<v8::Function>& callback, 1737 const v8::UniquePersistent<v8::Function>& callback,
1724 const std::vector<v8::UniquePersistent<v8::Value>>& args) { 1738 const std::vector<v8::UniquePersistent<v8::Value>>& args) {
1725 v8::Isolate* isolate = blink::mainThreadIsolate(); 1739 v8::Isolate* isolate = blink::mainThreadIsolate();
1726 v8::HandleScope handle_scope(isolate); 1740 v8::HandleScope handle_scope(isolate);
1727 1741
1728 if (!web_view_) 1742 WebFrame* frame = web_view()->mainFrame();
1729 return;
1730 WebFrame* frame = web_view_->mainFrame();
1731 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 1743 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
1732 if (context.IsEmpty()) 1744 if (context.IsEmpty())
1733 return; 1745 return;
1734 v8::Context::Scope context_scope(context); 1746 v8::Context::Scope context_scope(context);
1735 1747
1736 std::vector<v8::Local<v8::Value>> local_args; 1748 std::vector<v8::Local<v8::Value>> local_args;
1737 for (const auto& arg : args) { 1749 for (const auto& arg : args) {
1738 local_args.push_back(v8::Local<v8::Value>::New(isolate, arg)); 1750 local_args.push_back(v8::Local<v8::Value>::New(isolate, arg));
1739 } 1751 }
1740 1752
1741 frame->callFunctionEvenIfScriptDisabled( 1753 frame->callFunctionEvenIfScriptDisabled(
1742 v8::Local<v8::Function>::New(isolate, callback), context->Global(), 1754 v8::Local<v8::Function>::New(isolate, callback), context->Global(),
1743 local_args.size(), local_args.data()); 1755 local_args.size(), local_args.data());
1744 } 1756 }
1745 1757
1746 base::Closure TestRunner::CreateClosureThatPostsV8Callback( 1758 base::Closure TestRunnerForSpecificView::CreateClosureThatPostsV8Callback(
1747 const v8::Local<v8::Function>& callback) { 1759 const v8::Local<v8::Function>& callback) {
1748 return base::Bind( 1760 return base::Bind(&TestRunnerForSpecificView::PostTask,
1749 &TestRunner::PostTask, weak_factory_.GetWeakPtr(), 1761 weak_factory_.GetWeakPtr(),
1750 base::Bind(&TestRunner::InvokeV8Callback, weak_factory_.GetWeakPtr(), 1762 base::Bind(&TestRunnerForSpecificView::InvokeV8Callback,
1751 v8::UniquePersistent<v8::Function>(blink::mainThreadIsolate(), 1763 weak_factory_.GetWeakPtr(),
1752 callback))); 1764 v8::UniquePersistent<v8::Function>(
1765 blink::mainThreadIsolate(), callback)));
1753 } 1766 }
1754 1767
1755 bool TestRunner::shouldDumpEditingCallbacks() const { 1768 bool TestRunner::shouldDumpEditingCallbacks() const {
1756 return layout_test_runtime_flags_.dump_editting_callbacks(); 1769 return layout_test_runtime_flags_.dump_editting_callbacks();
1757 } 1770 }
1758 1771
1759 void TestRunner::setShouldDumpAsText(bool value) { 1772 void TestRunner::setShouldDumpAsText(bool value) {
1760 layout_test_runtime_flags_.set_dump_as_text(value); 1773 layout_test_runtime_flags_.set_dump_as_text(value);
1761 OnLayoutTestRuntimeFlagsChanged(); 1774 OnLayoutTestRuntimeFlagsChanged();
1762 } 1775 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 bitmap.eraseColor(0); 1839 bitmap.eraseColor(0);
1827 } 1840 }
1828 callback.Run(bitmap); 1841 callback.Run(bitmap);
1829 return; 1842 return;
1830 } 1843 }
1831 1844
1832 callback.Run(drag_image_.getSkBitmap()); 1845 callback.Run(drag_image_.getSkBitmap());
1833 return; 1846 return;
1834 } 1847 }
1835 1848
1836 test_runner::DumpPixelsAsync(web_view_, layout_test_runtime_flags_, 1849 test_runner::DumpPixelsAsync(web_view, layout_test_runtime_flags_,
1837 delegate_->GetDeviceScaleFactorForTest(), 1850 delegate_->GetDeviceScaleFactorForTest(),
1838 callback); 1851 callback);
1839 } 1852 }
1840 1853
1841 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1854 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1842 const base::DictionaryValue& changed_values) { 1855 const base::DictionaryValue& changed_values) {
1843 DCHECK(test_is_running_); 1856 DCHECK(test_is_running_);
1844 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1857 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1845 changed_values); 1858 changed_values);
1846 } 1859 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2181
2169 void TestRunner::SetCloseRemainingWindowsWhenComplete( 2182 void TestRunner::SetCloseRemainingWindowsWhenComplete(
2170 bool close_remaining_windows) { 2183 bool close_remaining_windows) {
2171 close_remaining_windows_ = close_remaining_windows; 2184 close_remaining_windows_ = close_remaining_windows;
2172 } 2185 }
2173 2186
2174 void TestRunner::ResetTestHelperControllers() { 2187 void TestRunner::ResetTestHelperControllers() {
2175 test_interfaces_->ResetTestHelperControllers(); 2188 test_interfaces_->ResetTestHelperControllers();
2176 } 2189 }
2177 2190
2178 void TestRunner::SetTabKeyCyclesThroughElements( 2191 void TestRunnerForSpecificView::SetTabKeyCyclesThroughElements(
2179 bool tab_key_cycles_through_elements) { 2192 bool tab_key_cycles_through_elements) {
2180 web_view_->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements); 2193 web_view()->setTabKeyCyclesThroughElements(tab_key_cycles_through_elements);
2181 } 2194 }
2182 2195
2183 void TestRunner::ExecCommand(gin::Arguments* args) { 2196 void TestRunnerForSpecificView::ExecCommand(gin::Arguments* args) {
2184 std::string command; 2197 std::string command;
2185 args->GetNext(&command); 2198 args->GetNext(&command);
2186 2199
2187 std::string value; 2200 std::string value;
2188 if (args->Length() >= 3) { 2201 if (args->Length() >= 3) {
2189 // Ignore the second parameter (which is userInterface) 2202 // Ignore the second parameter (which is userInterface)
2190 // since this command emulates a manual action. 2203 // since this command emulates a manual action.
2191 args->Skip(); 2204 args->Skip();
2192 args->GetNext(&value); 2205 args->GetNext(&value);
2193 } 2206 }
2194 2207
2195 // Note: webkit's version does not return the boolean, so neither do we. 2208 // Note: webkit's version does not return the boolean, so neither do we.
2196 web_view_->focusedFrame()->executeCommand(WebString::fromUTF8(command), 2209 web_view()->focusedFrame()->executeCommand(WebString::fromUTF8(command),
2197 WebString::fromUTF8(value)); 2210 WebString::fromUTF8(value));
2198 } 2211 }
2199 2212
2200 bool TestRunner::IsCommandEnabled(const std::string& command) { 2213 bool TestRunnerForSpecificView::IsCommandEnabled(const std::string& command) {
2201 return web_view_->focusedFrame()->isCommandEnabled( 2214 return web_view()->focusedFrame()->isCommandEnabled(
2202 WebString::fromUTF8(command)); 2215 WebString::fromUTF8(command));
2203 } 2216 }
2204 2217
2205 bool TestRunner::CallShouldCloseOnWebView() { 2218 bool TestRunnerForSpecificView::CallShouldCloseOnWebView() {
2206 return web_view_->mainFrame()->dispatchBeforeUnloadEvent(); 2219 return web_view()->mainFrame()->dispatchBeforeUnloadEvent();
2207 } 2220 }
2208 2221
2209 void TestRunner::SetDomainRelaxationForbiddenForURLScheme( 2222 void TestRunnerForSpecificView::SetDomainRelaxationForbiddenForURLScheme(
2210 bool forbidden, const std::string& scheme) { 2223 bool forbidden,
2211 web_view_->setDomainRelaxationForbidden(forbidden, 2224 const std::string& scheme) {
2212 WebString::fromUTF8(scheme)); 2225 web_view()->setDomainRelaxationForbidden(forbidden,
2226 WebString::fromUTF8(scheme));
2213 } 2227 }
2214 2228
2215 v8::Local<v8::Value> TestRunner::EvaluateScriptInIsolatedWorldAndReturnValue( 2229 v8::Local<v8::Value>
2230 TestRunnerForSpecificView::EvaluateScriptInIsolatedWorldAndReturnValue(
2216 int world_id, 2231 int world_id,
2217 const std::string& script) { 2232 const std::string& script) {
2218 WebVector<v8::Local<v8::Value>> values; 2233 WebVector<v8::Local<v8::Value>> values;
2219 WebScriptSource source(WebString::fromUTF8(script)); 2234 WebScriptSource source(WebString::fromUTF8(script));
2220 // This relies on the iframe focusing itself when it loads. This is a bit 2235 // 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. 2236 // sketchy, but it seems to be what other tests do.
2222 web_view_->focusedFrame()->executeScriptInIsolatedWorld( 2237 web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
2223 world_id, &source, 1, 1, &values); 2238 1, &values);
2224 // Since only one script was added, only one result is expected 2239 // Since only one script was added, only one result is expected
2225 if (values.size() == 1 && !values[0].IsEmpty()) 2240 if (values.size() == 1 && !values[0].IsEmpty())
2226 return values[0]; 2241 return values[0];
2227 return v8::Local<v8::Value>(); 2242 return v8::Local<v8::Value>();
2228 } 2243 }
2229 2244
2230 void TestRunner::EvaluateScriptInIsolatedWorld(int world_id, 2245 void TestRunnerForSpecificView::EvaluateScriptInIsolatedWorld(
2231 const std::string& script) { 2246 int world_id,
2247 const std::string& script) {
2232 WebScriptSource source(WebString::fromUTF8(script)); 2248 WebScriptSource source(WebString::fromUTF8(script));
2233 web_view_->focusedFrame()->executeScriptInIsolatedWorld( 2249 web_view()->focusedFrame()->executeScriptInIsolatedWorld(world_id, &source, 1,
2234 world_id, &source, 1, 1); 2250 1);
2235 } 2251 }
2236 2252
2237 void TestRunner::SetIsolatedWorldSecurityOrigin(int world_id, 2253 void TestRunnerForSpecificView::SetIsolatedWorldSecurityOrigin(
2238 v8::Local<v8::Value> origin) { 2254 int world_id,
2255 v8::Local<v8::Value> origin) {
2239 if (!(origin->IsString() || !origin->IsNull())) 2256 if (!(origin->IsString() || !origin->IsNull()))
2240 return; 2257 return;
2241 2258
2242 WebSecurityOrigin web_origin; 2259 WebSecurityOrigin web_origin;
2243 if (origin->IsString()) { 2260 if (origin->IsString()) {
2244 web_origin = WebSecurityOrigin::createFromString( 2261 web_origin = WebSecurityOrigin::createFromString(
2245 V8StringToWebString(origin.As<v8::String>())); 2262 V8StringToWebString(origin.As<v8::String>()));
2246 } 2263 }
2247 web_view_->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id, 2264 web_view()->focusedFrame()->setIsolatedWorldSecurityOrigin(world_id,
2248 web_origin); 2265 web_origin);
2249 } 2266 }
2250 2267
2251 void TestRunner::SetIsolatedWorldContentSecurityPolicy( 2268 void TestRunnerForSpecificView::SetIsolatedWorldContentSecurityPolicy(
2252 int world_id, 2269 int world_id,
2253 const std::string& policy) { 2270 const std::string& policy) {
2254 web_view_->focusedFrame()->setIsolatedWorldContentSecurityPolicy( 2271 web_view()->focusedFrame()->setIsolatedWorldContentSecurityPolicy(
2255 world_id, WebString::fromUTF8(policy)); 2272 world_id, WebString::fromUTF8(policy));
2256 } 2273 }
2257 2274
2258 void TestRunner::AddOriginAccessWhitelistEntry( 2275 void TestRunner::AddOriginAccessWhitelistEntry(
2259 const std::string& source_origin, 2276 const std::string& source_origin,
2260 const std::string& destination_protocol, 2277 const std::string& destination_protocol,
2261 const std::string& destination_host, 2278 const std::string& destination_host,
2262 bool allow_destination_subdomains) { 2279 bool allow_destination_subdomains) {
2263 WebURL url((GURL(source_origin))); 2280 WebURL url((GURL(source_origin)));
2264 if (!url.isValid()) 2281 if (!url.isValid())
(...skipping 15 matching lines...) Expand all
2280 if (!url.isValid()) 2297 if (!url.isValid())
2281 return; 2298 return;
2282 2299
2283 WebSecurityPolicy::removeOriginAccessWhitelistEntry( 2300 WebSecurityPolicy::removeOriginAccessWhitelistEntry(
2284 url, 2301 url,
2285 WebString::fromUTF8(destination_protocol), 2302 WebString::fromUTF8(destination_protocol),
2286 WebString::fromUTF8(destination_host), 2303 WebString::fromUTF8(destination_host),
2287 allow_destination_subdomains); 2304 allow_destination_subdomains);
2288 } 2305 }
2289 2306
2290 bool TestRunner::HasCustomPageSizeStyle(int page_index) { 2307 bool TestRunnerForSpecificView::HasCustomPageSizeStyle(int page_index) {
2291 WebFrame* frame = web_view_->mainFrame(); 2308 WebFrame* frame = web_view()->mainFrame();
2292 if (!frame) 2309 if (!frame)
2293 return false; 2310 return false;
2294 return frame->hasCustomPageSizeStyle(page_index); 2311 return frame->hasCustomPageSizeStyle(page_index);
2295 } 2312 }
2296 2313
2297 void TestRunner::ForceRedSelectionColors() { 2314 void TestRunnerForSpecificView::ForceRedSelectionColors() {
2298 web_view_->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, 0xffc0c0c0); 2315 web_view()->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000,
2316 0xffc0c0c0);
2299 } 2317 }
2300 2318
2301 void TestRunner::InsertStyleSheet(const std::string& source_code) { 2319 void TestRunner::InsertStyleSheet(const std::string& source_code) {
2302 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet( 2320 WebLocalFrame::frameForCurrentContext()->document().insertStyleSheet(
2303 WebString::fromUTF8(source_code)); 2321 WebString::fromUTF8(source_code));
2304 } 2322 }
2305 2323
2306 bool TestRunner::FindString(const std::string& search_text, 2324 bool TestRunnerForSpecificView::FindString(
2307 const std::vector<std::string>& options_array) { 2325 const std::string& search_text,
2326 const std::vector<std::string>& options_array) {
2308 WebFindOptions find_options; 2327 WebFindOptions find_options;
2309 bool wrap_around = false; 2328 bool wrap_around = false;
2310 find_options.matchCase = true; 2329 find_options.matchCase = true;
2311 find_options.findNext = true; 2330 find_options.findNext = true;
2312 2331
2313 for (const std::string& option : options_array) { 2332 for (const std::string& option : options_array) {
2314 if (option == "CaseInsensitive") 2333 if (option == "CaseInsensitive")
2315 find_options.matchCase = false; 2334 find_options.matchCase = false;
2316 else if (option == "Backwards") 2335 else if (option == "Backwards")
2317 find_options.forward = false; 2336 find_options.forward = false;
2318 else if (option == "StartInSelection") 2337 else if (option == "StartInSelection")
2319 find_options.findNext = false; 2338 find_options.findNext = false;
2320 else if (option == "AtWordStarts") 2339 else if (option == "AtWordStarts")
2321 find_options.wordStart = true; 2340 find_options.wordStart = true;
2322 else if (option == "TreatMedialCapitalAsWordStart") 2341 else if (option == "TreatMedialCapitalAsWordStart")
2323 find_options.medialCapitalAsWordStart = true; 2342 find_options.medialCapitalAsWordStart = true;
2324 else if (option == "WrapAround") 2343 else if (option == "WrapAround")
2325 wrap_around = true; 2344 wrap_around = true;
2326 } 2345 }
2327 2346
2328 WebLocalFrame* frame = web_view_->mainFrame()->toWebLocalFrame(); 2347 WebLocalFrame* frame = web_view()->mainFrame()->toWebLocalFrame();
2329 const bool find_result = frame->find(0, WebString::fromUTF8(search_text), 2348 const bool find_result = frame->find(0, WebString::fromUTF8(search_text),
2330 find_options, wrap_around, 0); 2349 find_options, wrap_around, 0);
2331 frame->stopFinding(false); 2350 frame->stopFinding(false);
2332 return find_result; 2351 return find_result;
2333 } 2352 }
2334 2353
2335 std::string TestRunner::SelectionAsMarkup() { 2354 std::string TestRunnerForSpecificView::SelectionAsMarkup() {
2336 return web_view_->mainFrame()->selectionAsMarkup().utf8(); 2355 return web_view()->mainFrame()->selectionAsMarkup().utf8();
2337 } 2356 }
2338 2357
2339 void TestRunner::SetTextSubpixelPositioning(bool value) { 2358 void TestRunner::SetTextSubpixelPositioning(bool value) {
2340 #if defined(__linux__) || defined(ANDROID) 2359 #if defined(__linux__) || defined(ANDROID)
2341 // Since FontConfig doesn't provide a variable to control subpixel 2360 // Since FontConfig doesn't provide a variable to control subpixel
2342 // positioning, we'll fall back to setting it globally for all fonts. 2361 // positioning, we'll fall back to setting it globally for all fonts.
2343 WebFontRendering::setSubpixelPositioning(value); 2362 WebFontRendering::setSubpixelPositioning(value);
2344 #endif 2363 #endif
2345 } 2364 }
2346 2365
2347 void TestRunner::SetPageVisibility(const std::string& new_visibility) { 2366 void TestRunnerForSpecificView::SetPageVisibility(
2367 const std::string& new_visibility) {
2348 if (new_visibility == "visible") 2368 if (new_visibility == "visible")
2349 web_view_->setVisibilityState(WebPageVisibilityStateVisible, false); 2369 web_view()->setVisibilityState(WebPageVisibilityStateVisible, false);
2350 else if (new_visibility == "hidden") 2370 else if (new_visibility == "hidden")
2351 web_view_->setVisibilityState(WebPageVisibilityStateHidden, false); 2371 web_view()->setVisibilityState(WebPageVisibilityStateHidden, false);
2352 else if (new_visibility == "prerender") 2372 else if (new_visibility == "prerender")
2353 web_view_->setVisibilityState(WebPageVisibilityStatePrerender, false); 2373 web_view()->setVisibilityState(WebPageVisibilityStatePrerender, false);
2354 } 2374 }
2355 2375
2356 void TestRunner::SetTextDirection(const std::string& direction_name) { 2376 void TestRunnerForSpecificView::SetTextDirection(
2377 const std::string& direction_name) {
2357 // Map a direction name to a WebTextDirection value. 2378 // Map a direction name to a WebTextDirection value.
2358 WebTextDirection direction; 2379 WebTextDirection direction;
2359 if (direction_name == "auto") 2380 if (direction_name == "auto")
2360 direction = WebTextDirectionDefault; 2381 direction = WebTextDirectionDefault;
2361 else if (direction_name == "rtl") 2382 else if (direction_name == "rtl")
2362 direction = WebTextDirectionRightToLeft; 2383 direction = WebTextDirectionRightToLeft;
2363 else if (direction_name == "ltr") 2384 else if (direction_name == "ltr")
2364 direction = WebTextDirectionLeftToRight; 2385 direction = WebTextDirectionLeftToRight;
2365 else 2386 else
2366 return; 2387 return;
2367 2388
2368 web_view_->setTextDirection(direction); 2389 web_view()->setTextDirection(direction);
2369 } 2390 }
2370 2391
2371 void TestRunner::UseUnfortunateSynchronousResizeMode() { 2392 void TestRunner::UseUnfortunateSynchronousResizeMode() {
2372 delegate_->UseUnfortunateSynchronousResizeMode(true); 2393 delegate_->UseUnfortunateSynchronousResizeMode(true);
2373 } 2394 }
2374 2395
2375 bool TestRunner::EnableAutoResizeMode(int min_width, 2396 bool TestRunner::EnableAutoResizeMode(int min_width,
2376 int min_height, 2397 int min_height,
2377 int max_width, 2398 int max_width,
2378 int max_height) { 2399 int max_height) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 layout_test_runtime_flags_.set_dump_drag_image(true); 2861 layout_test_runtime_flags_.set_dump_drag_image(true);
2841 DumpAsTextWithPixelResults(); 2862 DumpAsTextWithPixelResults();
2842 OnLayoutTestRuntimeFlagsChanged(); 2863 OnLayoutTestRuntimeFlagsChanged();
2843 } 2864 }
2844 2865
2845 void TestRunner::DumpNavigationPolicy() { 2866 void TestRunner::DumpNavigationPolicy() {
2846 layout_test_runtime_flags_.set_dump_navigation_policy(true); 2867 layout_test_runtime_flags_.set_dump_navigation_policy(true);
2847 OnLayoutTestRuntimeFlagsChanged(); 2868 OnLayoutTestRuntimeFlagsChanged();
2848 } 2869 }
2849 2870
2850 void TestRunner::DumpPageImportanceSignals() { 2871 void TestRunnerForSpecificView::DumpPageImportanceSignals() {
2851 blink::WebPageImportanceSignals* signals = 2872 blink::WebPageImportanceSignals* signals =
2852 web_view_->pageImportanceSignals(); 2873 web_view()->pageImportanceSignals();
2853 if (!signals) 2874 if (!signals)
2854 return; 2875 return;
2855 2876
2856 std::string message = base::StringPrintf( 2877 std::string message = base::StringPrintf(
2857 "WebPageImportanceSignals:\n" 2878 "WebPageImportanceSignals:\n"
2858 " hadFormInteraction: %s\n" 2879 " hadFormInteraction: %s\n"
2859 " issuedNonGetFetchFromScript: %s\n", 2880 " issuedNonGetFetchFromScript: %s\n",
2860 signals->hadFormInteraction() ? "true" : "false", 2881 signals->hadFormInteraction() ? "true" : "false",
2861 signals->issuedNonGetFetchFromScript() ? "true" : "false"); 2882 signals->issuedNonGetFetchFromScript() ? "true" : "false");
2862 if (delegate_) 2883 if (delegate())
2863 delegate_->PrintMessage(message); 2884 delegate()->PrintMessage(message);
2864 } 2885 }
2865 2886
2866 void TestRunner::CloseWebInspector() { 2887 void TestRunner::CloseWebInspector() {
2867 delegate_->CloseDevTools(); 2888 delegate_->CloseDevTools();
2868 } 2889 }
2869 2890
2870 bool TestRunner::IsChooserShown() { 2891 bool TestRunner::IsChooserShown() {
2871 return 0 < chooser_count_; 2892 return 0 < chooser_count_;
2872 } 2893 }
2873 2894
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 delegate_->SetFocus(web_view, false); 2930 delegate_->SetFocus(web_view, false);
2910 previously_focused_view_ = nullptr; 2931 previously_focused_view_ = nullptr;
2911 } 2932 }
2912 } 2933 }
2913 } 2934 }
2914 2935
2915 std::string TestRunner::PathToLocalResource(const std::string& path) { 2936 std::string TestRunner::PathToLocalResource(const std::string& path) {
2916 return delegate_->PathToLocalResource(path); 2937 return delegate_->PathToLocalResource(path);
2917 } 2938 }
2918 2939
2919 void TestRunner::SetBackingScaleFactor(double value, 2940 void TestRunnerForSpecificView::SetBackingScaleFactor(
2920 v8::Local<v8::Function> callback) { 2941 double value,
2921 delegate_->SetDeviceScaleFactor(value); 2942 v8::Local<v8::Function> callback) {
2943 delegate()->SetDeviceScaleFactor(value);
2922 PostV8Callback(callback); 2944 PostV8Callback(callback);
2923 } 2945 }
2924 2946
2925 void TestRunner::EnableUseZoomForDSF(v8::Local<v8::Function> callback) { 2947 void TestRunnerForSpecificView::EnableUseZoomForDSF(
2926 delegate_->EnableUseZoomForDSF(); 2948 v8::Local<v8::Function> callback) {
2949 delegate()->EnableUseZoomForDSF();
2927 PostV8Callback(callback); 2950 PostV8Callback(callback);
2928 } 2951 }
2929 2952
2930 void TestRunner::SetColorProfile(const std::string& name, 2953 void TestRunnerForSpecificView::SetColorProfile(
2931 v8::Local<v8::Function> callback) { 2954 const std::string& name,
2932 delegate_->SetDeviceColorProfile(name); 2955 v8::Local<v8::Function> callback) {
2956 delegate()->SetDeviceColorProfile(name);
2933 PostV8Callback(callback); 2957 PostV8Callback(callback);
2934 } 2958 }
2935 2959
2936 void TestRunner::SetBluetoothFakeAdapter(const std::string& adapter_name, 2960 void TestRunnerForSpecificView::SetBluetoothFakeAdapter(
2937 v8::Local<v8::Function> callback) { 2961 const std::string& adapter_name,
2938 delegate_->SetBluetoothFakeAdapter( 2962 v8::Local<v8::Function> callback) {
2963 delegate()->SetBluetoothFakeAdapter(
2939 adapter_name, CreateClosureThatPostsV8Callback(callback)); 2964 adapter_name, CreateClosureThatPostsV8Callback(callback));
2940 } 2965 }
2941 2966
2942 void TestRunner::SetBluetoothManualChooser(bool enable) { 2967 void TestRunnerForSpecificView::SetBluetoothManualChooser(bool enable) {
2943 delegate_->SetBluetoothManualChooser(enable); 2968 delegate()->SetBluetoothManualChooser(enable);
2944 } 2969 }
2945 2970
2946 void TestRunner::GetBluetoothManualChooserEvents( 2971 void TestRunnerForSpecificView::GetBluetoothManualChooserEvents(
2947 v8::Local<v8::Function> callback) { 2972 v8::Local<v8::Function> callback) {
2948 return delegate_->GetBluetoothManualChooserEvents( 2973 return delegate()->GetBluetoothManualChooserEvents(base::Bind(
2949 base::Bind(&TestRunner::GetBluetoothManualChooserEventsCallback, 2974 &TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback,
2950 weak_factory_.GetWeakPtr(), 2975 weak_factory_.GetWeakPtr(),
2951 base::Passed(v8::UniquePersistent<v8::Function>( 2976 base::Passed(v8::UniquePersistent<v8::Function>(
2952 blink::mainThreadIsolate(), callback)))); 2977 blink::mainThreadIsolate(), callback))));
2953 } 2978 }
2954 2979
2955 void TestRunner::SendBluetoothManualChooserEvent(const std::string& event, 2980 void TestRunnerForSpecificView::SendBluetoothManualChooserEvent(
2956 const std::string& argument) { 2981 const std::string& event,
2957 delegate_->SendBluetoothManualChooserEvent(event, argument); 2982 const std::string& argument) {
2983 delegate()->SendBluetoothManualChooserEvent(event, argument);
2958 } 2984 }
2959 2985
2960 void TestRunner::SetGeofencingMockProvider(bool service_available) { 2986 void TestRunner::SetGeofencingMockProvider(bool service_available) {
2961 delegate_->SetGeofencingMockProvider(service_available); 2987 delegate_->SetGeofencingMockProvider(service_available);
2962 } 2988 }
2963 2989
2964 void TestRunner::ClearGeofencingMockProvider() { 2990 void TestRunner::ClearGeofencingMockProvider() {
2965 delegate_->ClearGeofencingMockProvider(); 2991 delegate_->ClearGeofencingMockProvider();
2966 } 2992 }
2967 2993
2968 void TestRunner::SetGeofencingMockPosition(double latitude, double longitude) { 2994 void TestRunner::SetGeofencingMockPosition(double latitude, double longitude) {
2969 delegate_->SetGeofencingMockPosition(latitude, longitude); 2995 delegate_->SetGeofencingMockPosition(latitude, longitude);
2970 } 2996 }
2971 2997
2972 void TestRunner::SetPermission(const std::string& name, 2998 void TestRunner::SetPermission(const std::string& name,
2973 const std::string& value, 2999 const std::string& value,
2974 const GURL& origin, 3000 const GURL& origin,
2975 const GURL& embedding_origin) { 3001 const GURL& embedding_origin) {
2976 delegate_->SetPermission(name, value, origin, embedding_origin); 3002 delegate_->SetPermission(name, value, origin, embedding_origin);
2977 } 3003 }
2978 3004
2979 void TestRunner::DispatchBeforeInstallPromptEvent( 3005 void TestRunnerForSpecificView::DispatchBeforeInstallPromptEvent(
2980 int request_id, 3006 int request_id,
2981 const std::vector<std::string>& event_platforms, 3007 const std::vector<std::string>& event_platforms,
2982 v8::Local<v8::Function> callback) { 3008 v8::Local<v8::Function> callback) {
2983 delegate_->DispatchBeforeInstallPromptEvent( 3009 delegate()->DispatchBeforeInstallPromptEvent(
2984 request_id, event_platforms, 3010 request_id, event_platforms,
2985 base::Bind(&TestRunner::DispatchBeforeInstallPromptCallback, 3011 base::Bind(
2986 weak_factory_.GetWeakPtr(), 3012 &TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback,
2987 base::Passed(v8::UniquePersistent<v8::Function>( 3013 weak_factory_.GetWeakPtr(),
2988 blink::mainThreadIsolate(), callback)))); 3014 base::Passed(v8::UniquePersistent<v8::Function>(
3015 blink::mainThreadIsolate(), callback))));
2989 } 3016 }
2990 3017
2991 void TestRunner::ResolveBeforeInstallPromptPromise( 3018 void TestRunner::ResolveBeforeInstallPromptPromise(
2992 int request_id, 3019 int request_id,
2993 const std::string& platform) { 3020 const std::string& platform) {
2994 if (!test_interfaces_->GetAppBannerClient()) 3021 if (!test_interfaces_->GetAppBannerClient())
2995 return; 3022 return;
2996 test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform); 3023 test_interfaces_->GetAppBannerClient()->ResolvePromise(request_id, platform);
2997 } 3024 }
2998 3025
2999 void TestRunner::RunIdleTasks(v8::Local<v8::Function> callback) { 3026 void TestRunnerForSpecificView::RunIdleTasks(v8::Local<v8::Function> callback) {
3000 delegate_->RunIdleTasks( 3027 delegate()->RunIdleTasks(CreateClosureThatPostsV8Callback(callback));
3001 CreateClosureThatPostsV8Callback(callback));
3002 } 3028 }
3003 3029
3004 void TestRunner::SetPOSIXLocale(const std::string& locale) { 3030 void TestRunner::SetPOSIXLocale(const std::string& locale) {
3005 delegate_->SetLocale(locale); 3031 delegate_->SetLocale(locale);
3006 } 3032 }
3007 3033
3008 void TestRunner::SetMIDIAccessorResult(bool result) { 3034 void TestRunner::SetMIDIAccessorResult(bool result) {
3009 midi_accessor_result_ = result; 3035 midi_accessor_result_ = result;
3010 } 3036 }
3011 3037
(...skipping 25 matching lines...) Expand all
3037 const std::string& password) { 3063 const std::string& password) {
3038 credential_manager_client_->SetResponse(new WebPasswordCredential( 3064 credential_manager_client_->SetResponse(new WebPasswordCredential(
3039 WebString::fromUTF8(id), WebString::fromUTF8(password), 3065 WebString::fromUTF8(id), WebString::fromUTF8(password),
3040 WebString::fromUTF8(name), WebURL(GURL(avatar)))); 3066 WebString::fromUTF8(name), WebURL(GURL(avatar))));
3041 } 3067 }
3042 3068
3043 void TestRunner::AddMockCredentialManagerError(const std::string& error) { 3069 void TestRunner::AddMockCredentialManagerError(const std::string& error) {
3044 credential_manager_client_->SetError(error); 3070 credential_manager_client_->SetError(error);
3045 } 3071 }
3046 3072
3047 void TestRunner::AddWebPageOverlay() { 3073 void TestRunnerForSpecificView::AddWebPageOverlay() {
3048 if (web_view_) 3074 web_view()->setPageOverlayColor(SK_ColorCYAN);
3049 web_view_->setPageOverlayColor(SK_ColorCYAN);
3050 } 3075 }
3051 3076
3052 void TestRunner::RemoveWebPageOverlay() { 3077 void TestRunnerForSpecificView::RemoveWebPageOverlay() {
3053 if (web_view_) 3078 web_view()->setPageOverlayColor(SK_ColorTRANSPARENT);
3054 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
3055 } 3079 }
3056 3080
3057 void TestRunner::LayoutAndPaintAsync() { 3081 void TestRunnerForSpecificView::LayoutAndPaintAsync() {
3058 test_runner::LayoutAndPaintAsyncThen(web_view_, base::Closure()); 3082 test_runner::LayoutAndPaintAsyncThen(web_view(), base::Closure());
3059 } 3083 }
3060 3084
3061 void TestRunner::LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback) { 3085 void TestRunnerForSpecificView::LayoutAndPaintAsyncThen(
3086 v8::Local<v8::Function> callback) {
3062 test_runner::LayoutAndPaintAsyncThen( 3087 test_runner::LayoutAndPaintAsyncThen(
3063 web_view_, CreateClosureThatPostsV8Callback(callback)); 3088 web_view(), CreateClosureThatPostsV8Callback(callback));
3064 } 3089 }
3065 3090
3066 void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) { 3091 void TestRunnerForSpecificView::GetManifestThen(
3092 v8::Local<v8::Function> callback) {
3067 v8::UniquePersistent<v8::Function> persistent_callback( 3093 v8::UniquePersistent<v8::Function> persistent_callback(
3068 blink::mainThreadIsolate(), callback); 3094 blink::mainThreadIsolate(), callback);
3069 3095
3070 if (!web_view_) { 3096 delegate()->FetchManifest(
3071 WebURLResponse response; 3097 web_view(), web_view()->mainFrame()->document().manifestURL(),
3072 response.setHTTPStatusCode(404); 3098 base::Bind(&TestRunnerForSpecificView::GetManifestCallback,
3073 GetManifestCallback(std::move(persistent_callback), response, ""); 3099 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)))); 3100 base::Passed(std::move(persistent_callback))));
3081 } 3101 }
3082 3102
3083 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { 3103 void TestRunnerForSpecificView::CapturePixelsAsyncThen(
3104 v8::Local<v8::Function> callback) {
3084 v8::UniquePersistent<v8::Function> persistent_callback( 3105 v8::UniquePersistent<v8::Function> persistent_callback(
3085 blink::mainThreadIsolate(), callback); 3106 blink::mainThreadIsolate(), callback);
3086 3107
3087 if (!web_view_) { 3108 web_test_proxy_base_->test_interfaces()->GetTestRunner()->DumpPixelsAsync(
3088 CapturePixelsCallback(std::move(persistent_callback), SkBitmap()); 3109 web_view(), base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
3089 return; 3110 weak_factory_.GetWeakPtr(),
3090 } 3111 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 } 3112 }
3097 3113
3098 void TestRunner::OnLayoutTestRuntimeFlagsChanged() { 3114 void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
3099 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty()) 3115 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty())
3100 return; 3116 return;
3101 3117
3102 delegate_->OnLayoutTestRuntimeFlagsChanged( 3118 delegate_->OnLayoutTestRuntimeFlagsChanged(
3103 layout_test_runtime_flags_.tracked_dictionary().changed_values()); 3119 layout_test_runtime_flags_.tracked_dictionary().changed_values());
3104 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking(); 3120 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking();
3105 } 3121 }
3106 3122
3107 void TestRunner::ForceNextWebGLContextCreationToFail() { 3123 void TestRunnerForSpecificView::ForceNextWebGLContextCreationToFail() {
3108 if (web_view_) 3124 web_view()->forceNextWebGLContextCreationToFail();
3109 web_view_->forceNextWebGLContextCreationToFail();
3110 } 3125 }
3111 3126
3112 void TestRunner::ForceNextDrawingBufferCreationToFail() { 3127 void TestRunnerForSpecificView::ForceNextDrawingBufferCreationToFail() {
3113 if (web_view_) 3128 web_view()->forceNextDrawingBufferCreationToFail();
3114 web_view_->forceNextDrawingBufferCreationToFail();
3115 } 3129 }
3116 3130
3117 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( 3131 void TestRunnerForSpecificView::CopyImageAtAndCapturePixelsAsyncThen(
3118 int x, int y, v8::Local<v8::Function> callback) { 3132 int x,
3133 int y,
3134 v8::Local<v8::Function> callback) {
3119 v8::UniquePersistent<v8::Function> persistent_callback( 3135 v8::UniquePersistent<v8::Function> persistent_callback(
3120 blink::mainThreadIsolate(), callback); 3136 blink::mainThreadIsolate(), callback);
3121 3137
3122 if (!web_view_) {
3123 CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
3124 return;
3125 }
3126
3127 CopyImageAtAndCapturePixels( 3138 CopyImageAtAndCapturePixels(
3128 web_view_, x, y, 3139 web_view(), x, y,
3129 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(), 3140 base::Bind(&TestRunnerForSpecificView::CapturePixelsCallback,
3141 weak_factory_.GetWeakPtr(),
3130 base::Passed(std::move(persistent_callback)))); 3142 base::Passed(std::move(persistent_callback))));
3131 } 3143 }
3132 3144
3133 void TestRunner::GetManifestCallback( 3145 void TestRunnerForSpecificView::GetManifestCallback(
3134 v8::UniquePersistent<v8::Function> callback, 3146 v8::UniquePersistent<v8::Function> callback,
3135 const blink::WebURLResponse& response, 3147 const blink::WebURLResponse& response,
3136 const std::string& data) { 3148 const std::string& data) {
3137 PostV8CallbackWithArgs(std::move(callback), 0, nullptr); 3149 PostV8CallbackWithArgs(std::move(callback), 0, nullptr);
3138 } 3150 }
3139 3151
3140 void TestRunner::CapturePixelsCallback( 3152 void TestRunnerForSpecificView::CapturePixelsCallback(
3141 v8::UniquePersistent<v8::Function> callback, 3153 v8::UniquePersistent<v8::Function> callback,
3142 const SkBitmap& snapshot) { 3154 const SkBitmap& snapshot) {
3143 if (!web_view_)
3144 return;
3145
3146 v8::Isolate* isolate = blink::mainThreadIsolate(); 3155 v8::Isolate* isolate = blink::mainThreadIsolate();
3147 v8::HandleScope handle_scope(isolate); 3156 v8::HandleScope handle_scope(isolate);
3148 3157
3149 v8::Local<v8::Context> context = 3158 v8::Local<v8::Context> context =
3150 web_view_->mainFrame()->mainWorldScriptContext(); 3159 web_view()->mainFrame()->mainWorldScriptContext();
3151 if (context.IsEmpty()) 3160 if (context.IsEmpty())
3152 return; 3161 return;
3153 3162
3154 v8::Context::Scope context_scope(context); 3163 v8::Context::Scope context_scope(context);
3155 v8::Local<v8::Value> argv[3]; 3164 v8::Local<v8::Value> argv[3];
3156 SkAutoLockPixels snapshot_lock(snapshot); 3165 SkAutoLockPixels snapshot_lock(snapshot);
3157 3166
3158 // Size can be 0 for cases where copyImageAt was called on position 3167 // Size can be 0 for cases where copyImageAt was called on position
3159 // that doesn't have an image. 3168 // that doesn't have an image.
3160 int width = snapshot.info().width(); 3169 int width = snapshot.info().width();
(...skipping 16 matching lines...) Expand all
3177 // We only expect readPixels to fail for null bitmaps. 3186 // We only expect readPixels to fail for null bitmaps.
3178 DCHECK(snapshot.isNull()); 3187 DCHECK(snapshot.isNull());
3179 } 3188 }
3180 3189
3181 argv[2] = blink::WebArrayBufferConverter::toV8Value( 3190 argv[2] = blink::WebArrayBufferConverter::toV8Value(
3182 &buffer, context->Global(), isolate); 3191 &buffer, context->Global(), isolate);
3183 3192
3184 PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv); 3193 PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv);
3185 } 3194 }
3186 3195
3187 void TestRunner::DispatchBeforeInstallPromptCallback( 3196 void TestRunnerForSpecificView::DispatchBeforeInstallPromptCallback(
3188 v8::UniquePersistent<v8::Function> callback, 3197 v8::UniquePersistent<v8::Function> callback,
3189 bool canceled) { 3198 bool canceled) {
3190 if (!web_view_)
3191 return;
3192
3193 v8::Isolate* isolate = blink::mainThreadIsolate(); 3199 v8::Isolate* isolate = blink::mainThreadIsolate();
3194 v8::HandleScope handle_scope(isolate); 3200 v8::HandleScope handle_scope(isolate);
3195 3201
3196 v8::Local<v8::Context> context = 3202 v8::Local<v8::Context> context =
3197 web_view_->mainFrame()->mainWorldScriptContext(); 3203 web_view()->mainFrame()->mainWorldScriptContext();
3198 if (context.IsEmpty()) 3204 if (context.IsEmpty())
3199 return; 3205 return;
3200 3206
3201 v8::Context::Scope context_scope(context); 3207 v8::Context::Scope context_scope(context);
3202 v8::Local<v8::Value> arg; 3208 v8::Local<v8::Value> arg;
3203 arg = v8::Boolean::New(isolate, canceled); 3209 arg = v8::Boolean::New(isolate, canceled);
3204 3210
3205 PostV8CallbackWithArgs(std::move(callback), 1, &arg); 3211 PostV8CallbackWithArgs(std::move(callback), 1, &arg);
3206 } 3212 }
3207 3213
3208 void TestRunner::GetBluetoothManualChooserEventsCallback( 3214 void TestRunnerForSpecificView::GetBluetoothManualChooserEventsCallback(
3209 v8::UniquePersistent<v8::Function> callback, 3215 v8::UniquePersistent<v8::Function> callback,
3210 const std::vector<std::string>& events) { 3216 const std::vector<std::string>& events) {
3211 if (!web_view_)
3212 return;
3213
3214 // Build the V8 context. 3217 // Build the V8 context.
3215 v8::Isolate* isolate = blink::mainThreadIsolate(); 3218 v8::Isolate* isolate = blink::mainThreadIsolate();
3216 v8::HandleScope handle_scope(isolate); 3219 v8::HandleScope handle_scope(isolate);
3217 v8::Local<v8::Context> context = 3220 v8::Local<v8::Context> context =
3218 web_view_->mainFrame()->mainWorldScriptContext(); 3221 web_view()->mainFrame()->mainWorldScriptContext();
3219 if (context.IsEmpty()) 3222 if (context.IsEmpty())
3220 return; 3223 return;
3221 v8::Context::Scope context_scope(context); 3224 v8::Context::Scope context_scope(context);
3222 3225
3223 // Convert the argument. 3226 // Convert the argument.
3224 v8::Local<v8::Value> arg; 3227 v8::Local<v8::Value> arg;
3225 if (!gin::TryConvertToV8(isolate, events, &arg)) 3228 if (!gin::TryConvertToV8(isolate, events, &arg))
3226 return; 3229 return;
3227 3230
3228 // Call the callback. 3231 // Call the callback.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 pointer_lock_planned_result_ = PointerLockWillSucceed; 3287 pointer_lock_planned_result_ = PointerLockWillSucceed;
3285 } 3288 }
3286 3289
3287 void TestRunner::DidLosePointerLockInternal() { 3290 void TestRunner::DidLosePointerLockInternal() {
3288 bool was_locked = pointer_locked_; 3291 bool was_locked = pointer_locked_;
3289 pointer_locked_ = false; 3292 pointer_locked_ = false;
3290 if (was_locked) 3293 if (was_locked)
3291 web_view_->didLosePointerLock(); 3294 web_view_->didLosePointerLock();
3292 } 3295 }
3293 3296
3297 TestRunnerForSpecificView::TestRunnerForSpecificView(
3298 WebTestProxyBase* web_test_proxy_base)
3299 : web_test_proxy_base_(web_test_proxy_base), weak_factory_(this) {}
3300
3301 TestRunnerForSpecificView::~TestRunnerForSpecificView() {}
3302
3303 void TestRunnerForSpecificView::Install(blink::WebLocalFrame* frame) {
3304 web_test_proxy_base_->test_interfaces()->GetTestRunner()->Install(
3305 frame, weak_factory_.GetWeakPtr());
3306 }
3307
3308 void TestRunnerForSpecificView::SetViewSourceForFrame(const std::string& name,
3309 bool enabled) {
3310 WebFrame* target_frame =
3311 web_view()->findFrameByName(WebString::fromUTF8(name));
3312 if (target_frame)
3313 target_frame->enableViewSourceMode(enabled);
3314 }
3315
3316 blink::WebView* TestRunnerForSpecificView::web_view() {
3317 return web_test_proxy_base_->web_view();
3318 }
3319
3320 WebTestDelegate* TestRunnerForSpecificView::delegate() {
3321 return web_test_proxy_base_->delegate();
3322 }
3323
3294 } // namespace test_runner 3324 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698