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

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

Issue 2655143002: Drop replacesCurrentHistoryItem, NavigationType (Closed)
Patch Set: More compile fixes Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/web_frame_test_client.h" 5 #include "components/test_runner/web_frame_test_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #else 129 #else
130 pos = 0; 130 pos = 0;
131 #endif 131 #endif
132 } 132 }
133 std::string filename = url.substr(pos + 1); 133 std::string filename = url.substr(pos + 1);
134 if (filename.empty()) 134 if (filename.empty())
135 return "file:"; // A WebKit test has this in its expected output. 135 return "file:"; // A WebKit test has this in its expected output.
136 return filename; 136 return filename;
137 } 137 }
138 138
139 // WebNavigationType debugging strings taken from PolicyDelegate.mm.
140 const char* kLinkClickedString = "link clicked";
141 const char* kFormSubmittedString = "form submitted";
142 const char* kBackForwardString = "back/forward";
143 const char* kReloadString = "reload";
144 const char* kFormResubmittedString = "form resubmitted";
145 const char* kOtherString = "other";
146 const char* kIllegalString = "illegal value";
147
148 // Get a debugging string from a WebNavigationType.
149 const char* WebNavigationTypeToString(blink::WebNavigationType type) {
150 switch (type) {
151 case blink::WebNavigationTypeLinkClicked:
152 return kLinkClickedString;
153 case blink::WebNavigationTypeFormSubmitted:
154 return kFormSubmittedString;
155 case blink::WebNavigationTypeBackForward:
156 return kBackForwardString;
157 case blink::WebNavigationTypeReload:
158 return kReloadString;
159 case blink::WebNavigationTypeFormResubmitted:
160 return kFormResubmittedString;
161 case blink::WebNavigationTypeOther:
162 return kOtherString;
163 }
164 return kIllegalString;
165 }
166
167 } // namespace 139 } // namespace
168 140
169 WebFrameTestClient::WebFrameTestClient( 141 WebFrameTestClient::WebFrameTestClient(
170 WebTestDelegate* delegate, 142 WebTestDelegate* delegate,
171 WebViewTestProxyBase* web_view_test_proxy_base, 143 WebViewTestProxyBase* web_view_test_proxy_base,
172 WebFrameTestProxyBase* web_frame_test_proxy_base) 144 WebFrameTestProxyBase* web_frame_test_proxy_base)
173 : delegate_(delegate), 145 : delegate_(delegate),
174 web_view_test_proxy_base_(web_view_test_proxy_base), 146 web_view_test_proxy_base_(web_view_test_proxy_base),
175 web_frame_test_proxy_base_(web_frame_test_proxy_base) { 147 web_frame_test_proxy_base_(web_frame_test_proxy_base) {
176 DCHECK(delegate_); 148 DCHECK(delegate_);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 356 }
385 357
386 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() { 358 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() {
387 return test_runner()->getMockWebUserMediaClient(); 359 return test_runner()->getMockWebUserMediaClient();
388 } 360 }
389 361
390 void WebFrameTestClient::loadURLExternally( 362 void WebFrameTestClient::loadURLExternally(
391 const blink::WebURLRequest& request, 363 const blink::WebURLRequest& request,
392 blink::WebNavigationPolicy policy, 364 blink::WebNavigationPolicy policy,
393 const blink::WebString& suggested_name, 365 const blink::WebString& suggested_name,
394 bool replaces_current_history_item) { 366 blink::WebFrameLoadType load_type) {
395 if (test_runner()->shouldWaitUntilExternalURLLoad()) { 367 if (test_runner()->shouldWaitUntilExternalURLLoad()) {
396 if (policy == blink::WebNavigationPolicyDownload) { 368 if (policy == blink::WebNavigationPolicyDownload) {
397 delegate_->PrintMessage( 369 delegate_->PrintMessage(
398 std::string("Downloading URL with suggested filename \"") + 370 std::string("Downloading URL with suggested filename \"") +
399 suggested_name.utf8() + "\"\n"); 371 suggested_name.utf8() + "\"\n");
400 } else { 372 } else {
401 delegate_->PrintMessage(std::string("Loading URL externally - \"") + 373 delegate_->PrintMessage(std::string("Loading URL externally - \"") +
402 URLDescription(request.url()) + "\"\n"); 374 URLDescription(request.url()) + "\"\n");
403 } 375 }
404 delegate_->TestFinished(); 376 delegate_->TestFinished();
405 } 377 }
406 } 378 }
407 379
408 void WebFrameTestClient::loadErrorPage(int reason) { 380 void WebFrameTestClient::loadErrorPage(int reason) {
409 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 381 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
410 delegate_->PrintMessage(base::StringPrintf( 382 delegate_->PrintMessage(base::StringPrintf(
411 "- loadErrorPage: %s\n", net::ErrorToString(reason).c_str())); 383 "- loadErrorPage: %s\n", net::ErrorToString(reason).c_str()));
412 } 384 }
413 } 385 }
414 386
415 void WebFrameTestClient::didStartProvisionalLoad(blink::WebLocalFrame* frame) { 387 void WebFrameTestClient::didStartProvisionalLoad(
388 blink::WebDataSource* data_source,
389 blink::WebFrameLoadType load_type) {
390 blink::WebFrame* frame = web_frame_test_proxy_base_->web_frame();
416 test_runner()->tryToSetTopLoadingFrame(frame); 391 test_runner()->tryToSetTopLoadingFrame(frame);
417 392
418 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 393 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
419 PrintFrameDescription(delegate_, frame); 394 PrintFrameDescription(delegate_, frame);
420 delegate_->PrintMessage(" - didStartProvisionalLoadForFrame\n"); 395 delegate_->PrintMessage(" - didStartProvisionalLoadForFrame\n");
421 } 396 }
422 397
423 if (test_runner()->shouldDumpUserGestureInFrameLoadCallbacks()) { 398 if (test_runner()->shouldDumpUserGestureInFrameLoadCallbacks()) {
424 PrintFrameuserGestureStatus(delegate_, frame, 399 PrintFrameuserGestureStatus(delegate_, frame,
425 " - in didStartProvisionalLoadForFrame\n"); 400 " - in didStartProvisionalLoadForFrame\n");
(...skipping 13 matching lines...) Expand all
439 blink::WebLocalFrame* frame, 414 blink::WebLocalFrame* frame,
440 const blink::WebURLError& error, 415 const blink::WebURLError& error,
441 blink::WebHistoryCommitType commit_type) { 416 blink::WebHistoryCommitType commit_type) {
442 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 417 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
443 PrintFrameDescription(delegate_, frame); 418 PrintFrameDescription(delegate_, frame);
444 delegate_->PrintMessage(" - didFailProvisionalLoadWithError\n"); 419 delegate_->PrintMessage(" - didFailProvisionalLoadWithError\n");
445 } 420 }
446 } 421 }
447 422
448 void WebFrameTestClient::didCommitProvisionalLoad( 423 void WebFrameTestClient::didCommitProvisionalLoad(
449 blink::WebLocalFrame* frame, 424 blink::WebDataSource* data_source,
425 blink::WebFrameLoadType load_type,
450 const blink::WebHistoryItem& history_item, 426 const blink::WebHistoryItem& history_item,
451 blink::WebHistoryCommitType history_type) { 427 blink::WebHistoryCommitType history_type) {
452 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 428 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
453 PrintFrameDescription(delegate_, frame); 429 PrintFrameDescription(delegate_, web_frame_test_proxy_base_->web_frame());
454 delegate_->PrintMessage(" - didCommitLoadForFrame\n"); 430 delegate_->PrintMessage(" - didCommitLoadForFrame\n");
455 } 431 }
456 } 432 }
457 433
458 void WebFrameTestClient::didReceiveTitle(blink::WebLocalFrame* frame, 434 void WebFrameTestClient::didReceiveTitle(blink::WebLocalFrame* frame,
459 const blink::WebString& title, 435 const blink::WebString& title,
460 blink::WebTextDirection direction) { 436 blink::WebTextDirection direction) {
461 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 437 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
462 PrintFrameDescription(delegate_, frame); 438 PrintFrameDescription(delegate_, frame);
463 delegate_->PrintMessage(std::string(" - didReceiveTitle: ") + title.utf8() + 439 delegate_->PrintMessage(std::string(" - didReceiveTitle: ") + title.utf8() +
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 477 }
502 478
503 void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) { 479 void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) {
504 if (test_runner()->shouldDumpFrameLoadCallbacks()) { 480 if (test_runner()->shouldDumpFrameLoadCallbacks()) {
505 PrintFrameDescription(delegate_, frame); 481 PrintFrameDescription(delegate_, frame);
506 delegate_->PrintMessage(" - didFinishLoadForFrame\n"); 482 delegate_->PrintMessage(" - didFinishLoadForFrame\n");
507 } 483 }
508 } 484 }
509 485
510 void WebFrameTestClient::didNavigateWithinPage( 486 void WebFrameTestClient::didNavigateWithinPage(
511 blink::WebLocalFrame* frame, 487 blink::WebDataSource* data_source,
488 blink::WebFrameLoadType load_type,
512 const blink::WebHistoryItem& history_item, 489 const blink::WebHistoryItem& history_item,
513 blink::WebHistoryCommitType commit_type, 490 blink::WebHistoryCommitType commit_type,
514 bool contentInitiated) { 491 bool contentInitiated) {
515 test_runner()->OnNavigationEnd(); 492 test_runner()->OnNavigationEnd();
516 } 493 }
517 494
518 void WebFrameTestClient::didStartLoading(bool to_different_document) { 495 void WebFrameTestClient::didStartLoading(bool to_different_document) {
519 test_runner()->OnNavigationBegin(web_frame_test_proxy_base_->web_frame()); 496 test_runner()->OnNavigationBegin(web_frame_test_proxy_base_->web_frame());
520 } 497 }
521 498
522 void WebFrameTestClient::didStopLoading() { 499 void WebFrameTestClient::didStopLoading() {
523 test_runner()->tryToClearTopLoadingFrame( 500 test_runner()->tryToClearTopLoadingFrame(
524 web_frame_test_proxy_base_->web_frame()); 501 web_frame_test_proxy_base_->web_frame());
525 } 502 }
526 503
527 void WebFrameTestClient::didDetectXSS(const blink::WebURL& insecure_url, 504 void WebFrameTestClient::didDetectXSS(const blink::WebURL& insecure_url,
528 bool did_block_entire_page) { 505 bool did_block_entire_page) {
529 if (test_runner()->shouldDumpFrameLoadCallbacks()) 506 if (test_runner()->shouldDumpFrameLoadCallbacks())
530 delegate_->PrintMessage("didDetectXSS\n"); 507 delegate_->PrintMessage("didDetectXSS\n");
531 } 508 }
532 509
533 void WebFrameTestClient::didDispatchPingLoader(const blink::WebURL& url) { 510 void WebFrameTestClient::didDispatchPingLoader(const blink::WebURL& url) {
534 if (test_runner()->shouldDumpPingLoaderCallbacks()) 511 if (test_runner()->shouldDumpPingLoaderCallbacks())
535 delegate_->PrintMessage(std::string("PingLoader dispatched to '") + 512 delegate_->PrintMessage(std::string("PingLoader dispatched to '") +
536 URLDescription(url).c_str() + "'.\n"); 513 URLDescription(url).c_str() + "'.\n");
537 } 514 }
538 515
539 void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, 516 void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame,
540 blink::WebURLRequest& request) { 517 blink::WebURLRequest& request,
518 blink::WebFrameLoadType load_type) {
541 // PlzNavigate 519 // PlzNavigate
542 // Navigation requests initiated by the renderer will have been logged when 520 // Navigation requests initiated by the renderer will have been logged when
543 // the navigation was sent to the browser. Please see 521 // the navigation was sent to the browser. Please see
544 // the RenderFrameImpl::BeginNavigation() function. 522 // the RenderFrameImpl::BeginNavigation() function.
545 if (delegate_->IsNavigationInitiatedByRenderer(request)) 523 if (delegate_->IsNavigationInitiatedByRenderer(request))
546 return; 524 return;
547 // Need to use GURL for host() and SchemeIs() 525 // Need to use GURL for host() and SchemeIs()
548 GURL url = request.url(); 526 GURL url = request.url();
549 std::string request_url = url.possibly_invalid_spec(); 527 std::string request_url = url.possibly_invalid_spec();
550 528
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 delegate_->PrintMessage("Default policy for navigation to '" + 639 delegate_->PrintMessage("Default policy for navigation to '" +
662 URLDescription(info.urlRequest.url()) + "' is '" + 640 URLDescription(info.urlRequest.url()) + "' is '" +
663 WebNavigationPolicyToString(info.defaultPolicy) + 641 WebNavigationPolicyToString(info.defaultPolicy) +
664 "'\n"); 642 "'\n");
665 } 643 }
666 644
667 blink::WebNavigationPolicy result; 645 blink::WebNavigationPolicy result;
668 if (!test_runner()->policyDelegateEnabled()) 646 if (!test_runner()->policyDelegateEnabled())
669 return info.defaultPolicy; 647 return info.defaultPolicy;
670 648
671 delegate_->PrintMessage( 649 delegate_->PrintMessage(std::string("Policy delegate: attempt to load ") +
672 std::string("Policy delegate: attempt to load ") + 650 URLDescription(info.urlRequest.url()) + "\n");
673 URLDescription(info.urlRequest.url()) + " with navigation type '" +
674 WebNavigationTypeToString(info.navigationType) + "'\n");
675 if (test_runner()->policyDelegateIsPermissive()) 651 if (test_runner()->policyDelegateIsPermissive())
676 result = blink::WebNavigationPolicyCurrentTab; 652 result = blink::WebNavigationPolicyCurrentTab;
677 else 653 else
678 result = blink::WebNavigationPolicyIgnore; 654 result = blink::WebNavigationPolicyIgnore;
679 655
680 if (test_runner()->policyDelegateShouldNotifyDone()) { 656 if (test_runner()->policyDelegateShouldNotifyDone()) {
681 test_runner()->policyDelegateDone(); 657 test_runner()->policyDelegateDone();
682 result = blink::WebNavigationPolicyIgnore; 658 result = blink::WebNavigationPolicyIgnore;
683 } 659 }
684 660
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 blink::WebEffectiveConnectionType 692 blink::WebEffectiveConnectionType
717 WebFrameTestClient::getEffectiveConnectionType() { 693 WebFrameTestClient::getEffectiveConnectionType() {
718 return test_runner()->effective_connection_type(); 694 return test_runner()->effective_connection_type();
719 } 695 }
720 696
721 TestRunner* WebFrameTestClient::test_runner() { 697 TestRunner* WebFrameTestClient::test_runner() {
722 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); 698 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner();
723 } 699 }
724 700
725 } // namespace test_runner 701 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/web_frame_test_client.h ('k') | components/test_runner/web_frame_test_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698