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/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | |
18 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" | 17 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" |
19 #include "content/shell/renderer/test_runner/accessibility_controller.h" | 18 #include "content/shell/renderer/test_runner/accessibility_controller.h" |
20 #include "content/shell/renderer/test_runner/event_sender.h" | 19 #include "content/shell/renderer/test_runner/event_sender.h" |
21 #include "content/shell/renderer/test_runner/mock_color_chooser.h" | 20 #include "content/shell/renderer/test_runner/mock_color_chooser.h" |
22 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" | 21 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" |
23 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" | 22 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" |
24 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 23 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
25 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 24 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
26 #include "content/shell/renderer/test_runner/mock_web_user_media_client.h" | 25 #include "content/shell/renderer/test_runner/mock_web_user_media_client.h" |
27 #include "content/shell/renderer/test_runner/spell_check_client.h" | 26 #include "content/shell/renderer/test_runner/spell_check_client.h" |
28 #include "content/shell/renderer/test_runner/test_interfaces.h" | 27 #include "content/shell/renderer/test_runner/test_interfaces.h" |
29 #include "content/shell/renderer/test_runner/test_plugin.h" | 28 #include "content/shell/renderer/test_runner/test_plugin.h" |
30 #include "content/shell/renderer/test_runner/test_runner.h" | 29 #include "content/shell/renderer/test_runner/test_runner.h" |
| 30 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
31 #include "content/shell/renderer/test_runner/web_test_runner.h" | 31 #include "content/shell/renderer/test_runner/web_test_runner.h" |
32 // FIXME: Including platform_canvas.h here is a layering violation. | 32 // FIXME: Including platform_canvas.h here is a layering violation. |
33 #include "skia/ext/platform_canvas.h" | 33 #include "skia/ext/platform_canvas.h" |
34 #include "third_party/WebKit/public/platform/Platform.h" | 34 #include "third_party/WebKit/public/platform/Platform.h" |
35 #include "third_party/WebKit/public/platform/WebCString.h" | 35 #include "third_party/WebKit/public/platform/WebCString.h" |
36 #include "third_party/WebKit/public/platform/WebClipboard.h" | 36 #include "third_party/WebKit/public/platform/WebClipboard.h" |
37 #include "third_party/WebKit/public/platform/WebURLError.h" | 37 #include "third_party/WebKit/public/platform/WebURLError.h" |
38 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 38 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
39 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 39 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
40 #include "third_party/WebKit/public/web/WebAXEnums.h" | 40 #include "third_party/WebKit/public/web/WebAXEnums.h" |
(...skipping 26 matching lines...) Expand all Loading... |
67 virtual void RunIfValid() OVERRIDE { (object_->*callback_)(); } | 67 virtual void RunIfValid() OVERRIDE { (object_->*callback_)(); } |
68 | 68 |
69 private: | 69 private: |
70 CallbackMethodType callback_; | 70 CallbackMethodType callback_; |
71 }; | 71 }; |
72 | 72 |
73 void PrintFrameDescription(WebTestDelegate* delegate, blink::WebFrame* frame) { | 73 void PrintFrameDescription(WebTestDelegate* delegate, blink::WebFrame* frame) { |
74 std::string name8 = frame->uniqueName().utf8(); | 74 std::string name8 = frame->uniqueName().utf8(); |
75 if (frame == frame->view()->mainFrame()) { | 75 if (frame == frame->view()->mainFrame()) { |
76 if (!name8.length()) { | 76 if (!name8.length()) { |
77 delegate->printMessage("main frame"); | 77 delegate->PrintMessage("main frame"); |
78 return; | 78 return; |
79 } | 79 } |
80 delegate->printMessage(std::string("main frame \"") + name8 + "\""); | 80 delegate->PrintMessage(std::string("main frame \"") + name8 + "\""); |
81 return; | 81 return; |
82 } | 82 } |
83 if (!name8.length()) { | 83 if (!name8.length()) { |
84 delegate->printMessage("frame (anonymous)"); | 84 delegate->PrintMessage("frame (anonymous)"); |
85 return; | 85 return; |
86 } | 86 } |
87 delegate->printMessage(std::string("frame \"") + name8 + "\""); | 87 delegate->PrintMessage(std::string("frame \"") + name8 + "\""); |
88 } | 88 } |
89 | 89 |
90 void PrintFrameuserGestureStatus(WebTestDelegate* delegate, | 90 void PrintFrameuserGestureStatus(WebTestDelegate* delegate, |
91 blink::WebFrame* frame, | 91 blink::WebFrame* frame, |
92 const char* msg) { | 92 const char* msg) { |
93 bool is_user_gesture = | 93 bool is_user_gesture = |
94 blink::WebUserGestureIndicator::isProcessingUserGesture(); | 94 blink::WebUserGestureIndicator::isProcessingUserGesture(); |
95 delegate->printMessage(std::string("Frame with user gesture \"") + | 95 delegate->PrintMessage(std::string("Frame with user gesture \"") + |
96 (is_user_gesture ? "true" : "false") + "\"" + msg); | 96 (is_user_gesture ? "true" : "false") + "\"" + msg); |
97 } | 97 } |
98 | 98 |
99 // Used to write a platform neutral file:/// URL by taking the | 99 // Used to write a platform neutral file:/// URL by taking the |
100 // filename and its directory. (e.g., converts | 100 // filename and its directory. (e.g., converts |
101 // "file:///tmp/foo/bar.txt" to just "bar.txt"). | 101 // "file:///tmp/foo/bar.txt" to just "bar.txt"). |
102 std::string DescriptionSuitableForTestResult(const std::string& url) { | 102 std::string DescriptionSuitableForTestResult(const std::string& url) { |
103 if (url.empty() || std::string::npos == url.find("file://")) | 103 if (url.empty() || std::string::npos == url.find("file://")) |
104 return url; | 104 return url; |
105 | 105 |
106 size_t pos = url.rfind('/'); | 106 size_t pos = url.rfind('/'); |
107 if (pos == std::string::npos || !pos) | 107 if (pos == std::string::npos || !pos) |
108 return "ERROR:" + url; | 108 return "ERROR:" + url; |
109 pos = url.rfind('/', pos - 1); | 109 pos = url.rfind('/', pos - 1); |
110 if (pos == std::string::npos) | 110 if (pos == std::string::npos) |
111 return "ERROR:" + url; | 111 return "ERROR:" + url; |
112 | 112 |
113 return url.substr(pos + 1); | 113 return url.substr(pos + 1); |
114 } | 114 } |
115 | 115 |
116 void PrintResponseDescription(WebTestDelegate* delegate, | 116 void PrintResponseDescription(WebTestDelegate* delegate, |
117 const blink::WebURLResponse& response) { | 117 const blink::WebURLResponse& response) { |
118 if (response.isNull()) { | 118 if (response.isNull()) { |
119 delegate->printMessage("(null)"); | 119 delegate->PrintMessage("(null)"); |
120 return; | 120 return; |
121 } | 121 } |
122 delegate->printMessage(base::StringPrintf( | 122 delegate->PrintMessage(base::StringPrintf( |
123 "<NSURLResponse %s, http status code %d>", | 123 "<NSURLResponse %s, http status code %d>", |
124 DescriptionSuitableForTestResult(response.url().spec()).c_str(), | 124 DescriptionSuitableForTestResult(response.url().spec()).c_str(), |
125 response.httpStatusCode())); | 125 response.httpStatusCode())); |
126 } | 126 } |
127 | 127 |
128 std::string URLDescription(const GURL& url) { | 128 std::string URLDescription(const GURL& url) { |
129 if (url.SchemeIs("file")) | 129 if (url.SchemeIs("file")) |
130 return url.ExtractFileName(); | 130 return url.ExtractFileName(); |
131 return url.possibly_invalid_spec(); | 131 return url.possibly_invalid_spec(); |
132 } | 132 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 result += DumpFrameScrollPosition(child, recursive); | 304 result += DumpFrameScrollPosition(child, recursive); |
305 return result; | 305 return result; |
306 } | 306 } |
307 | 307 |
308 std::string DumpAllBackForwardLists(TestInterfaces* interfaces, | 308 std::string DumpAllBackForwardLists(TestInterfaces* interfaces, |
309 WebTestDelegate* delegate) { | 309 WebTestDelegate* delegate) { |
310 std::string result; | 310 std::string result; |
311 const std::vector<WebTestProxyBase*>& window_list = | 311 const std::vector<WebTestProxyBase*>& window_list = |
312 interfaces->GetWindowList(); | 312 interfaces->GetWindowList(); |
313 for (size_t i = 0; i < window_list.size(); ++i) | 313 for (size_t i = 0; i < window_list.size(); ++i) |
314 result.append(delegate->dumpHistoryForWindow(window_list.at(i))); | 314 result.append(delegate->DumpHistoryForWindow(window_list.at(i))); |
315 return result; | 315 return result; |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 WebTestProxyBase::WebTestProxyBase() | 319 WebTestProxyBase::WebTestProxyBase() |
320 : test_interfaces_(NULL), | 320 : test_interfaces_(NULL), |
321 delegate_(NULL), | 321 delegate_(NULL), |
322 web_widget_(NULL), | 322 web_widget_(NULL), |
323 spellcheck_(new SpellCheckClient(this)), | 323 spellcheck_(new SpellCheckClient(this)), |
324 chooser_count_(0) { | 324 chooser_count_(0) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 blink::WebColorChooserClient* client, | 372 blink::WebColorChooserClient* client, |
373 const blink::WebColor& color, | 373 const blink::WebColor& color, |
374 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { | 374 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
375 // This instance is deleted by WebCore::ColorInputType | 375 // This instance is deleted by WebCore::ColorInputType |
376 return new MockColorChooser(client, delegate_, this); | 376 return new MockColorChooser(client, delegate_, this); |
377 } | 377 } |
378 | 378 |
379 bool WebTestProxyBase::RunFileChooser( | 379 bool WebTestProxyBase::RunFileChooser( |
380 const blink::WebFileChooserParams& params, | 380 const blink::WebFileChooserParams& params, |
381 blink::WebFileChooserCompletion* completion) { | 381 blink::WebFileChooserCompletion* completion) { |
382 delegate_->printMessage("Mock: Opening a file chooser.\n"); | 382 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); |
383 // FIXME: Add ability to set file names to a file upload control. | 383 // FIXME: Add ability to set file names to a file upload control. |
384 return false; | 384 return false; |
385 } | 385 } |
386 | 386 |
387 void WebTestProxyBase::ShowValidationMessage( | 387 void WebTestProxyBase::ShowValidationMessage( |
388 const base::string16& message, | 388 const base::string16& message, |
389 const base::string16& sub_message) { | 389 const base::string16& sub_message) { |
390 delegate_->printMessage( | 390 delegate_->PrintMessage("ValidationMessageClient: main-message=" + |
391 "ValidationMessageClient: main-message=" + | 391 base::UTF16ToUTF8(message) + " sub-message=" + |
392 base::UTF16ToUTF8(message) + | 392 base::UTF16ToUTF8(sub_message) + "\n"); |
393 " sub-message=" + | |
394 base::UTF16ToUTF8(sub_message) + "\n"); | |
395 } | 393 } |
396 | 394 |
397 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) { | 395 std::string WebTestProxyBase::CaptureTree(bool debug_render_tree) { |
398 bool should_dump_custom_text = | 396 bool should_dump_custom_text = |
399 test_interfaces_->GetTestRunner()->shouldDumpAsCustomText(); | 397 test_interfaces_->GetTestRunner()->shouldDumpAsCustomText(); |
400 bool should_dump_as_text = | 398 bool should_dump_as_text = |
401 test_interfaces_->GetTestRunner()->shouldDumpAsText(); | 399 test_interfaces_->GetTestRunner()->shouldDumpAsText(); |
402 bool should_dump_as_markup = | 400 bool should_dump_as_markup = |
403 test_interfaces_->GetTestRunner()->shouldDumpAsMarkup(); | 401 test_interfaces_->GetTestRunner()->shouldDumpAsMarkup(); |
404 bool should_dump_as_printed = test_interfaces_->GetTestRunner()->isPrinting(); | 402 bool should_dump_as_printed = test_interfaces_->GetTestRunner()->isPrinting(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 credential_manager_client_.reset(new MockCredentialManagerClient()); | 606 credential_manager_client_.reset(new MockCredentialManagerClient()); |
609 return credential_manager_client_.get(); | 607 return credential_manager_client_.get(); |
610 } | 608 } |
611 | 609 |
612 void WebTestProxyBase::ScheduleAnimation() { | 610 void WebTestProxyBase::ScheduleAnimation() { |
613 if (!test_interfaces_->GetTestRunner()->TestIsRunning()) | 611 if (!test_interfaces_->GetTestRunner()->TestIsRunning()) |
614 return; | 612 return; |
615 | 613 |
616 if (!animate_scheduled_) { | 614 if (!animate_scheduled_) { |
617 animate_scheduled_ = true; | 615 animate_scheduled_ = true; |
618 delegate_->postDelayedTask( | 616 delegate_->PostDelayedTask( |
619 new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1); | 617 new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1); |
620 } | 618 } |
621 } | 619 } |
622 | 620 |
623 void WebTestProxyBase::AnimateNow() { | 621 void WebTestProxyBase::AnimateNow() { |
624 if (animate_scheduled_) { | 622 if (animate_scheduled_) { |
625 animate_scheduled_ = false; | 623 animate_scheduled_ = false; |
626 web_widget_->animate(0.0); | 624 web_widget_->animate(0.0); |
627 web_widget_->layout(); | 625 web_widget_->layout(); |
628 } | 626 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 | 741 |
744 blink::WebNode node = obj.node(); | 742 blink::WebNode node = obj.node(); |
745 if (!node.isNull() && node.isElementNode()) { | 743 if (!node.isNull() && node.isElementNode()) { |
746 blink::WebElement element = node.to<blink::WebElement>(); | 744 blink::WebElement element = node.to<blink::WebElement>(); |
747 if (element.hasAttribute("id")) { | 745 if (element.hasAttribute("id")) { |
748 message += " - id:"; | 746 message += " - id:"; |
749 message += element.getAttribute("id").utf8().data(); | 747 message += element.getAttribute("id").utf8().data(); |
750 } | 748 } |
751 } | 749 } |
752 | 750 |
753 delegate_->printMessage(message + "\n"); | 751 delegate_->PrintMessage(message + "\n"); |
754 } | 752 } |
755 } | 753 } |
756 | 754 |
757 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame, | 755 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame, |
758 const blink::WebDragData& data, | 756 const blink::WebDragData& data, |
759 blink::WebDragOperationsMask mask, | 757 blink::WebDragOperationsMask mask, |
760 const blink::WebImage& image, | 758 const blink::WebImage& image, |
761 const blink::WebPoint& point) { | 759 const blink::WebPoint& point) { |
762 // When running a test, we need to fake a drag drop operation otherwise | 760 // When running a test, we need to fake a drag drop operation otherwise |
763 // Windows waits for real mouse events to know when the drag is over. | 761 // Windows waits for real mouse events to know when the drag is over. |
764 test_interfaces_->GetEventSender()->DoDragDrop(data, mask); | 762 test_interfaces_->GetEventSender()->DoDragDrop(data, mask); |
765 } | 763 } |
766 | 764 |
767 // The output from these methods in layout test mode should match that | 765 // The output from these methods in layout test mode should match that |
768 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. | 766 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. |
769 | 767 |
770 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) { | 768 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) { |
771 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks()) | 769 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks()) |
772 delegate_->printMessage( | 770 delegate_->PrintMessage( |
773 "EDITING DELEGATE: " | 771 "EDITING DELEGATE: " |
774 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); | 772 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); |
775 } | 773 } |
776 | 774 |
777 void WebTestProxyBase::DidChangeContents() { | 775 void WebTestProxyBase::DidChangeContents() { |
778 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks()) | 776 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks()) |
779 delegate_->printMessage( | 777 delegate_->PrintMessage( |
780 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); | 778 "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n"); |
781 } | 779 } |
782 | 780 |
783 bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame, | 781 bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame, |
784 const blink::WebURLRequest& request, | 782 const blink::WebURLRequest& request, |
785 const blink::WebWindowFeatures& features, | 783 const blink::WebWindowFeatures& features, |
786 const blink::WebString& frame_name, | 784 const blink::WebString& frame_name, |
787 blink::WebNavigationPolicy policy, | 785 blink::WebNavigationPolicy policy, |
788 bool suppress_opener) { | 786 bool suppress_opener) { |
789 if (!test_interfaces_->GetTestRunner()->canOpenWindows()) | 787 if (!test_interfaces_->GetTestRunner()->canOpenWindows()) |
790 return false; | 788 return false; |
791 if (test_interfaces_->GetTestRunner()->shouldDumpCreateView()) | 789 if (test_interfaces_->GetTestRunner()->shouldDumpCreateView()) |
792 delegate_->printMessage(std::string("createView(") + | 790 delegate_->PrintMessage(std::string("createView(") + |
793 URLDescription(request.url()) + ")\n"); | 791 URLDescription(request.url()) + ")\n"); |
794 return true; | 792 return true; |
795 } | 793 } |
796 | 794 |
797 blink::WebPlugin* WebTestProxyBase::CreatePlugin( | 795 blink::WebPlugin* WebTestProxyBase::CreatePlugin( |
798 blink::WebLocalFrame* frame, | 796 blink::WebLocalFrame* frame, |
799 const blink::WebPluginParams& params) { | 797 const blink::WebPluginParams& params) { |
800 if (TestPlugin::IsSupportedMimeType(params.mimeType)) | 798 if (TestPlugin::IsSupportedMimeType(params.mimeType)) |
801 return TestPlugin::create(frame, params, delegate_); | 799 return TestPlugin::create(frame, params, delegate_); |
802 return 0; | 800 return 0; |
803 } | 801 } |
804 | 802 |
805 void WebTestProxyBase::SetStatusText(const blink::WebString& text) { | 803 void WebTestProxyBase::SetStatusText(const blink::WebString& text) { |
806 if (!test_interfaces_->GetTestRunner()->shouldDumpStatusCallbacks()) | 804 if (!test_interfaces_->GetTestRunner()->shouldDumpStatusCallbacks()) |
807 return; | 805 return; |
808 delegate_->printMessage( | 806 delegate_->PrintMessage( |
809 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") + | 807 std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") + |
810 text.utf8().data() + "\n"); | 808 text.utf8().data() + "\n"); |
811 } | 809 } |
812 | 810 |
813 void WebTestProxyBase::DidStopLoading() { | 811 void WebTestProxyBase::DidStopLoading() { |
814 if (test_interfaces_->GetTestRunner()->shouldDumpProgressFinishedCallback()) | 812 if (test_interfaces_->GetTestRunner()->shouldDumpProgressFinishedCallback()) |
815 delegate_->printMessage("postProgressFinishedNotification\n"); | 813 delegate_->PrintMessage("postProgressFinishedNotification\n"); |
816 } | 814 } |
817 | 815 |
818 void WebTestProxyBase::ShowContextMenu( | 816 void WebTestProxyBase::ShowContextMenu( |
819 blink::WebLocalFrame* frame, | 817 blink::WebLocalFrame* frame, |
820 const blink::WebContextMenuData& context_menu_data) { | 818 const blink::WebContextMenuData& context_menu_data) { |
821 test_interfaces_->GetEventSender()->SetContextMenuData(context_menu_data); | 819 test_interfaces_->GetEventSender()->SetContextMenuData(context_menu_data); |
822 } | 820 } |
823 | 821 |
824 blink::WebUserMediaClient* WebTestProxyBase::GetUserMediaClient() { | 822 blink::WebUserMediaClient* WebTestProxyBase::GetUserMediaClient() { |
825 if (!user_media_client_.get()) | 823 if (!user_media_client_.get()) |
(...skipping 29 matching lines...) Expand all Loading... |
855 | 853 |
856 void WebTestProxyBase::RequestPointerUnlock() { | 854 void WebTestProxyBase::RequestPointerUnlock() { |
857 test_interfaces_->GetTestRunner()->RequestPointerUnlock(); | 855 test_interfaces_->GetTestRunner()->RequestPointerUnlock(); |
858 } | 856 } |
859 | 857 |
860 bool WebTestProxyBase::IsPointerLocked() { | 858 bool WebTestProxyBase::IsPointerLocked() { |
861 return test_interfaces_->GetTestRunner()->isPointerLocked(); | 859 return test_interfaces_->GetTestRunner()->isPointerLocked(); |
862 } | 860 } |
863 | 861 |
864 void WebTestProxyBase::DidFocus() { | 862 void WebTestProxyBase::DidFocus() { |
865 delegate_->setFocus(this, true); | 863 delegate_->SetFocus(this, true); |
866 } | 864 } |
867 | 865 |
868 void WebTestProxyBase::DidBlur() { | 866 void WebTestProxyBase::DidBlur() { |
869 delegate_->setFocus(this, false); | 867 delegate_->SetFocus(this, false); |
870 } | 868 } |
871 | 869 |
872 void WebTestProxyBase::SetToolTipText(const blink::WebString& text, | 870 void WebTestProxyBase::SetToolTipText(const blink::WebString& text, |
873 blink::WebTextDirection direction) { | 871 blink::WebTextDirection direction) { |
874 test_interfaces_->GetTestRunner()->setToolTipText(text); | 872 test_interfaces_->GetTestRunner()->setToolTipText(text); |
875 } | 873 } |
876 | 874 |
877 void WebTestProxyBase::DidOpenChooser() { | 875 void WebTestProxyBase::DidOpenChooser() { |
878 chooser_count_++; | 876 chooser_count_++; |
879 } | 877 } |
880 | 878 |
881 void WebTestProxyBase::DidCloseChooser() { | 879 void WebTestProxyBase::DidCloseChooser() { |
882 chooser_count_--; | 880 chooser_count_--; |
883 } | 881 } |
884 | 882 |
885 bool WebTestProxyBase::IsChooserShown() { | 883 bool WebTestProxyBase::IsChooserShown() { |
886 return 0 < chooser_count_; | 884 return 0 < chooser_count_; |
887 } | 885 } |
888 | 886 |
889 void WebTestProxyBase::LoadURLExternally( | 887 void WebTestProxyBase::LoadURLExternally( |
890 blink::WebLocalFrame* frame, | 888 blink::WebLocalFrame* frame, |
891 const blink::WebURLRequest& request, | 889 const blink::WebURLRequest& request, |
892 blink::WebNavigationPolicy policy, | 890 blink::WebNavigationPolicy policy, |
893 const blink::WebString& suggested_name) { | 891 const blink::WebString& suggested_name) { |
894 if (test_interfaces_->GetTestRunner()->shouldWaitUntilExternalURLLoad()) { | 892 if (test_interfaces_->GetTestRunner()->shouldWaitUntilExternalURLLoad()) { |
895 if (policy == blink::WebNavigationPolicyDownload) { | 893 if (policy == blink::WebNavigationPolicyDownload) { |
896 delegate_->printMessage( | 894 delegate_->PrintMessage( |
897 std::string("Downloading URL with suggested filename \"") + | 895 std::string("Downloading URL with suggested filename \"") + |
898 suggested_name.utf8() + "\"\n"); | 896 suggested_name.utf8() + "\"\n"); |
899 } else { | 897 } else { |
900 delegate_->printMessage(std::string("Loading URL externally - \"") + | 898 delegate_->PrintMessage(std::string("Loading URL externally - \"") + |
901 URLDescription(request.url()) + "\"\n"); | 899 URLDescription(request.url()) + "\"\n"); |
902 } | 900 } |
903 delegate_->testFinished(); | 901 delegate_->TestFinished(); |
904 } | 902 } |
905 } | 903 } |
906 | 904 |
907 void WebTestProxyBase::DidStartProvisionalLoad(blink::WebLocalFrame* frame) { | 905 void WebTestProxyBase::DidStartProvisionalLoad(blink::WebLocalFrame* frame) { |
908 if (!test_interfaces_->GetTestRunner()->topLoadingFrame()) | 906 if (!test_interfaces_->GetTestRunner()->topLoadingFrame()) |
909 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, false); | 907 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, false); |
910 | 908 |
911 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 909 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
912 PrintFrameDescription(delegate_, frame); | 910 PrintFrameDescription(delegate_, frame); |
913 delegate_->printMessage(" - didStartProvisionalLoadForFrame\n"); | 911 delegate_->PrintMessage(" - didStartProvisionalLoadForFrame\n"); |
914 } | 912 } |
915 | 913 |
916 if (test_interfaces_->GetTestRunner() | 914 if (test_interfaces_->GetTestRunner() |
917 ->shouldDumpUserGestureInFrameLoadCallbacks()) { | 915 ->shouldDumpUserGestureInFrameLoadCallbacks()) { |
918 PrintFrameuserGestureStatus( | 916 PrintFrameuserGestureStatus( |
919 delegate_, frame, " - in didStartProvisionalLoadForFrame\n"); | 917 delegate_, frame, " - in didStartProvisionalLoadForFrame\n"); |
920 } | 918 } |
921 } | 919 } |
922 | 920 |
923 void WebTestProxyBase::DidReceiveServerRedirectForProvisionalLoad( | 921 void WebTestProxyBase::DidReceiveServerRedirectForProvisionalLoad( |
924 blink::WebLocalFrame* frame) { | 922 blink::WebLocalFrame* frame) { |
925 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 923 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
926 PrintFrameDescription(delegate_, frame); | 924 PrintFrameDescription(delegate_, frame); |
927 delegate_->printMessage( | 925 delegate_->PrintMessage( |
928 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); | 926 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
929 } | 927 } |
930 } | 928 } |
931 | 929 |
932 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame, | 930 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame, |
933 const blink::WebURLError& error) { | 931 const blink::WebURLError& error) { |
934 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 932 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
935 PrintFrameDescription(delegate_, frame); | 933 PrintFrameDescription(delegate_, frame); |
936 delegate_->printMessage(" - didFailProvisionalLoadWithError\n"); | 934 delegate_->PrintMessage(" - didFailProvisionalLoadWithError\n"); |
937 } | 935 } |
938 CheckDone(frame, MainResourceLoadFailed); | 936 CheckDone(frame, MainResourceLoadFailed); |
939 return !frame->provisionalDataSource(); | 937 return !frame->provisionalDataSource(); |
940 } | 938 } |
941 | 939 |
942 void WebTestProxyBase::DidCommitProvisionalLoad( | 940 void WebTestProxyBase::DidCommitProvisionalLoad( |
943 blink::WebLocalFrame* frame, | 941 blink::WebLocalFrame* frame, |
944 const blink::WebHistoryItem& history_item, | 942 const blink::WebHistoryItem& history_item, |
945 blink::WebHistoryCommitType history_type) { | 943 blink::WebHistoryCommitType history_type) { |
946 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 944 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
947 PrintFrameDescription(delegate_, frame); | 945 PrintFrameDescription(delegate_, frame); |
948 delegate_->printMessage(" - didCommitLoadForFrame\n"); | 946 delegate_->PrintMessage(" - didCommitLoadForFrame\n"); |
949 } | 947 } |
950 } | 948 } |
951 | 949 |
952 void WebTestProxyBase::DidReceiveTitle(blink::WebLocalFrame* frame, | 950 void WebTestProxyBase::DidReceiveTitle(blink::WebLocalFrame* frame, |
953 const blink::WebString& title, | 951 const blink::WebString& title, |
954 blink::WebTextDirection direction) { | 952 blink::WebTextDirection direction) { |
955 blink::WebCString title8 = title.utf8(); | 953 blink::WebCString title8 = title.utf8(); |
956 | 954 |
957 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 955 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
958 PrintFrameDescription(delegate_, frame); | 956 PrintFrameDescription(delegate_, frame); |
959 delegate_->printMessage(std::string(" - didReceiveTitle: ") + | 957 delegate_->PrintMessage(std::string(" - didReceiveTitle: ") + |
960 title8.data() + "\n"); | 958 title8.data() + "\n"); |
961 } | 959 } |
962 | 960 |
963 if (test_interfaces_->GetTestRunner()->shouldDumpTitleChanges()) | 961 if (test_interfaces_->GetTestRunner()->shouldDumpTitleChanges()) |
964 delegate_->printMessage(std::string("TITLE CHANGED: '") + title8.data() + | 962 delegate_->PrintMessage(std::string("TITLE CHANGED: '") + title8.data() + |
965 "'\n"); | 963 "'\n"); |
966 } | 964 } |
967 | 965 |
968 void WebTestProxyBase::DidChangeIcon(blink::WebLocalFrame* frame, | 966 void WebTestProxyBase::DidChangeIcon(blink::WebLocalFrame* frame, |
969 blink::WebIconURL::Type icon_type) { | 967 blink::WebIconURL::Type icon_type) { |
970 if (test_interfaces_->GetTestRunner()->shouldDumpIconChanges()) { | 968 if (test_interfaces_->GetTestRunner()->shouldDumpIconChanges()) { |
971 PrintFrameDescription(delegate_, frame); | 969 PrintFrameDescription(delegate_, frame); |
972 delegate_->printMessage(std::string(" - didChangeIcons\n")); | 970 delegate_->PrintMessage(std::string(" - didChangeIcons\n")); |
973 } | 971 } |
974 } | 972 } |
975 | 973 |
976 void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { | 974 void WebTestProxyBase::DidFinishDocumentLoad(blink::WebLocalFrame* frame) { |
977 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 975 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
978 PrintFrameDescription(delegate_, frame); | 976 PrintFrameDescription(delegate_, frame); |
979 delegate_->printMessage(" - didFinishDocumentLoadForFrame\n"); | 977 delegate_->PrintMessage(" - didFinishDocumentLoadForFrame\n"); |
980 } else { | 978 } else { |
981 unsigned pendingUnloadEvents = frame->unloadListenerCount(); | 979 unsigned pendingUnloadEvents = frame->unloadListenerCount(); |
982 if (pendingUnloadEvents) { | 980 if (pendingUnloadEvents) { |
983 PrintFrameDescription(delegate_, frame); | 981 PrintFrameDescription(delegate_, frame); |
984 delegate_->printMessage(base::StringPrintf( | 982 delegate_->PrintMessage(base::StringPrintf( |
985 " - has %u onunload handler(s)\n", pendingUnloadEvents)); | 983 " - has %u onunload handler(s)\n", pendingUnloadEvents)); |
986 } | 984 } |
987 } | 985 } |
988 } | 986 } |
989 | 987 |
990 void WebTestProxyBase::DidHandleOnloadEvents(blink::WebLocalFrame* frame) { | 988 void WebTestProxyBase::DidHandleOnloadEvents(blink::WebLocalFrame* frame) { |
991 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 989 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
992 PrintFrameDescription(delegate_, frame); | 990 PrintFrameDescription(delegate_, frame); |
993 delegate_->printMessage(" - didHandleOnloadEventsForFrame\n"); | 991 delegate_->PrintMessage(" - didHandleOnloadEventsForFrame\n"); |
994 } | 992 } |
995 } | 993 } |
996 | 994 |
997 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame, | 995 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame, |
998 const blink::WebURLError& error) { | 996 const blink::WebURLError& error) { |
999 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 997 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
1000 PrintFrameDescription(delegate_, frame); | 998 PrintFrameDescription(delegate_, frame); |
1001 delegate_->printMessage(" - didFailLoadWithError\n"); | 999 delegate_->PrintMessage(" - didFailLoadWithError\n"); |
1002 } | 1000 } |
1003 CheckDone(frame, MainResourceLoadFailed); | 1001 CheckDone(frame, MainResourceLoadFailed); |
1004 } | 1002 } |
1005 | 1003 |
1006 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) { | 1004 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) { |
1007 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 1005 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
1008 PrintFrameDescription(delegate_, frame); | 1006 PrintFrameDescription(delegate_, frame); |
1009 delegate_->printMessage(" - didFinishLoadForFrame\n"); | 1007 delegate_->PrintMessage(" - didFinishLoadForFrame\n"); |
1010 } | 1008 } |
1011 CheckDone(frame, LoadFinished); | 1009 CheckDone(frame, LoadFinished); |
1012 } | 1010 } |
1013 | 1011 |
1014 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame, | 1012 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame, |
1015 const blink::WebURL& insecure_url, | 1013 const blink::WebURL& insecure_url, |
1016 bool did_block_entire_page) { | 1014 bool did_block_entire_page) { |
1017 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) | 1015 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) |
1018 delegate_->printMessage("didDetectXSS\n"); | 1016 delegate_->PrintMessage("didDetectXSS\n"); |
1019 } | 1017 } |
1020 | 1018 |
1021 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame, | 1019 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame, |
1022 const blink::WebURL& url) { | 1020 const blink::WebURL& url) { |
1023 if (test_interfaces_->GetTestRunner()->shouldDumpPingLoaderCallbacks()) | 1021 if (test_interfaces_->GetTestRunner()->shouldDumpPingLoaderCallbacks()) |
1024 delegate_->printMessage(std::string("PingLoader dispatched to '") + | 1022 delegate_->PrintMessage(std::string("PingLoader dispatched to '") + |
1025 URLDescription(url).c_str() + "'.\n"); | 1023 URLDescription(url).c_str() + "'.\n"); |
1026 } | 1024 } |
1027 | 1025 |
1028 void WebTestProxyBase::WillRequestResource( | 1026 void WebTestProxyBase::WillRequestResource( |
1029 blink::WebLocalFrame* frame, | 1027 blink::WebLocalFrame* frame, |
1030 const blink::WebCachedURLRequest& request) { | 1028 const blink::WebCachedURLRequest& request) { |
1031 if (test_interfaces_->GetTestRunner()->shouldDumpResourceRequestCallbacks()) { | 1029 if (test_interfaces_->GetTestRunner()->shouldDumpResourceRequestCallbacks()) { |
1032 PrintFrameDescription(delegate_, frame); | 1030 PrintFrameDescription(delegate_, frame); |
1033 delegate_->printMessage(std::string(" - ") + | 1031 delegate_->PrintMessage(std::string(" - ") + |
1034 request.initiatorName().utf8().data()); | 1032 request.initiatorName().utf8().data()); |
1035 delegate_->printMessage(std::string(" requested '") + | 1033 delegate_->PrintMessage(std::string(" requested '") + |
1036 URLDescription(request.urlRequest().url()).c_str() + | 1034 URLDescription(request.urlRequest().url()).c_str() + |
1037 "'\n"); | 1035 "'\n"); |
1038 } | 1036 } |
1039 } | 1037 } |
1040 | 1038 |
1041 void WebTestProxyBase::WillSendRequest( | 1039 void WebTestProxyBase::WillSendRequest( |
1042 blink::WebLocalFrame* frame, | 1040 blink::WebLocalFrame* frame, |
1043 unsigned identifier, | 1041 unsigned identifier, |
1044 blink::WebURLRequest& request, | 1042 blink::WebURLRequest& request, |
1045 const blink::WebURLResponse& redirect_response) { | 1043 const blink::WebURLResponse& redirect_response) { |
1046 // Need to use GURL for host() and SchemeIs() | 1044 // Need to use GURL for host() and SchemeIs() |
1047 GURL url = request.url(); | 1045 GURL url = request.url(); |
1048 std::string request_url = url.possibly_invalid_spec(); | 1046 std::string request_url = url.possibly_invalid_spec(); |
1049 | 1047 |
1050 GURL main_document_url = request.firstPartyForCookies(); | 1048 GURL main_document_url = request.firstPartyForCookies(); |
1051 | 1049 |
1052 if (redirect_response.isNull() && | 1050 if (redirect_response.isNull() && |
1053 (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks() || | 1051 (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks() || |
1054 test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities())) { | 1052 test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities())) { |
1055 DCHECK(resource_identifier_map_.find(identifier) == | 1053 DCHECK(resource_identifier_map_.find(identifier) == |
1056 resource_identifier_map_.end()); | 1054 resource_identifier_map_.end()); |
1057 resource_identifier_map_[identifier] = | 1055 resource_identifier_map_[identifier] = |
1058 DescriptionSuitableForTestResult(request_url); | 1056 DescriptionSuitableForTestResult(request_url); |
1059 } | 1057 } |
1060 | 1058 |
1061 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { | 1059 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { |
1062 if (resource_identifier_map_.find(identifier) == | 1060 if (resource_identifier_map_.find(identifier) == |
1063 resource_identifier_map_.end()) | 1061 resource_identifier_map_.end()) |
1064 delegate_->printMessage("<unknown>"); | 1062 delegate_->PrintMessage("<unknown>"); |
1065 else | 1063 else |
1066 delegate_->printMessage(resource_identifier_map_[identifier]); | 1064 delegate_->PrintMessage(resource_identifier_map_[identifier]); |
1067 delegate_->printMessage(" - willSendRequest <NSURLRequest URL "); | 1065 delegate_->PrintMessage(" - willSendRequest <NSURLRequest URL "); |
1068 delegate_->printMessage( | 1066 delegate_->PrintMessage( |
1069 DescriptionSuitableForTestResult(request_url).c_str()); | 1067 DescriptionSuitableForTestResult(request_url).c_str()); |
1070 delegate_->printMessage(", main document URL "); | 1068 delegate_->PrintMessage(", main document URL "); |
1071 delegate_->printMessage(URLDescription(main_document_url).c_str()); | 1069 delegate_->PrintMessage(URLDescription(main_document_url).c_str()); |
1072 delegate_->printMessage(", http method "); | 1070 delegate_->PrintMessage(", http method "); |
1073 delegate_->printMessage(request.httpMethod().utf8().data()); | 1071 delegate_->PrintMessage(request.httpMethod().utf8().data()); |
1074 delegate_->printMessage("> redirectResponse "); | 1072 delegate_->PrintMessage("> redirectResponse "); |
1075 PrintResponseDescription(delegate_, redirect_response); | 1073 PrintResponseDescription(delegate_, redirect_response); |
1076 delegate_->printMessage("\n"); | 1074 delegate_->PrintMessage("\n"); |
1077 } | 1075 } |
1078 | 1076 |
1079 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) { | 1077 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) { |
1080 delegate_->printMessage( | 1078 delegate_->PrintMessage( |
1081 DescriptionSuitableForTestResult(request_url).c_str()); | 1079 DescriptionSuitableForTestResult(request_url).c_str()); |
1082 delegate_->printMessage(" has priority "); | 1080 delegate_->PrintMessage(" has priority "); |
1083 delegate_->printMessage(PriorityDescription(request.priority())); | 1081 delegate_->PrintMessage(PriorityDescription(request.priority())); |
1084 delegate_->printMessage("\n"); | 1082 delegate_->PrintMessage("\n"); |
1085 } | 1083 } |
1086 | 1084 |
1087 if (test_interfaces_->GetTestRunner()->httpHeadersToClear()) { | 1085 if (test_interfaces_->GetTestRunner()->httpHeadersToClear()) { |
1088 const std::set<std::string>* clearHeaders = | 1086 const std::set<std::string>* clearHeaders = |
1089 test_interfaces_->GetTestRunner()->httpHeadersToClear(); | 1087 test_interfaces_->GetTestRunner()->httpHeadersToClear(); |
1090 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); | 1088 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); |
1091 header != clearHeaders->end(); | 1089 header != clearHeaders->end(); |
1092 ++header) | 1090 ++header) |
1093 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); | 1091 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); |
1094 } | 1092 } |
1095 | 1093 |
1096 std::string host = url.host(); | 1094 std::string host = url.host(); |
1097 if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { | 1095 if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) { |
1098 if (!IsLocalHost(host) && !IsTestHost(host) && !HostIsUsedBySomeTestsToGener
ateError(host) && | 1096 if (!IsLocalHost(host) && !IsTestHost(host) && |
| 1097 !HostIsUsedBySomeTestsToGenerateError(host) && |
1099 ((!main_document_url.SchemeIs("http") && | 1098 ((!main_document_url.SchemeIs("http") && |
1100 !main_document_url.SchemeIs("https")) || | 1099 !main_document_url.SchemeIs("https")) || |
1101 IsLocalHost(main_document_url.host())) && | 1100 IsLocalHost(main_document_url.host())) && |
1102 !delegate_->allowExternalPages()) { | 1101 !delegate_->AllowExternalPages()) { |
1103 delegate_->printMessage(std::string("Blocked access to external URL ") + | 1102 delegate_->PrintMessage(std::string("Blocked access to external URL ") + |
1104 request_url + "\n"); | 1103 request_url + "\n"); |
1105 BlockRequest(request); | 1104 BlockRequest(request); |
1106 return; | 1105 return; |
1107 } | 1106 } |
1108 } | 1107 } |
1109 | 1108 |
1110 // Set the new substituted URL. | 1109 // Set the new substituted URL. |
1111 request.setURL(delegate_->rewriteLayoutTestsURL(request.url().spec())); | 1110 request.setURL(delegate_->RewriteLayoutTestsURL(request.url().spec())); |
1112 } | 1111 } |
1113 | 1112 |
1114 void WebTestProxyBase::DidReceiveResponse( | 1113 void WebTestProxyBase::DidReceiveResponse( |
1115 blink::WebLocalFrame* frame, | 1114 blink::WebLocalFrame* frame, |
1116 unsigned identifier, | 1115 unsigned identifier, |
1117 const blink::WebURLResponse& response) { | 1116 const blink::WebURLResponse& response) { |
1118 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { | 1117 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { |
1119 if (resource_identifier_map_.find(identifier) == | 1118 if (resource_identifier_map_.find(identifier) == |
1120 resource_identifier_map_.end()) | 1119 resource_identifier_map_.end()) |
1121 delegate_->printMessage("<unknown>"); | 1120 delegate_->PrintMessage("<unknown>"); |
1122 else | 1121 else |
1123 delegate_->printMessage(resource_identifier_map_[identifier]); | 1122 delegate_->PrintMessage(resource_identifier_map_[identifier]); |
1124 delegate_->printMessage(" - didReceiveResponse "); | 1123 delegate_->PrintMessage(" - didReceiveResponse "); |
1125 PrintResponseDescription(delegate_, response); | 1124 PrintResponseDescription(delegate_, response); |
1126 delegate_->printMessage("\n"); | 1125 delegate_->PrintMessage("\n"); |
1127 } | 1126 } |
1128 if (test_interfaces_->GetTestRunner() | 1127 if (test_interfaces_->GetTestRunner() |
1129 ->shouldDumpResourceResponseMIMETypes()) { | 1128 ->shouldDumpResourceResponseMIMETypes()) { |
1130 GURL url = response.url(); | 1129 GURL url = response.url(); |
1131 blink::WebString mime_type = response.mimeType(); | 1130 blink::WebString mime_type = response.mimeType(); |
1132 delegate_->printMessage(url.ExtractFileName()); | 1131 delegate_->PrintMessage(url.ExtractFileName()); |
1133 delegate_->printMessage(" has MIME type "); | 1132 delegate_->PrintMessage(" has MIME type "); |
1134 // Simulate NSURLResponse's mapping of empty/unknown MIME types to | 1133 // Simulate NSURLResponse's mapping of empty/unknown MIME types to |
1135 // application/octet-stream | 1134 // application/octet-stream |
1136 delegate_->printMessage(mime_type.isEmpty() ? "application/octet-stream" | 1135 delegate_->PrintMessage(mime_type.isEmpty() ? "application/octet-stream" |
1137 : mime_type.utf8().data()); | 1136 : mime_type.utf8().data()); |
1138 delegate_->printMessage("\n"); | 1137 delegate_->PrintMessage("\n"); |
1139 } | 1138 } |
1140 } | 1139 } |
1141 | 1140 |
1142 void WebTestProxyBase::DidChangeResourcePriority( | 1141 void WebTestProxyBase::DidChangeResourcePriority( |
1143 blink::WebLocalFrame* frame, | 1142 blink::WebLocalFrame* frame, |
1144 unsigned identifier, | 1143 unsigned identifier, |
1145 const blink::WebURLRequest::Priority& priority, | 1144 const blink::WebURLRequest::Priority& priority, |
1146 int intra_priority_value) { | 1145 int intra_priority_value) { |
1147 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) { | 1146 if (test_interfaces_->GetTestRunner()->shouldDumpResourcePriorities()) { |
1148 if (resource_identifier_map_.find(identifier) == | 1147 if (resource_identifier_map_.find(identifier) == |
1149 resource_identifier_map_.end()) | 1148 resource_identifier_map_.end()) |
1150 delegate_->printMessage("<unknown>"); | 1149 delegate_->PrintMessage("<unknown>"); |
1151 else | 1150 else |
1152 delegate_->printMessage(resource_identifier_map_[identifier]); | 1151 delegate_->PrintMessage(resource_identifier_map_[identifier]); |
1153 delegate_->printMessage( | 1152 delegate_->PrintMessage( |
1154 base::StringPrintf(" changed priority to %s, intra_priority %d\n", | 1153 base::StringPrintf(" changed priority to %s, intra_priority %d\n", |
1155 PriorityDescription(priority).c_str(), | 1154 PriorityDescription(priority).c_str(), |
1156 intra_priority_value)); | 1155 intra_priority_value)); |
1157 } | 1156 } |
1158 } | 1157 } |
1159 | 1158 |
1160 void WebTestProxyBase::DidFinishResourceLoad(blink::WebLocalFrame* frame, | 1159 void WebTestProxyBase::DidFinishResourceLoad(blink::WebLocalFrame* frame, |
1161 unsigned identifier) { | 1160 unsigned identifier) { |
1162 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { | 1161 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { |
1163 if (resource_identifier_map_.find(identifier) == | 1162 if (resource_identifier_map_.find(identifier) == |
1164 resource_identifier_map_.end()) | 1163 resource_identifier_map_.end()) |
1165 delegate_->printMessage("<unknown>"); | 1164 delegate_->PrintMessage("<unknown>"); |
1166 else | 1165 else |
1167 delegate_->printMessage(resource_identifier_map_[identifier]); | 1166 delegate_->PrintMessage(resource_identifier_map_[identifier]); |
1168 delegate_->printMessage(" - didFinishLoading\n"); | 1167 delegate_->PrintMessage(" - didFinishLoading\n"); |
1169 } | 1168 } |
1170 resource_identifier_map_.erase(identifier); | 1169 resource_identifier_map_.erase(identifier); |
1171 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) | 1170 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) |
1172 CheckDone(frame, ResourceLoadCompleted); | 1171 CheckDone(frame, ResourceLoadCompleted); |
1173 #endif | 1172 #endif |
1174 } | 1173 } |
1175 | 1174 |
1176 void WebTestProxyBase::DidAddMessageToConsole( | 1175 void WebTestProxyBase::DidAddMessageToConsole( |
1177 const blink::WebConsoleMessage& message, | 1176 const blink::WebConsoleMessage& message, |
1178 const blink::WebString& source_name, | 1177 const blink::WebString& source_name, |
(...skipping 12 matching lines...) Expand all Loading... |
1191 case blink::WebConsoleMessage::LevelInfo: | 1190 case blink::WebConsoleMessage::LevelInfo: |
1192 level = "INFO"; | 1191 level = "INFO"; |
1193 break; | 1192 break; |
1194 case blink::WebConsoleMessage::LevelWarning: | 1193 case blink::WebConsoleMessage::LevelWarning: |
1195 level = "WARNING"; | 1194 level = "WARNING"; |
1196 break; | 1195 break; |
1197 case blink::WebConsoleMessage::LevelError: | 1196 case blink::WebConsoleMessage::LevelError: |
1198 level = "ERROR"; | 1197 level = "ERROR"; |
1199 break; | 1198 break; |
1200 } | 1199 } |
1201 delegate_->printMessage(std::string("CONSOLE ") + level + ": "); | 1200 delegate_->PrintMessage(std::string("CONSOLE ") + level + ": "); |
1202 if (source_line) { | 1201 if (source_line) { |
1203 delegate_->printMessage(base::StringPrintf("line %d: ", source_line)); | 1202 delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line)); |
1204 } | 1203 } |
1205 if (!message.text.isEmpty()) { | 1204 if (!message.text.isEmpty()) { |
1206 std::string new_message; | 1205 std::string new_message; |
1207 new_message = message.text.utf8(); | 1206 new_message = message.text.utf8(); |
1208 size_t file_protocol = new_message.find("file://"); | 1207 size_t file_protocol = new_message.find("file://"); |
1209 if (file_protocol != std::string::npos) { | 1208 if (file_protocol != std::string::npos) { |
1210 new_message = new_message.substr(0, file_protocol) + | 1209 new_message = new_message.substr(0, file_protocol) + |
1211 URLSuitableForTestResult(new_message.substr(file_protocol)); | 1210 URLSuitableForTestResult(new_message.substr(file_protocol)); |
1212 } | 1211 } |
1213 delegate_->printMessage(new_message); | 1212 delegate_->PrintMessage(new_message); |
1214 } | 1213 } |
1215 delegate_->printMessage(std::string("\n")); | 1214 delegate_->PrintMessage(std::string("\n")); |
1216 } | 1215 } |
1217 | 1216 |
1218 void WebTestProxyBase::CheckDone(blink::WebLocalFrame* frame, | 1217 void WebTestProxyBase::CheckDone(blink::WebLocalFrame* frame, |
1219 CheckDoneReason reason) { | 1218 CheckDoneReason reason) { |
1220 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) | 1219 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) |
1221 return; | 1220 return; |
1222 | 1221 |
1223 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) | 1222 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) |
1224 // Quirk for MHTML prematurely completing on resource load completion. | 1223 // Quirk for MHTML prematurely completing on resource load completion. |
1225 std::string mime_type = frame->dataSource()->response().mimeType().utf8(); | 1224 std::string mime_type = frame->dataSource()->response().mimeType().utf8(); |
1226 if (reason == ResourceLoadCompleted && mime_type == "multipart/related") | 1225 if (reason == ResourceLoadCompleted && mime_type == "multipart/related") |
1227 return; | 1226 return; |
1228 | 1227 |
1229 if (reason != MainResourceLoadFailed && | 1228 if (reason != MainResourceLoadFailed && |
1230 (frame->isResourceLoadInProgress() || frame->isLoading())) | 1229 (frame->isResourceLoadInProgress() || frame->isLoading())) |
1231 return; | 1230 return; |
1232 #endif | 1231 #endif |
1233 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); | 1232 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); |
1234 } | 1233 } |
1235 | 1234 |
1236 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( | 1235 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( |
1237 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 1236 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
1238 blink::WebNavigationPolicy result; | 1237 blink::WebNavigationPolicy result; |
1239 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled()) | 1238 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled()) |
1240 return info.defaultPolicy; | 1239 return info.defaultPolicy; |
1241 | 1240 |
1242 delegate_->printMessage(std::string("Policy delegate: attempt to load ") + | 1241 delegate_->PrintMessage( |
1243 URLDescription(info.urlRequest.url()) + | 1242 std::string("Policy delegate: attempt to load ") + |
1244 " with navigation type '" + | 1243 URLDescription(info.urlRequest.url()) + " with navigation type '" + |
1245 WebNavigationTypeToString(info.navigationType) + "'\n"
); | 1244 WebNavigationTypeToString(info.navigationType) + "'\n"); |
1246 if (test_interfaces_->GetTestRunner()->policyDelegateIsPermissive()) | 1245 if (test_interfaces_->GetTestRunner()->policyDelegateIsPermissive()) |
1247 result = blink::WebNavigationPolicyCurrentTab; | 1246 result = blink::WebNavigationPolicyCurrentTab; |
1248 else | 1247 else |
1249 result = blink::WebNavigationPolicyIgnore; | 1248 result = blink::WebNavigationPolicyIgnore; |
1250 | 1249 |
1251 if (test_interfaces_->GetTestRunner()->policyDelegateShouldNotifyDone()) | 1250 if (test_interfaces_->GetTestRunner()->policyDelegateShouldNotifyDone()) |
1252 test_interfaces_->GetTestRunner()->policyDelegateDone(); | 1251 test_interfaces_->GetTestRunner()->policyDelegateDone(); |
1253 return result; | 1252 return result; |
1254 } | 1253 } |
1255 | 1254 |
1256 bool WebTestProxyBase::WillCheckAndDispatchMessageEvent( | 1255 bool WebTestProxyBase::WillCheckAndDispatchMessageEvent( |
1257 blink::WebLocalFrame* source_frame, | 1256 blink::WebLocalFrame* source_frame, |
1258 blink::WebFrame* target_frame, | 1257 blink::WebFrame* target_frame, |
1259 blink::WebSecurityOrigin target, | 1258 blink::WebSecurityOrigin target, |
1260 blink::WebDOMMessageEvent event) { | 1259 blink::WebDOMMessageEvent event) { |
1261 if (test_interfaces_->GetTestRunner()->shouldInterceptPostMessage()) { | 1260 if (test_interfaces_->GetTestRunner()->shouldInterceptPostMessage()) { |
1262 delegate_->printMessage("intercepted postMessage\n"); | 1261 delegate_->PrintMessage("intercepted postMessage\n"); |
1263 return true; | 1262 return true; |
1264 } | 1263 } |
1265 | 1264 |
1266 return false; | 1265 return false; |
1267 } | 1266 } |
1268 | 1267 |
1269 void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) { | 1268 void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) { |
1270 if (test_interfaces_->GetTestRunner()->shouldDumpSpellCheckCallbacks()) { | 1269 if (test_interfaces_->GetTestRunner()->shouldDumpSpellCheckCallbacks()) { |
1271 delegate_->printMessage(std::string("SpellCheckEvent: ") + | 1270 delegate_->PrintMessage(std::string("SpellCheckEvent: ") + |
1272 event_name.utf8().data() + "\n"); | 1271 event_name.utf8().data() + "\n"); |
1273 } | 1272 } |
1274 } | 1273 } |
1275 | 1274 |
1276 void WebTestProxyBase::ResetInputMethod() { | 1275 void WebTestProxyBase::ResetInputMethod() { |
1277 // If a composition text exists, then we need to let the browser process | 1276 // If a composition text exists, then we need to let the browser process |
1278 // to cancel the input method's ongoing composition session. | 1277 // to cancel the input method's ongoing composition session. |
1279 if (web_widget_) | 1278 if (web_widget_) |
1280 web_widget_->confirmComposition(); | 1279 web_widget_->confirmComposition(); |
1281 } | 1280 } |
1282 | 1281 |
1283 blink::WebString WebTestProxyBase::acceptLanguages() { | 1282 blink::WebString WebTestProxyBase::acceptLanguages() { |
1284 return blink::WebString::fromUTF8(accept_languages_); | 1283 return blink::WebString::fromUTF8(accept_languages_); |
1285 } | 1284 } |
1286 | 1285 |
1287 MockWebPushClient* WebTestProxyBase::GetPushClientMock() { | 1286 MockWebPushClient* WebTestProxyBase::GetPushClientMock() { |
1288 if (!push_client_.get()) | 1287 if (!push_client_.get()) |
1289 push_client_.reset(new MockWebPushClient); | 1288 push_client_.reset(new MockWebPushClient); |
1290 return push_client_.get(); | 1289 return push_client_.get(); |
1291 } | 1290 } |
1292 | 1291 |
1293 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { | 1292 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { |
1294 return GetPushClientMock(); | 1293 return GetPushClientMock(); |
1295 } | 1294 } |
1296 | 1295 |
1297 } // namespace content | 1296 } // namespace content |
OLD | NEW |