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

Side by Side Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 458723002: TestInterfaces to chromium c++ style, rename methods and remove un-used header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 "content/shell/renderer/test_runner/web_test_proxy.h" 5 #include "content/shell/renderer/test_runner/web_test_proxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "content/shell/renderer/test_runner/TestInterfaces.h"
14 #include "content/shell/renderer/test_runner/TestPlugin.h" 13 #include "content/shell/renderer/test_runner/TestPlugin.h"
15 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
16 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" 15 #include "content/shell/renderer/test_runner/WebTestInterfaces.h"
17 #include "content/shell/renderer/test_runner/accessibility_controller.h" 16 #include "content/shell/renderer/test_runner/accessibility_controller.h"
18 #include "content/shell/renderer/test_runner/event_sender.h" 17 #include "content/shell/renderer/test_runner/event_sender.h"
19 #include "content/shell/renderer/test_runner/mock_color_chooser.h" 18 #include "content/shell/renderer/test_runner/mock_color_chooser.h"
20 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" 19 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
21 #include "content/shell/renderer/test_runner/mock_web_push_client.h" 20 #include "content/shell/renderer/test_runner/mock_web_push_client.h"
22 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" 21 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h"
23 #include "content/shell/renderer/test_runner/mock_web_user_media_client.h" 22 #include "content/shell/renderer/test_runner/mock_web_user_media_client.h"
24 #include "content/shell/renderer/test_runner/spell_check_client.h" 23 #include "content/shell/renderer/test_runner/spell_check_client.h"
24 #include "content/shell/renderer/test_runner/test_interfaces.h"
25 #include "content/shell/renderer/test_runner/test_runner.h" 25 #include "content/shell/renderer/test_runner/test_runner.h"
26 #include "content/shell/renderer/test_runner/web_test_runner.h" 26 #include "content/shell/renderer/test_runner/web_test_runner.h"
27 // FIXME: Including platform_canvas.h here is a layering violation. 27 // FIXME: Including platform_canvas.h here is a layering violation.
28 #include "skia/ext/platform_canvas.h" 28 #include "skia/ext/platform_canvas.h"
29 #include "third_party/WebKit/public/platform/Platform.h" 29 #include "third_party/WebKit/public/platform/Platform.h"
30 #include "third_party/WebKit/public/platform/WebCString.h" 30 #include "third_party/WebKit/public/platform/WebCString.h"
31 #include "third_party/WebKit/public/platform/WebClipboard.h" 31 #include "third_party/WebKit/public/platform/WebClipboard.h"
32 #include "third_party/WebKit/public/platform/WebURLError.h" 32 #include "third_party/WebKit/public/platform/WebURLError.h"
33 #include "third_party/WebKit/public/platform/WebURLRequest.h" 33 #include "third_party/WebKit/public/platform/WebURLRequest.h"
34 #include "third_party/WebKit/public/platform/WebURLResponse.h" 34 #include "third_party/WebKit/public/platform/WebURLResponse.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return result; 292 return result;
293 for (blink::WebFrame* child = frame->firstChild(); child; 293 for (blink::WebFrame* child = frame->firstChild(); child;
294 child = child->nextSibling()) 294 child = child->nextSibling())
295 result += DumpFrameScrollPosition(child, recursive); 295 result += DumpFrameScrollPosition(child, recursive);
296 return result; 296 return result;
297 } 297 }
298 298
299 std::string DumpAllBackForwardLists(TestInterfaces* interfaces, 299 std::string DumpAllBackForwardLists(TestInterfaces* interfaces,
300 WebTestDelegate* delegate) { 300 WebTestDelegate* delegate) {
301 std::string result; 301 std::string result;
302 const std::vector<WebTestProxyBase*>& window_list = interfaces->windowList(); 302 const std::vector<WebTestProxyBase*>& window_list = interfaces->WindowList();
303 for (size_t i = 0; i < window_list.size(); ++i) 303 for (size_t i = 0; i < window_list.size(); ++i)
304 result.append(delegate->dumpHistoryForWindow(window_list.at(i))); 304 result.append(delegate->dumpHistoryForWindow(window_list.at(i)));
305 return result; 305 return result;
306 } 306 }
307 } 307 }
308 308
309 WebTestProxyBase::WebTestProxyBase() 309 WebTestProxyBase::WebTestProxyBase()
310 : test_interfaces_(NULL), 310 : test_interfaces_(NULL),
311 delegate_(NULL), 311 delegate_(NULL),
312 web_widget_(NULL), 312 web_widget_(NULL),
313 spellcheck_(new SpellCheckClient(this)), 313 spellcheck_(new SpellCheckClient(this)),
314 chooser_count_(0) { 314 chooser_count_(0) {
315 Reset(); 315 Reset();
316 } 316 }
317 317
318 WebTestProxyBase::~WebTestProxyBase() { 318 WebTestProxyBase::~WebTestProxyBase() {
319 test_interfaces_->windowClosed(this); 319 test_interfaces_->WindowClosed(this);
320 // Tests must wait for readback requests to finish before notifying that 320 // Tests must wait for readback requests to finish before notifying that
321 // they are done. 321 // they are done.
322 CHECK_EQ(0u, composite_and_readback_callbacks_.size()); 322 CHECK_EQ(0u, composite_and_readback_callbacks_.size());
323 } 323 }
324 324
325 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) { 325 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) {
326 test_interfaces_ = interfaces->testInterfaces(); 326 test_interfaces_ = interfaces->testInterfaces();
327 test_interfaces_->windowOpened(this); 327 test_interfaces_->WindowOpened(this);
328 } 328 }
329 329
330 void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) { 330 void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) {
331 delegate_ = delegate; 331 delegate_ = delegate;
332 spellcheck_->SetDelegate(delegate); 332 spellcheck_->SetDelegate(delegate);
333 if (speech_recognizer_.get()) 333 if (speech_recognizer_.get())
334 speech_recognizer_->SetDelegate(delegate); 334 speech_recognizer_->SetDelegate(delegate);
335 } 335 }
336 336
337 blink::WebView* WebTestProxyBase::GetWebView() const { 337 blink::WebView* WebTestProxyBase::GetWebView() const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 const blink::WebString& sub_message, 376 const blink::WebString& sub_message,
377 blink::WebTextDirection hint) { 377 blink::WebTextDirection hint) {
378 delegate_->printMessage( 378 delegate_->printMessage(
379 std::string("ValidationMessageClient: main-message=") + 379 std::string("ValidationMessageClient: main-message=") +
380 std::string(message.utf8()) + " sub-message=" + 380 std::string(message.utf8()) + " sub-message=" +
381 std::string(sub_message.utf8()) + "\n"); 381 std::string(sub_message.utf8()) + "\n");
382 } 382 }
383 383
384 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) { 384 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) {
385 bool should_dump_custom_text = 385 bool should_dump_custom_text =
386 test_interfaces_->testRunner()->shouldDumpAsCustomText(); 386 test_interfaces_->GetTestRunner()->shouldDumpAsCustomText();
387 bool should_dump_as_text = test_interfaces_->testRunner()->shouldDumpAsText(); 387 bool should_dump_as_text =
388 test_interfaces_->GetTestRunner()->shouldDumpAsText();
388 bool should_dump_as_markup = 389 bool should_dump_as_markup =
389 test_interfaces_->testRunner()->shouldDumpAsMarkup(); 390 test_interfaces_->GetTestRunner()->shouldDumpAsMarkup();
390 bool should_dump_as_printed = test_interfaces_->testRunner()->isPrinting(); 391 bool should_dump_as_printed = test_interfaces_->GetTestRunner()->isPrinting();
391 blink::WebFrame* frame = GetWebView()->mainFrame(); 392 blink::WebFrame* frame = GetWebView()->mainFrame();
392 std::string data_utf8; 393 std::string data_utf8;
393 if (should_dump_custom_text) { 394 if (should_dump_custom_text) {
394 // Append a newline for the test driver. 395 // Append a newline for the test driver.
395 data_utf8 = test_interfaces_->testRunner()->customDumpText() + "\n"; 396 data_utf8 = test_interfaces_->GetTestRunner()->customDumpText() + "\n";
396 } else if (should_dump_as_text) { 397 } else if (should_dump_as_text) {
397 bool recursive = 398 bool recursive =
398 test_interfaces_->testRunner()->shouldDumpChildFramesAsText(); 399 test_interfaces_->GetTestRunner()->shouldDumpChildFramesAsText();
399 data_utf8 = should_dump_as_printed ? 400 data_utf8 = should_dump_as_printed ?
400 DumpFramesAsPrintedText(frame, recursive) : 401 DumpFramesAsPrintedText(frame, recursive) :
401 DumpFramesAsText(frame, recursive); 402 DumpFramesAsText(frame, recursive);
402 } else if (should_dump_as_markup) { 403 } else if (should_dump_as_markup) {
403 bool recursive = 404 bool recursive =
404 test_interfaces_->testRunner()->shouldDumpChildFramesAsMarkup(); 405 test_interfaces_->GetTestRunner()->shouldDumpChildFramesAsMarkup();
405 // Append a newline for the test driver. 406 // Append a newline for the test driver.
406 data_utf8 = DumpFramesAsMarkup(frame, recursive); 407 data_utf8 = DumpFramesAsMarkup(frame, recursive);
407 } else { 408 } else {
408 bool recursive = 409 bool recursive = test_interfaces_->GetTestRunner()
409 test_interfaces_->testRunner()->shouldDumpChildFrameScrollPositions(); 410 ->shouldDumpChildFrameScrollPositions();
410 blink::WebFrame::RenderAsTextControls render_text_behavior = 411 blink::WebFrame::RenderAsTextControls render_text_behavior =
411 blink::WebFrame::RenderAsTextNormal; 412 blink::WebFrame::RenderAsTextNormal;
412 if (should_dump_as_printed) 413 if (should_dump_as_printed)
413 render_text_behavior |= blink::WebFrame::RenderAsTextPrinting; 414 render_text_behavior |= blink::WebFrame::RenderAsTextPrinting;
414 if (debug_render_tree) 415 if (debug_render_tree)
415 render_text_behavior |= blink::WebFrame::RenderAsTextDebug; 416 render_text_behavior |= blink::WebFrame::RenderAsTextDebug;
416 data_utf8 = frame->renderTreeAsText(render_text_behavior).utf8(); 417 data_utf8 = frame->renderTreeAsText(render_text_behavior).utf8();
417 data_utf8 += DumpFrameScrollPosition(frame, recursive); 418 data_utf8 += DumpFrameScrollPosition(frame, recursive);
418 } 419 }
419 420
420 if (test_interfaces_->testRunner()->ShouldDumpBackForwardList()) 421 if (test_interfaces_->GetTestRunner()->ShouldDumpBackForwardList())
421 data_utf8 += DumpAllBackForwardLists(test_interfaces_, delegate_); 422 data_utf8 += DumpAllBackForwardLists(test_interfaces_, delegate_);
422 423
423 return data_utf8; 424 return data_utf8;
424 } 425 }
425 426
426 void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) { 427 void WebTestProxyBase::DrawSelectionRect(SkCanvas* canvas) {
427 // See if we need to draw the selection bounds rect. Selection bounds 428 // See if we need to draw the selection bounds rect. Selection bounds
428 // rect is the rect enclosing the (possibly transformed) selection. 429 // rect is the rect enclosing the (possibly transformed) selection.
429 // The rect should be drawn after everything is laid out and painted. 430 // The rect should be drawn after everything is laid out and painted.
430 if (!test_interfaces_->testRunner()->shouldDumpSelectionRect()) 431 if (!test_interfaces_->GetTestRunner()->shouldDumpSelectionRect())
431 return; 432 return;
432 // If there is a selection rect - draw a red 1px border enclosing rect 433 // If there is a selection rect - draw a red 1px border enclosing rect
433 blink::WebRect wr = GetWebView()->mainFrame()->selectionBoundsRect(); 434 blink::WebRect wr = GetWebView()->mainFrame()->selectionBoundsRect();
434 if (wr.isEmpty()) 435 if (wr.isEmpty())
435 return; 436 return;
436 // Render a red rectangle bounding selection rect 437 // Render a red rectangle bounding selection rect
437 SkPaint paint; 438 SkPaint paint;
438 paint.setColor(0xFFFF0000); // Fully opaque red 439 paint.setColor(0xFFFF0000); // Fully opaque red
439 paint.setStyle(SkPaint::kStroke_Style); 440 paint.setStyle(SkPaint::kStroke_Style);
440 paint.setFlags(SkPaint::kAntiAlias_Flag); 441 paint.setFlags(SkPaint::kAntiAlias_Flag);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 callback.Run(bitmap); 515 callback.Run(bitmap);
515 } 516 }
516 517
517 void WebTestProxyBase::CapturePixelsAsync( 518 void WebTestProxyBase::CapturePixelsAsync(
518 const base::Callback<void(const SkBitmap&)>& callback) { 519 const base::Callback<void(const SkBitmap&)>& callback) {
519 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); 520 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync");
520 521
521 DCHECK(web_widget_->isAcceleratedCompositingActive()); 522 DCHECK(web_widget_->isAcceleratedCompositingActive());
522 DCHECK(!callback.is_null()); 523 DCHECK(!callback.is_null());
523 524
524 if (test_interfaces_->testRunner()->isPrinting()) { 525 if (test_interfaces_->GetTestRunner()->isPrinting()) {
525 base::MessageLoopProxy::current()->PostTask( 526 base::MessageLoopProxy::current()->PostTask(
526 FROM_HERE, 527 FROM_HERE,
527 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, 528 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting,
528 base::Unretained(this), 529 base::Unretained(this),
529 callback)); 530 callback));
530 return; 531 return;
531 } 532 }
532 533
533 composite_and_readback_callbacks_.push_back(callback); 534 composite_and_readback_callbacks_.push_back(callback);
534 web_widget_->compositeAndReadbackAsync(this); 535 web_widget_->compositeAndReadbackAsync(this);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 583
583 MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() { 584 MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() {
584 if (!speech_recognizer_.get()) { 585 if (!speech_recognizer_.get()) {
585 speech_recognizer_.reset(new MockWebSpeechRecognizer()); 586 speech_recognizer_.reset(new MockWebSpeechRecognizer());
586 speech_recognizer_->SetDelegate(delegate_); 587 speech_recognizer_->SetDelegate(delegate_);
587 } 588 }
588 return speech_recognizer_.get(); 589 return speech_recognizer_.get();
589 } 590 }
590 591
591 void WebTestProxyBase::ScheduleAnimation() { 592 void WebTestProxyBase::ScheduleAnimation() {
592 if (!test_interfaces_->testRunner()->TestIsRunning()) 593 if (!test_interfaces_->GetTestRunner()->TestIsRunning())
593 return; 594 return;
594 595
595 if (!animate_scheduled_) { 596 if (!animate_scheduled_) {
596 animate_scheduled_ = true; 597 animate_scheduled_ = true;
597 delegate_->postDelayedTask( 598 delegate_->postDelayedTask(
598 new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1); 599 new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1);
599 } 600 }
600 } 601 }
601 602
602 void WebTestProxyBase::AnimateNow() { 603 void WebTestProxyBase::AnimateNow() {
603 if (animate_scheduled_) { 604 if (animate_scheduled_) {
604 animate_scheduled_ = false; 605 animate_scheduled_ = false;
605 web_widget_->animate(0.0); 606 web_widget_->animate(0.0);
606 web_widget_->layout(); 607 web_widget_->layout();
607 } 608 }
608 } 609 }
609 610
610 void WebTestProxyBase::PostAccessibilityEvent(const blink::WebAXObject& obj, 611 void WebTestProxyBase::PostAccessibilityEvent(const blink::WebAXObject& obj,
611 blink::WebAXEvent event) { 612 blink::WebAXEvent event) {
612 // Only hook the accessibility events occured during the test run. 613 // Only hook the accessibility events occured during the test run.
613 // This check prevents false positives in WebLeakDetector. 614 // This check prevents false positives in WebLeakDetector.
614 // The pending tasks in browser/renderer message queue may trigger 615 // The pending tasks in browser/renderer message queue may trigger
615 // accessibility events, 616 // accessibility events,
616 // and AccessibilityController will hold on to their target nodes if we don't 617 // and AccessibilityController will hold on to their target nodes if we don't
617 // ignore them here. 618 // ignore them here.
618 if (!test_interfaces_->testRunner()->TestIsRunning()) 619 if (!test_interfaces_->GetTestRunner()->TestIsRunning())
619 return; 620 return;
620 621
621 if (event == blink::WebAXEventFocus) 622 if (event == blink::WebAXEventFocus)
622 test_interfaces_->accessibilityController()->SetFocusedElement(obj); 623 test_interfaces_->GetAccessibilityController()->SetFocusedElement(obj);
623 624
624 const char* event_name = NULL; 625 const char* event_name = NULL;
625 switch (event) { 626 switch (event) {
626 case blink::WebAXEventActiveDescendantChanged: 627 case blink::WebAXEventActiveDescendantChanged:
627 event_name = "ActiveDescendantChanged"; 628 event_name = "ActiveDescendantChanged";
628 break; 629 break;
629 case blink::WebAXEventAlert: 630 case blink::WebAXEventAlert:
630 event_name = "Alert"; 631 event_name = "Alert";
631 break; 632 break;
632 case blink::WebAXEventAriaAttributeChanged: 633 case blink::WebAXEventAriaAttributeChanged:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 event_name = "TextRemoved"; 706 event_name = "TextRemoved";
706 break; 707 break;
707 case blink::WebAXEventValueChanged: 708 case blink::WebAXEventValueChanged:
708 event_name = "ValueChanged"; 709 event_name = "ValueChanged";
709 break; 710 break;
710 default: 711 default:
711 event_name = "Unknown"; 712 event_name = "Unknown";
712 break; 713 break;
713 } 714 }
714 715
715 test_interfaces_->accessibilityController()->NotificationReceived(obj, 716 test_interfaces_->GetAccessibilityController()->NotificationReceived(
716 event_name); 717 obj, event_name);
717 718
718 if (test_interfaces_->accessibilityController() 719 if (test_interfaces_->GetAccessibilityController()
719 ->ShouldLogAccessibilityEvents()) { 720 ->ShouldLogAccessibilityEvents()) {
720 std::string message("AccessibilityNotification - "); 721 std::string message("AccessibilityNotification - ");
721 message += event_name; 722 message += event_name;
722 723
723 blink::WebNode node = obj.node(); 724 blink::WebNode node = obj.node();
724 if (!node.isNull() && node.isElementNode()) { 725 if (!node.isNull() && node.isElementNode()) {
725 blink::WebElement element = node.to<blink::WebElement>(); 726 blink::WebElement element = node.to<blink::WebElement>();
726 if (element.hasAttribute("id")) { 727 if (element.hasAttribute("id")) {
727 message += " - id:"; 728 message += " - id:";
728 message += element.getAttribute("id").utf8().data(); 729 message += element.getAttribute("id").utf8().data();
729 } 730 }
730 } 731 }
731 732
732 delegate_->printMessage(message + "\n"); 733 delegate_->printMessage(message + "\n");
733 } 734 }
734 } 735 }
735 736
736 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame, 737 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame,
737 const blink::WebDragData& data, 738 const blink::WebDragData& data,
738 blink::WebDragOperationsMask mask, 739 blink::WebDragOperationsMask mask,
739 const blink::WebImage& image, 740 const blink::WebImage& image,
740 const blink::WebPoint& point) { 741 const blink::WebPoint& point) {
741 // When running a test, we need to fake a drag drop operation otherwise 742 // When running a test, we need to fake a drag drop operation otherwise
742 // Windows waits for real mouse events to know when the drag is over. 743 // Windows waits for real mouse events to know when the drag is over.
743 test_interfaces_->eventSender()->DoDragDrop(data, mask); 744 test_interfaces_->GetEventSender()->DoDragDrop(data, mask);
744 } 745 }
745 746
746 // The output from these methods in layout test mode should match that 747 // The output from these methods in layout test mode should match that
747 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. 748 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
748 749
749 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) { 750 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) {
750 if (test_interfaces_->testRunner()->shouldDumpEditingCallbacks()) 751 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks())
751 delegate_->printMessage( 752 delegate_->printMessage(
752 "EDITING DELEGATE: " 753 "EDITING DELEGATE: "
753 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); 754 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n");
754 } 755 }
755 756
756 void WebTestProxyBase::DidChangeContents() { 757 void WebTestProxyBase::DidChangeContents() {
757 if (test_interfaces_->testRunner()->shouldDumpEditingCallbacks()) 758 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks())
758 delegate_->printMessage( 759 delegate_->printMessage(
759 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); 760 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n");
760 } 761 }
761 762
762 bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame, 763 bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame,
763 const blink::WebURLRequest& request, 764 const blink::WebURLRequest& request,
764 const blink::WebWindowFeatures& features, 765 const blink::WebWindowFeatures& features,
765 const blink::WebString& frame_name, 766 const blink::WebString& frame_name,
766 blink::WebNavigationPolicy policy, 767 blink::WebNavigationPolicy policy,
767 bool suppress_opener) { 768 bool suppress_opener) {
768 if (!test_interfaces_->testRunner()->canOpenWindows()) 769 if (!test_interfaces_->GetTestRunner()->canOpenWindows())
769 return false; 770 return false;
770 if (test_interfaces_->testRunner()->shouldDumpCreateView()) 771 if (test_interfaces_->GetTestRunner()->shouldDumpCreateView())
771 delegate_->printMessage(std::string("createView(") + 772 delegate_->printMessage(std::string("createView(") +
772 URLDescription(request.url()) + ")\n"); 773 URLDescription(request.url()) + ")\n");
773 return true; 774 return true;
774 } 775 }
775 776
776 blink::WebPlugin* WebTestProxyBase::CreatePlugin( 777 blink::WebPlugin* WebTestProxyBase::CreatePlugin(
777 blink::WebLocalFrame* frame, 778 blink::WebLocalFrame* frame,
778 const blink::WebPluginParams& params) { 779 const blink::WebPluginParams& params) {
779 if (TestPlugin::isSupportedMimeType(params.mimeType)) 780 if (TestPlugin::isSupportedMimeType(params.mimeType))
780 return TestPlugin::create(frame, params, delegate_); 781 return TestPlugin::create(frame, params, delegate_);
781 return 0; 782 return 0;
782 } 783 }
783 784
784 void WebTestProxyBase::SetStatusText(const blink::WebString& text) { 785 void WebTestProxyBase::SetStatusText(const blink::WebString& text) {
785 if (!test_interfaces_->testRunner()->shouldDumpStatusCallbacks()) 786 if (!test_interfaces_->GetTestRunner()->shouldDumpStatusCallbacks())
786 return; 787 return;
787 delegate_->printMessage( 788 delegate_->printMessage(
788 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") + 789 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") +
789 text.utf8().data() + "\n"); 790 text.utf8().data() + "\n");
790 } 791 }
791 792
792 void WebTestProxyBase::DidStopLoading() { 793 void WebTestProxyBase::DidStopLoading() {
793 if (test_interfaces_->testRunner()->shouldDumpProgressFinishedCallback()) 794 if (test_interfaces_->GetTestRunner()->shouldDumpProgressFinishedCallback())
794 delegate_->printMessage("postProgressFinishedNotification\n"); 795 delegate_->printMessage("postProgressFinishedNotification\n");
795 } 796 }
796 797
797 void WebTestProxyBase::ShowContextMenu( 798 void WebTestProxyBase::ShowContextMenu(
798 blink::WebLocalFrame* frame, 799 blink::WebLocalFrame* frame,
799 const blink::WebContextMenuData& context_menu_data) { 800 const blink::WebContextMenuData& context_menu_data) {
800 test_interfaces_->eventSender()->SetContextMenuData(context_menu_data); 801 test_interfaces_->GetEventSender()->SetContextMenuData(context_menu_data);
801 } 802 }
802 803
803 blink::WebUserMediaClient* WebTestProxyBase::GetUserMediaClient() { 804 blink::WebUserMediaClient* WebTestProxyBase::GetUserMediaClient() {
804 if (!user_media_client_.get()) 805 if (!user_media_client_.get())
805 user_media_client_.reset(new MockWebUserMediaClient(delegate_)); 806 user_media_client_.reset(new MockWebUserMediaClient(delegate_));
806 return user_media_client_.get(); 807 return user_media_client_.get();
807 } 808 }
808 809
809 // Simulate a print by going into print mode and then exit straight away. 810 // Simulate a print by going into print mode and then exit straight away.
810 void WebTestProxyBase::PrintPage(blink::WebLocalFrame* frame) { 811 void WebTestProxyBase::PrintPage(blink::WebLocalFrame* frame) {
811 blink::WebSize page_size_in_pixels = web_widget_->size(); 812 blink::WebSize page_size_in_pixels = web_widget_->size();
812 if (page_size_in_pixels.isEmpty()) 813 if (page_size_in_pixels.isEmpty())
813 return; 814 return;
814 blink::WebPrintParams printParams(page_size_in_pixels); 815 blink::WebPrintParams printParams(page_size_in_pixels);
815 frame->printBegin(printParams); 816 frame->printBegin(printParams);
816 frame->printEnd(); 817 frame->printEnd();
817 } 818 }
818 819
819 blink::WebNotificationPresenter* WebTestProxyBase::GetNotificationPresenter() { 820 blink::WebNotificationPresenter* WebTestProxyBase::GetNotificationPresenter() {
820 return test_interfaces_->testRunner()->notification_presenter(); 821 return test_interfaces_->GetTestRunner()->notification_presenter();
821 } 822 }
822 823
823 blink::WebMIDIClient* WebTestProxyBase::GetWebMIDIClient() { 824 blink::WebMIDIClient* WebTestProxyBase::GetWebMIDIClient() {
824 return GetMIDIClientMock(); 825 return GetMIDIClientMock();
825 } 826 }
826 827
827 blink::WebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizer() { 828 blink::WebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizer() {
828 return GetSpeechRecognizerMock(); 829 return GetSpeechRecognizerMock();
829 } 830 }
830 831
831 bool WebTestProxyBase::RequestPointerLock() { 832 bool WebTestProxyBase::RequestPointerLock() {
832 return test_interfaces_->testRunner()->RequestPointerLock(); 833 return test_interfaces_->GetTestRunner()->RequestPointerLock();
833 } 834 }
834 835
835 void WebTestProxyBase::RequestPointerUnlock() { 836 void WebTestProxyBase::RequestPointerUnlock() {
836 test_interfaces_->testRunner()->RequestPointerUnlock(); 837 test_interfaces_->GetTestRunner()->RequestPointerUnlock();
837 } 838 }
838 839
839 bool WebTestProxyBase::IsPointerLocked() { 840 bool WebTestProxyBase::IsPointerLocked() {
840 return test_interfaces_->testRunner()->isPointerLocked(); 841 return test_interfaces_->GetTestRunner()->isPointerLocked();
841 } 842 }
842 843
843 void WebTestProxyBase::DidFocus() { 844 void WebTestProxyBase::DidFocus() {
844 delegate_->setFocus(this, true); 845 delegate_->setFocus(this, true);
845 } 846 }
846 847
847 void WebTestProxyBase::DidBlur() { 848 void WebTestProxyBase::DidBlur() {
848 delegate_->setFocus(this, false); 849 delegate_->setFocus(this, false);
849 } 850 }
850 851
851 void WebTestProxyBase::SetToolTipText(const blink::WebString& text, 852 void WebTestProxyBase::SetToolTipText(const blink::WebString& text,
852 blink::WebTextDirection direction) { 853 blink::WebTextDirection direction) {
853 test_interfaces_->testRunner()->setToolTipText(text); 854 test_interfaces_->GetTestRunner()->setToolTipText(text);
854 } 855 }
855 856
856 void WebTestProxyBase::DidOpenChooser() { 857 void WebTestProxyBase::DidOpenChooser() {
857 chooser_count_++; 858 chooser_count_++;
858 } 859 }
859 860
860 void WebTestProxyBase::DidCloseChooser() { 861 void WebTestProxyBase::DidCloseChooser() {
861 chooser_count_--; 862 chooser_count_--;
862 } 863 }
863 864
864 bool WebTestProxyBase::IsChooserShown() { 865 bool WebTestProxyBase::IsChooserShown() {
865 return 0 < chooser_count_; 866 return 0 < chooser_count_;
866 } 867 }
867 868
868 void WebTestProxyBase::LoadURLExternally( 869 void WebTestProxyBase::LoadURLExternally(
869 blink::WebLocalFrame* frame, 870 blink::WebLocalFrame* frame,
870 const blink::WebURLRequest& request, 871 const blink::WebURLRequest& request,
871 blink::WebNavigationPolicy policy, 872 blink::WebNavigationPolicy policy,
872 const blink::WebString& suggested_name) { 873 const blink::WebString& suggested_name) {
873 if (test_interfaces_->testRunner()->shouldWaitUntilExternalURLLoad()) { 874 if (test_interfaces_->GetTestRunner()->shouldWaitUntilExternalURLLoad()) {
874 if (policy == blink::WebNavigationPolicyDownload) { 875 if (policy == blink::WebNavigationPolicyDownload) {
875 delegate_->printMessage( 876 delegate_->printMessage(
876 std::string("Downloading URL with suggested filename \"") + 877 std::string("Downloading URL with suggested filename \"") +
877 suggested_name.utf8() + "\"\n"); 878 suggested_name.utf8() + "\"\n");
878 } else { 879 } else {
879 delegate_->printMessage(std::string("Loading URL externally - \"") + 880 delegate_->printMessage(std::string("Loading URL externally - \"") +
880 URLDescription(request.url()) + "\"\n"); 881 URLDescription(request.url()) + "\"\n");
881 } 882 }
882 delegate_->testFinished(); 883 delegate_->testFinished();
883 } 884 }
884 } 885 }
885 886
886 void WebTestProxyBase::DidStartProvisionalLoad(blink::WebLocalFrame* frame) { 887 void WebTestProxyBase::DidStartProvisionalLoad(blink::WebLocalFrame* frame) {
887 if (!test_interfaces_->testRunner()->topLoadingFrame()) 888 if (!test_interfaces_->GetTestRunner()->topLoadingFrame())
888 test_interfaces_->testRunner()->setTopLoadingFrame(frame, false); 889 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, false);
889 890
890 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 891 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
891 PrintFrameDescription(delegate_, frame); 892 PrintFrameDescription(delegate_, frame);
892 delegate_->printMessage(" - didStartProvisionalLoadForFrame\n"); 893 delegate_->printMessage(" - didStartProvisionalLoadForFrame\n");
893 } 894 }
894 895
895 if (test_interfaces_->testRunner() 896 if (test_interfaces_->GetTestRunner()
896 ->shouldDumpUserGestureInFrameLoadCallbacks()) { 897 ->shouldDumpUserGestureInFrameLoadCallbacks()) {
897 PrintFrameuserGestureStatus( 898 PrintFrameuserGestureStatus(
898 delegate_, frame, " - in didStartProvisionalLoadForFrame\n"); 899 delegate_, frame, " - in didStartProvisionalLoadForFrame\n");
899 } 900 }
900 } 901 }
901 902
902 void WebTestProxyBase::DidReceiveServerRedirectForProvisionalLoad( 903 void WebTestProxyBase::DidReceiveServerRedirectForProvisionalLoad(
903 blink::WebLocalFrame* frame) { 904 blink::WebLocalFrame* frame) {
904 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 905 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
905 PrintFrameDescription(delegate_, frame); 906 PrintFrameDescription(delegate_, frame);
906 delegate_->printMessage( 907 delegate_->printMessage(
907 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); 908 " - didReceiveServerRedirectForProvisionalLoadForFrame\n");
908 } 909 }
909 } 910 }
910 911
911 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame, 912 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame,
912 const blink::WebURLError& error) { 913 const blink::WebURLError& error) {
913 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 914 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
914 PrintFrameDescription(delegate_, frame); 915 PrintFrameDescription(delegate_, frame);
915 delegate_->printMessage(" - didFailProvisionalLoadWithError\n"); 916 delegate_->printMessage(" - didFailProvisionalLoadWithError\n");
916 } 917 }
917 LocationChangeDone(frame); 918 LocationChangeDone(frame);
918 return !frame->provisionalDataSource(); 919 return !frame->provisionalDataSource();
919 } 920 }
920 921
921 void WebTestProxyBase::DidCommitProvisionalLoad( 922 void WebTestProxyBase::DidCommitProvisionalLoad(
922 blink::WebLocalFrame* frame, 923 blink::WebLocalFrame* frame,
923 const blink::WebHistoryItem& history_item, 924 const blink::WebHistoryItem& history_item,
924 blink::WebHistoryCommitType history_type) { 925 blink::WebHistoryCommitType history_type) {
925 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 926 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
926 PrintFrameDescription(delegate_, frame); 927 PrintFrameDescription(delegate_, frame);
927 delegate_->printMessage(" - didCommitLoadForFrame\n"); 928 delegate_->printMessage(" - didCommitLoadForFrame\n");
928 } 929 }
929 } 930 }
930 931
931 void WebTestProxyBase::DidReceiveTitle(blink::WebLocalFrame* frame, 932 void WebTestProxyBase::DidReceiveTitle(blink::WebLocalFrame* frame,
932 const blink::WebString& title, 933 const blink::WebString& title,
933 blink::WebTextDirection direction) { 934 blink::WebTextDirection direction) {
934 blink::WebCString title8 = title.utf8(); 935 blink::WebCString title8 = title.utf8();
935 936
936 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 937 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
937 PrintFrameDescription(delegate_, frame); 938 PrintFrameDescription(delegate_, frame);
938 delegate_->printMessage(std::string(" - didReceiveTitle: ") + 939 delegate_->printMessage(std::string(" - didReceiveTitle: ") +
939 title8.data() + "\n"); 940 title8.data() + "\n");
940 } 941 }
941 942
942 if (test_interfaces_->testRunner()->shouldDumpTitleChanges()) 943 if (test_interfaces_->GetTestRunner()->shouldDumpTitleChanges())
943 delegate_->printMessage(std::string("TITLE CHANGED: '") + title8.data() + 944 delegate_->printMessage(std::string("TITLE CHANGED: '") + title8.data() +
944 "'\n"); 945 "'\n");
945 } 946 }
946 947
947 void WebTestProxyBase::DidChangeIcon(blink::WebLocalFrame* frame, 948 void WebTestProxyBase::DidChangeIcon(blink::WebLocalFrame* frame,
948 blink::WebIconURL::Type icon_type) { 949 blink::WebIconURL::Type icon_type) {
949 if (test_interfaces_->testRunner()->shouldDumpIconChanges()) { 950 if (test_interfaces_->GetTestRunner()->shouldDumpIconChanges()) {
950 PrintFrameDescription(delegate_, frame); 951 PrintFrameDescription(delegate_, frame);
951 delegate_->printMessage(std::string(" - didChangeIcons\n")); 952 delegate_->printMessage(std::string(" - didChangeIcons\n"));
952 } 953 }
953 } 954 }
954 955
955 void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { 956 void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) {
956 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 957 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
957 PrintFrameDescription(delegate_, frame); 958 PrintFrameDescription(delegate_, frame);
958 delegate_->printMessage(" - didFinishDocumentLoadForFrame\n"); 959 delegate_->printMessage(" - didFinishDocumentLoadForFrame\n");
959 } else { 960 } else {
960 unsigned pendingUnloadEvents = frame->unloadListenerCount(); 961 unsigned pendingUnloadEvents = frame->unloadListenerCount();
961 if (pendingUnloadEvents) { 962 if (pendingUnloadEvents) {
962 PrintFrameDescription(delegate_, frame); 963 PrintFrameDescription(delegate_, frame);
963 delegate_->printMessage(base::StringPrintf( 964 delegate_->printMessage(base::StringPrintf(
964 " - has %u onunload handler(s)\n", pendingUnloadEvents)); 965 " - has %u onunload handler(s)\n", pendingUnloadEvents));
965 } 966 }
966 } 967 }
967 } 968 }
968 969
969 void WebTestProxyBase::DidHandleOnloadEvents(blink::WebLocalFrame* frame) { 970 void WebTestProxyBase::DidHandleOnloadEvents(blink::WebLocalFrame* frame) {
970 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 971 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
971 PrintFrameDescription(delegate_, frame); 972 PrintFrameDescription(delegate_, frame);
972 delegate_->printMessage(" - didHandleOnloadEventsForFrame\n"); 973 delegate_->printMessage(" - didHandleOnloadEventsForFrame\n");
973 } 974 }
974 } 975 }
975 976
976 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame, 977 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame,
977 const blink::WebURLError& error) { 978 const blink::WebURLError& error) {
978 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 979 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
979 PrintFrameDescription(delegate_, frame); 980 PrintFrameDescription(delegate_, frame);
980 delegate_->printMessage(" - didFailLoadWithError\n"); 981 delegate_->printMessage(" - didFailLoadWithError\n");
981 } 982 }
982 LocationChangeDone(frame); 983 LocationChangeDone(frame);
983 } 984 }
984 985
985 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) { 986 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) {
986 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) { 987 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) {
987 PrintFrameDescription(delegate_, frame); 988 PrintFrameDescription(delegate_, frame);
988 delegate_->printMessage(" - didFinishLoadForFrame\n"); 989 delegate_->printMessage(" - didFinishLoadForFrame\n");
989 } 990 }
990 LocationChangeDone(frame); 991 LocationChangeDone(frame);
991 } 992 }
992 993
993 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame, 994 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame,
994 const blink::WebURL& insecure_url, 995 const blink::WebURL& insecure_url,
995 bool did_block_entire_page) { 996 bool did_block_entire_page) {
996 if (test_interfaces_->testRunner()->shouldDumpFrameLoadCallbacks()) 997 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks())
997 delegate_->printMessage("didDetectXSS\n"); 998 delegate_->printMessage("didDetectXSS\n");
998 } 999 }
999 1000
1000 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame, 1001 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame,
1001 const blink::WebURL& url) { 1002 const blink::WebURL& url) {
1002 if (test_interfaces_->testRunner()->shouldDumpPingLoaderCallbacks()) 1003 if (test_interfaces_->GetTestRunner()->shouldDumpPingLoaderCallbacks())
1003 delegate_->printMessage(std::string("PingLoader dispatched to '") + 1004 delegate_->printMessage(std::string("PingLoader dispatched to '") +
1004 URLDescription(url).c_str() + "'.\n"); 1005 URLDescription(url).c_str() + "'.\n");
1005 } 1006 }
1006 1007
1007 void WebTestProxyBase::WillRequestResource( 1008 void WebTestProxyBase::WillRequestResource(
1008 blink::WebLocalFrame* frame, 1009 blink::WebLocalFrame* frame,
1009 const blink::WebCachedURLRequest& request) { 1010 const blink::WebCachedURLRequest& request) {
1010 if (test_interfaces_->testRunner()->shouldDumpResourceRequestCallbacks()) { 1011 if (test_interfaces_->GetTestRunner()->shouldDumpResourceRequestCallbacks()) {
1011 PrintFrameDescription(delegate_, frame); 1012 PrintFrameDescription(delegate_, frame);
1012 delegate_->printMessage(std::string(" - ") + 1013 delegate_->printMessage(std::string(" - ") +
1013 request.initiatorName().utf8().data()); 1014 request.initiatorName().utf8().data());
1014 delegate_->printMessage(std::string(" requested '") + 1015 delegate_->printMessage(std::string(" requested '") +
1015 URLDescription(request.urlRequest().url()).c_str() + 1016 URLDescription(request.urlRequest().url()).c_str() +
1016 "'\n"); 1017 "'\n");
1017 } 1018 }
1018 } 1019 }
1019 1020
1020 void WebTestProxyBase::WillSendRequest( 1021 void WebTestProxyBase::WillSendRequest(
1021 blink::WebLocalFrame* frame, 1022 blink::WebLocalFrame* frame,
1022 unsigned identifier, 1023 unsigned identifier,
1023 blink::WebURLRequest& request, 1024 blink::WebURLRequest& request,
1024 const blink::WebURLResponse& redirect_response) { 1025 const blink::WebURLResponse& redirect_response) {
1025 // Need to use GURL for host() and SchemeIs() 1026 // Need to use GURL for host() and SchemeIs()
1026 GURL url = request.url(); 1027 GURL url = request.url();
1027 std::string request_url = url.possibly_invalid_spec(); 1028 std::string request_url = url.possibly_invalid_spec();
1028 1029
1029 GURL main_document_url = request.firstPartyForCookies(); 1030 GURL main_document_url = request.firstPartyForCookies();
1030 1031
1031 if (redirect_response.isNull() && 1032 if (redirect_response.isNull() &&
1032 (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks() || 1033 (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks() ||
1033 test_interfaces_->testRunner()->shouldDumpResourcePriorities())) { 1034 test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities())) {
1034 DCHECK(resource_identifier_map_.find(identifier) == 1035 DCHECK(resource_identifier_map_.find(identifier) ==
1035 resource_identifier_map_.end()); 1036 resource_identifier_map_.end());
1036 resource_identifier_map_[identifier] = 1037 resource_identifier_map_[identifier] =
1037 DescriptionSuitableForTestResult(request_url); 1038 DescriptionSuitableForTestResult(request_url);
1038 } 1039 }
1039 1040
1040 if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { 1041 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) {
1041 if (resource_identifier_map_.find(identifier) == 1042 if (resource_identifier_map_.find(identifier) ==
1042 resource_identifier_map_.end()) 1043 resource_identifier_map_.end())
1043 delegate_->printMessage("<unknown>"); 1044 delegate_->printMessage("<unknown>");
1044 else 1045 else
1045 delegate_->printMessage(resource_identifier_map_[identifier]); 1046 delegate_->printMessage(resource_identifier_map_[identifier]);
1046 delegate_->printMessage(" - willSendRequest <NSURLRequest URL "); 1047 delegate_->printMessage(" - willSendRequest <NSURLRequest URL ");
1047 delegate_->printMessage( 1048 delegate_->printMessage(
1048 DescriptionSuitableForTestResult(request_url).c_str()); 1049 DescriptionSuitableForTestResult(request_url).c_str());
1049 delegate_->printMessage(", main document URL "); 1050 delegate_->printMessage(", main document URL ");
1050 delegate_->printMessage(URLDescription(main_document_url).c_str()); 1051 delegate_->printMessage(URLDescription(main_document_url).c_str());
1051 delegate_->printMessage(", http method "); 1052 delegate_->printMessage(", http method ");
1052 delegate_->printMessage(request.httpMethod().utf8().data()); 1053 delegate_->printMessage(request.httpMethod().utf8().data());
1053 delegate_->printMessage("> redirectResponse "); 1054 delegate_->printMessage("> redirectResponse ");
1054 PrintResponseDescription(delegate_, redirect_response); 1055 PrintResponseDescription(delegate_, redirect_response);
1055 delegate_->printMessage("\n"); 1056 delegate_->printMessage("\n");
1056 } 1057 }
1057 1058
1058 if (test_interfaces_->testRunner()->shouldDumpResourcePriorities()) { 1059 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) {
1059 delegate_->printMessage( 1060 delegate_->printMessage(
1060 DescriptionSuitableForTestResult(request_url).c_str()); 1061 DescriptionSuitableForTestResult(request_url).c_str());
1061 delegate_->printMessage(" has priority "); 1062 delegate_->printMessage(" has priority ");
1062 delegate_->printMessage(PriorityDescription(request.priority())); 1063 delegate_->printMessage(PriorityDescription(request.priority()));
1063 delegate_->printMessage("\n"); 1064 delegate_->printMessage("\n");
1064 } 1065 }
1065 1066
1066 if (test_interfaces_->testRunner()->httpHeadersToClear()) { 1067 if (test_interfaces_->GetTestRunner()->httpHeadersToClear()) {
1067 const std::set<std::string>* clearHeaders = 1068 const std::set<std::string>* clearHeaders =
1068 test_interfaces_->testRunner()->httpHeadersToClear(); 1069 test_interfaces_->GetTestRunner()->httpHeadersToClear();
1069 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); 1070 for (std::set<std::string>::const_iterator header = clearHeaders->begin();
1070 header != clearHeaders->end(); 1071 header != clearHeaders->end();
1071 ++header) 1072 ++header)
1072 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); 1073 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header));
1073 } 1074 }
1074 1075
1075 std::string host = url.host(); 1076 std::string host = url.host();
1076 if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { 1077 if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) {
1077 if (!IsLocalHost(host) && !HostIsUsedBySomeTestsToGenerateError(host) && 1078 if (!IsLocalHost(host) && !HostIsUsedBySomeTestsToGenerateError(host) &&
1078 ((!main_document_url.SchemeIs("http") && 1079 ((!main_document_url.SchemeIs("http") &&
1079 !main_document_url.SchemeIs("https")) || 1080 !main_document_url.SchemeIs("https")) ||
1080 IsLocalHost(main_document_url.host())) && 1081 IsLocalHost(main_document_url.host())) &&
1081 !delegate_->allowExternalPages()) { 1082 !delegate_->allowExternalPages()) {
1082 delegate_->printMessage(std::string("Blocked access to external URL ") + 1083 delegate_->printMessage(std::string("Blocked access to external URL ") +
1083 request_url + "\n"); 1084 request_url + "\n");
1084 BlockRequest(request); 1085 BlockRequest(request);
1085 return; 1086 return;
1086 } 1087 }
1087 } 1088 }
1088 1089
1089 // Set the new substituted URL. 1090 // Set the new substituted URL.
1090 request.setURL(delegate_->rewriteLayoutTestsURL(request.url().spec())); 1091 request.setURL(delegate_->rewriteLayoutTestsURL(request.url().spec()));
1091 } 1092 }
1092 1093
1093 void WebTestProxyBase::DidReceiveResponse( 1094 void WebTestProxyBase::DidReceiveResponse(
1094 blink::WebLocalFrame* frame, 1095 blink::WebLocalFrame* frame,
1095 unsigned identifier, 1096 unsigned identifier,
1096 const blink::WebURLResponse& response) { 1097 const blink::WebURLResponse& response) {
1097 if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { 1098 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) {
1098 if (resource_identifier_map_.find(identifier) == 1099 if (resource_identifier_map_.find(identifier) ==
1099 resource_identifier_map_.end()) 1100 resource_identifier_map_.end())
1100 delegate_->printMessage("<unknown>"); 1101 delegate_->printMessage("<unknown>");
1101 else 1102 else
1102 delegate_->printMessage(resource_identifier_map_[identifier]); 1103 delegate_->printMessage(resource_identifier_map_[identifier]);
1103 delegate_->printMessage(" - didReceiveResponse "); 1104 delegate_->printMessage(" - didReceiveResponse ");
1104 PrintResponseDescription(delegate_, response); 1105 PrintResponseDescription(delegate_, response);
1105 delegate_->printMessage("\n"); 1106 delegate_->printMessage("\n");
1106 } 1107 }
1107 if (test_interfaces_->testRunner()->shouldDumpResourceResponseMIMETypes()) { 1108 if (test_interfaces_->GetTestRunner()
1109 ->shouldDumpResourceResponseMIMETypes()) {
1108 GURL url = response.url(); 1110 GURL url = response.url();
1109 blink::WebString mime_type = response.mimeType(); 1111 blink::WebString mime_type = response.mimeType();
1110 delegate_->printMessage(url.ExtractFileName()); 1112 delegate_->printMessage(url.ExtractFileName());
1111 delegate_->printMessage(" has MIME type "); 1113 delegate_->printMessage(" has MIME type ");
1112 // Simulate NSURLResponse's mapping of empty/unknown MIME types to 1114 // Simulate NSURLResponse's mapping of empty/unknown MIME types to
1113 // application/octet-stream 1115 // application/octet-stream
1114 delegate_->printMessage(mime_type.isEmpty() ? "application/octet-stream" 1116 delegate_->printMessage(mime_type.isEmpty() ? "application/octet-stream"
1115 : mime_type.utf8().data()); 1117 : mime_type.utf8().data());
1116 delegate_->printMessage("\n"); 1118 delegate_->printMessage("\n");
1117 } 1119 }
1118 } 1120 }
1119 1121
1120 void WebTestProxyBase::DidChangeResourcePriority( 1122 void WebTestProxyBase::DidChangeResourcePriority(
1121 blink::WebLocalFrame* frame, 1123 blink::WebLocalFrame* frame,
1122 unsigned identifier, 1124 unsigned identifier,
1123 const blink::WebURLRequest::Priority& priority, 1125 const blink::WebURLRequest::Priority& priority,
1124 int intra_priority_value) { 1126 int intra_priority_value) {
1125 if (test_interfaces_->testRunner()->shouldDumpResourcePriorities()) { 1127 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) {
1126 if (resource_identifier_map_.find(identifier) == 1128 if (resource_identifier_map_.find(identifier) ==
1127 resource_identifier_map_.end()) 1129 resource_identifier_map_.end())
1128 delegate_->printMessage("<unknown>"); 1130 delegate_->printMessage("<unknown>");
1129 else 1131 else
1130 delegate_->printMessage(resource_identifier_map_[identifier]); 1132 delegate_->printMessage(resource_identifier_map_[identifier]);
1131 delegate_->printMessage( 1133 delegate_->printMessage(
1132 base::StringPrintf(" changed priority to %s, intra_priority %d\n", 1134 base::StringPrintf(" changed priority to %s, intra_priority %d\n",
1133 PriorityDescription(priority).c_str(), 1135 PriorityDescription(priority).c_str(),
1134 intra_priority_value)); 1136 intra_priority_value));
1135 } 1137 }
1136 } 1138 }
1137 1139
1138 void WebTestProxyBase::DidFinishResourceLoad(blink::WebLocalFrame* frame, 1140 void WebTestProxyBase::DidFinishResourceLoad(blink::WebLocalFrame* frame,
1139 unsigned identifier) { 1141 unsigned identifier) {
1140 if (test_interfaces_->testRunner()->shouldDumpResourceLoadCallbacks()) { 1142 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) {
1141 if (resource_identifier_map_.find(identifier) == 1143 if (resource_identifier_map_.find(identifier) ==
1142 resource_identifier_map_.end()) 1144 resource_identifier_map_.end())
1143 delegate_->printMessage("<unknown>"); 1145 delegate_->printMessage("<unknown>");
1144 else 1146 else
1145 delegate_->printMessage(resource_identifier_map_[identifier]); 1147 delegate_->printMessage(resource_identifier_map_[identifier]);
1146 delegate_->printMessage(" - didFinishLoading\n"); 1148 delegate_->printMessage(" - didFinishLoading\n");
1147 } 1149 }
1148 resource_identifier_map_.erase(identifier); 1150 resource_identifier_map_.erase(identifier);
1149 } 1151 }
1150 1152
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 if (file_protocol != std::string::npos) { 1186 if (file_protocol != std::string::npos) {
1185 new_message = new_message.substr(0, file_protocol) + 1187 new_message = new_message.substr(0, file_protocol) +
1186 URLSuitableForTestResult(new_message.substr(file_protocol)); 1188 URLSuitableForTestResult(new_message.substr(file_protocol));
1187 } 1189 }
1188 delegate_->printMessage(new_message); 1190 delegate_->printMessage(new_message);
1189 } 1191 }
1190 delegate_->printMessage(std::string("\n")); 1192 delegate_->printMessage(std::string("\n"));
1191 } 1193 }
1192 1194
1193 void WebTestProxyBase::LocationChangeDone(blink::WebFrame* frame) { 1195 void WebTestProxyBase::LocationChangeDone(blink::WebFrame* frame) {
1194 if (frame != test_interfaces_->testRunner()->topLoadingFrame()) 1196 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame())
1195 return; 1197 return;
1196 test_interfaces_->testRunner()->setTopLoadingFrame(frame, true); 1198 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true);
1197 } 1199 }
1198 1200
1199 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( 1201 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation(
1200 const blink::WebFrameClient::NavigationPolicyInfo& info) { 1202 const blink::WebFrameClient::NavigationPolicyInfo& info) {
1201 blink::WebNavigationPolicy result; 1203 blink::WebNavigationPolicy result;
1202 if (!test_interfaces_->testRunner()->policyDelegateEnabled()) 1204 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled())
1203 return info.defaultPolicy; 1205 return info.defaultPolicy;
1204 1206
1205 delegate_->printMessage(std::string("Policy delegate: attempt to load ") + 1207 delegate_->printMessage(std::string("Policy delegate: attempt to load ") +
1206 URLDescription(info.urlRequest.url()) + 1208 URLDescription(info.urlRequest.url()) +
1207 " with navigation type '" + 1209 " with navigation type '" +
1208 WebNavigationTypeToString(info.navigationType) + "'\n" ); 1210 WebNavigationTypeToString(info.navigationType) + "'\n" );
1209 if (test_interfaces_->testRunner()->policyDelegateIsPermissive()) 1211 if (test_interfaces_->GetTestRunner()->policyDelegateIsPermissive())
1210 result = blink::WebNavigationPolicyCurrentTab; 1212 result = blink::WebNavigationPolicyCurrentTab;
1211 else 1213 else
1212 result = blink::WebNavigationPolicyIgnore; 1214 result = blink::WebNavigationPolicyIgnore;
1213 1215
1214 if (test_interfaces_->testRunner()->policyDelegateShouldNotifyDone()) 1216 if (test_interfaces_->GetTestRunner()->policyDelegateShouldNotifyDone())
1215 test_interfaces_->testRunner()->policyDelegateDone(); 1217 test_interfaces_->GetTestRunner()->policyDelegateDone();
1216 return result; 1218 return result;
1217 } 1219 }
1218 1220
1219 bool WebTestProxyBase::WillCheckAndDispatchMessageEvent( 1221 bool WebTestProxyBase::WillCheckAndDispatchMessageEvent(
1220 blink::WebLocalFrame* source_frame, 1222 blink::WebLocalFrame* source_frame,
1221 blink::WebFrame* target_frame, 1223 blink::WebFrame* target_frame,
1222 blink::WebSecurityOrigin target, 1224 blink::WebSecurityOrigin target,
1223 blink::WebDOMMessageEvent event) { 1225 blink::WebDOMMessageEvent event) {
1224 if (test_interfaces_->testRunner()->shouldInterceptPostMessage()) { 1226 if (test_interfaces_->GetTestRunner()->shouldInterceptPostMessage()) {
1225 delegate_->printMessage("intercepted postMessage\n"); 1227 delegate_->printMessage("intercepted postMessage\n");
1226 return true; 1228 return true;
1227 } 1229 }
1228 1230
1229 return false; 1231 return false;
1230 } 1232 }
1231 1233
1232 void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) { 1234 void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) {
1233 if (test_interfaces_->testRunner()->shouldDumpSpellCheckCallbacks()) { 1235 if (test_interfaces_->GetTestRunner()->shouldDumpSpellCheckCallbacks()) {
1234 delegate_->printMessage(std::string("SpellCheckEvent: ") + 1236 delegate_->printMessage(std::string("SpellCheckEvent: ") +
1235 event_name.utf8().data() + "\n"); 1237 event_name.utf8().data() + "\n");
1236 } 1238 }
1237 } 1239 }
1238 1240
1239 void WebTestProxyBase::ResetInputMethod() { 1241 void WebTestProxyBase::ResetInputMethod() {
1240 // If a composition text exists, then we need to let the browser process 1242 // If a composition text exists, then we need to let the browser process
1241 // to cancel the input method's ongoing composition session. 1243 // to cancel the input method's ongoing composition session.
1242 if (web_widget_) 1244 if (web_widget_)
1243 web_widget_->confirmComposition(); 1245 web_widget_->confirmComposition();
1244 } 1246 }
1245 1247
1246 blink::WebString WebTestProxyBase::acceptLanguages() { 1248 blink::WebString WebTestProxyBase::acceptLanguages() {
1247 return blink::WebString::fromUTF8(accept_languages_); 1249 return blink::WebString::fromUTF8(accept_languages_);
1248 } 1250 }
1249 1251
1250 MockWebPushClient* WebTestProxyBase::GetPushClientMock() { 1252 MockWebPushClient* WebTestProxyBase::GetPushClientMock() {
1251 if (!push_client_.get()) 1253 if (!push_client_.get())
1252 push_client_.reset(new MockWebPushClient); 1254 push_client_.reset(new MockWebPushClient);
1253 return push_client_.get(); 1255 return push_client_.get();
1254 } 1256 }
1255 1257
1256 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { 1258 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() {
1257 return GetPushClientMock(); 1259 return GetPushClientMock();
1258 } 1260 }
1259 1261
1260 } // namespace content 1262 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698