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