OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/WebTestProxy.h" | 5 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
6 | 6 |
7 #include <cctype> | 7 #include <cctype> |
8 | 8 |
9 #include "content/shell/renderer/test_runner/event_sender.h" | 9 #include "content/shell/renderer/test_runner/event_sender.h" |
10 #include "content/shell/renderer/test_runner/MockColorChooser.h" | 10 #include "content/shell/renderer/test_runner/MockColorChooser.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 28 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
29 #include "third_party/WebKit/public/web/WebAXEnums.h" | 29 #include "third_party/WebKit/public/web/WebAXEnums.h" |
30 #include "third_party/WebKit/public/web/WebAXObject.h" | 30 #include "third_party/WebKit/public/web/WebAXObject.h" |
31 #include "third_party/WebKit/public/web/WebCachedURLRequest.h" | 31 #include "third_party/WebKit/public/web/WebCachedURLRequest.h" |
32 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 32 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
33 #include "third_party/WebKit/public/web/WebDataSource.h" | 33 #include "third_party/WebKit/public/web/WebDataSource.h" |
34 #include "third_party/WebKit/public/web/WebDocument.h" | 34 #include "third_party/WebKit/public/web/WebDocument.h" |
35 #include "third_party/WebKit/public/web/WebElement.h" | 35 #include "third_party/WebKit/public/web/WebElement.h" |
36 #include "third_party/WebKit/public/web/WebFrame.h" | 36 #include "third_party/WebKit/public/web/WebFrame.h" |
37 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 37 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 38 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
38 #include "third_party/WebKit/public/web/WebMIDIClientMock.h" | 39 #include "third_party/WebKit/public/web/WebMIDIClientMock.h" |
39 #include "third_party/WebKit/public/web/WebNode.h" | 40 #include "third_party/WebKit/public/web/WebNode.h" |
40 #include "third_party/WebKit/public/web/WebPluginParams.h" | 41 #include "third_party/WebKit/public/web/WebPluginParams.h" |
41 #include "third_party/WebKit/public/web/WebPrintParams.h" | 42 #include "third_party/WebKit/public/web/WebPrintParams.h" |
42 #include "third_party/WebKit/public/web/WebRange.h" | 43 #include "third_party/WebKit/public/web/WebRange.h" |
43 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 44 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
44 #include "third_party/WebKit/public/web/WebView.h" | 45 #include "third_party/WebKit/public/web/WebView.h" |
45 | 46 |
46 using namespace blink; | 47 using namespace blink; |
47 using namespace std; | 48 using namespace std; |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 if (element.hasAttribute("id")) { | 865 if (element.hasAttribute("id")) { |
865 message += " - id:"; | 866 message += " - id:"; |
866 message += element.getAttribute("id").utf8().data(); | 867 message += element.getAttribute("id").utf8().data(); |
867 } | 868 } |
868 } | 869 } |
869 | 870 |
870 m_delegate->printMessage(message + "\n"); | 871 m_delegate->printMessage(message + "\n"); |
871 } | 872 } |
872 } | 873 } |
873 | 874 |
874 void WebTestProxyBase::startDragging(WebFrame*, const WebDragData& data, WebDrag
OperationsMask mask, const WebImage&, const WebPoint&) | 875 void WebTestProxyBase::startDragging(WebLocalFrame*, |
875 { | 876 const WebDragData& data, |
| 877 WebDragOperationsMask mask, |
| 878 const WebImage&, |
| 879 const WebPoint&) { |
876 // When running a test, we need to fake a drag drop operation otherwise | 880 // When running a test, we need to fake a drag drop operation otherwise |
877 // Windows waits for real mouse events to know when the drag is over. | 881 // Windows waits for real mouse events to know when the drag is over. |
878 m_testInterfaces->eventSender()->DoDragDrop(data, mask); | 882 m_testInterfaces->eventSender()->DoDragDrop(data, mask); |
879 } | 883 } |
880 | 884 |
881 // The output from these methods in layout test mode should match that | 885 // The output from these methods in layout test mode should match that |
882 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. | 886 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. |
883 | 887 |
884 void WebTestProxyBase::didChangeSelection(bool isEmptySelection) | 888 void WebTestProxyBase::didChangeSelection(bool isEmptySelection) |
885 { | 889 { |
886 if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) | 890 if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) |
887 m_delegate->printMessage("EDITING DELEGATE: webViewDidChangeSelection:We
bViewDidChangeSelectionNotification\n"); | 891 m_delegate->printMessage("EDITING DELEGATE: webViewDidChangeSelection:We
bViewDidChangeSelectionNotification\n"); |
888 } | 892 } |
889 | 893 |
890 void WebTestProxyBase::didChangeContents() | 894 void WebTestProxyBase::didChangeContents() |
891 { | 895 { |
892 if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) | 896 if (m_testInterfaces->testRunner()->shouldDumpEditingCallbacks()) |
893 m_delegate->printMessage("EDITING DELEGATE: webViewDidChange:WebViewDidC
hangeNotification\n"); | 897 m_delegate->printMessage("EDITING DELEGATE: webViewDidChange:WebViewDidC
hangeNotification\n"); |
894 } | 898 } |
895 | 899 |
896 bool WebTestProxyBase::createView(WebFrame*, const WebURLRequest& request, const
WebWindowFeatures&, const WebString&, WebNavigationPolicy, bool) | 900 bool WebTestProxyBase::createView(WebLocalFrame*, |
897 { | 901 const WebURLRequest& request, |
| 902 const WebWindowFeatures&, |
| 903 const WebString&, |
| 904 WebNavigationPolicy, |
| 905 bool) { |
898 if (!m_testInterfaces->testRunner()->canOpenWindows()) | 906 if (!m_testInterfaces->testRunner()->canOpenWindows()) |
899 return false; | 907 return false; |
900 if (m_testInterfaces->testRunner()->shouldDumpCreateView()) | 908 if (m_testInterfaces->testRunner()->shouldDumpCreateView()) |
901 m_delegate->printMessage(string("createView(") + URLDescription(request.
url()) + ")\n"); | 909 m_delegate->printMessage(string("createView(") + URLDescription(request.
url()) + ")\n"); |
902 return true; | 910 return true; |
903 } | 911 } |
904 | 912 |
905 WebPlugin* WebTestProxyBase::createPlugin(WebFrame* frame, const WebPluginParams
& params) | 913 WebPlugin* WebTestProxyBase::createPlugin(WebLocalFrame* frame, |
906 { | 914 const WebPluginParams& params) { |
907 if (TestPlugin::isSupportedMimeType(params.mimeType)) | 915 if (TestPlugin::isSupportedMimeType(params.mimeType)) |
908 return TestPlugin::create(frame, params, m_delegate); | 916 return TestPlugin::create(frame, params, m_delegate); |
909 return 0; | 917 return 0; |
910 } | 918 } |
911 | 919 |
912 void WebTestProxyBase::setStatusText(const WebString& text) | 920 void WebTestProxyBase::setStatusText(const WebString& text) |
913 { | 921 { |
914 if (!m_testInterfaces->testRunner()->shouldDumpStatusCallbacks()) | 922 if (!m_testInterfaces->testRunner()->shouldDumpStatusCallbacks()) |
915 return; | 923 return; |
916 m_delegate->printMessage(string("UI DELEGATE STATUS CALLBACK: setStatusText:
") + text.utf8().data() + "\n"); | 924 m_delegate->printMessage(string("UI DELEGATE STATUS CALLBACK: setStatusText:
") + text.utf8().data() + "\n"); |
917 } | 925 } |
918 | 926 |
919 void WebTestProxyBase::didStopLoading() | 927 void WebTestProxyBase::didStopLoading() |
920 { | 928 { |
921 if (m_testInterfaces->testRunner()->shouldDumpProgressFinishedCallback()) | 929 if (m_testInterfaces->testRunner()->shouldDumpProgressFinishedCallback()) |
922 m_delegate->printMessage("postProgressFinishedNotification\n"); | 930 m_delegate->printMessage("postProgressFinishedNotification\n"); |
923 } | 931 } |
924 | 932 |
925 void WebTestProxyBase::showContextMenu(WebFrame*, const WebContextMenuData& cont
extMenuData) | 933 void WebTestProxyBase::showContextMenu( |
926 { | 934 WebLocalFrame*, |
| 935 const WebContextMenuData& contextMenuData) { |
927 m_testInterfaces->eventSender()->SetContextMenuData(contextMenuData); | 936 m_testInterfaces->eventSender()->SetContextMenuData(contextMenuData); |
928 } | 937 } |
929 | 938 |
930 WebUserMediaClient* WebTestProxyBase::userMediaClient() | 939 WebUserMediaClient* WebTestProxyBase::userMediaClient() |
931 { | 940 { |
932 if (!m_userMediaClient.get()) | 941 if (!m_userMediaClient.get()) |
933 m_userMediaClient.reset(new WebUserMediaClientMock(m_delegate)); | 942 m_userMediaClient.reset(new WebUserMediaClientMock(m_delegate)); |
934 return m_userMediaClient.get(); | 943 return m_userMediaClient.get(); |
935 } | 944 } |
936 | 945 |
937 // Simulate a print by going into print mode and then exit straight away. | 946 // Simulate a print by going into print mode and then exit straight away. |
938 void WebTestProxyBase::printPage(WebFrame* frame) | 947 void WebTestProxyBase::printPage(WebLocalFrame* frame) { |
939 { | |
940 WebSize pageSizeInPixels = webWidget()->size(); | 948 WebSize pageSizeInPixels = webWidget()->size(); |
941 if (pageSizeInPixels.isEmpty()) | 949 if (pageSizeInPixels.isEmpty()) |
942 return; | 950 return; |
943 WebPrintParams printParams(pageSizeInPixels); | 951 WebPrintParams printParams(pageSizeInPixels); |
944 frame->printBegin(printParams); | 952 frame->printBegin(printParams); |
945 frame->printEnd(); | 953 frame->printEnd(); |
946 } | 954 } |
947 | 955 |
948 WebNotificationPresenter* WebTestProxyBase::notificationPresenter() | 956 WebNotificationPresenter* WebTestProxyBase::notificationPresenter() |
949 { | 957 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 void WebTestProxyBase::didCloseChooser() | 1020 void WebTestProxyBase::didCloseChooser() |
1013 { | 1021 { |
1014 m_chooserCount--; | 1022 m_chooserCount--; |
1015 } | 1023 } |
1016 | 1024 |
1017 bool WebTestProxyBase::isChooserShown() | 1025 bool WebTestProxyBase::isChooserShown() |
1018 { | 1026 { |
1019 return 0 < m_chooserCount; | 1027 return 0 < m_chooserCount; |
1020 } | 1028 } |
1021 | 1029 |
1022 void WebTestProxyBase::didStartProvisionalLoad(WebFrame* frame) | 1030 void WebTestProxyBase::didStartProvisionalLoad(WebLocalFrame* frame) { |
1023 { | |
1024 if (!m_testInterfaces->testRunner()->topLoadingFrame()) | 1031 if (!m_testInterfaces->testRunner()->topLoadingFrame()) |
1025 m_testInterfaces->testRunner()->setTopLoadingFrame(frame, false); | 1032 m_testInterfaces->testRunner()->setTopLoadingFrame(frame, false); |
1026 | 1033 |
1027 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1034 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1028 printFrameDescription(m_delegate, frame); | 1035 printFrameDescription(m_delegate, frame); |
1029 m_delegate->printMessage(" - didStartProvisionalLoadForFrame\n"); | 1036 m_delegate->printMessage(" - didStartProvisionalLoadForFrame\n"); |
1030 } | 1037 } |
1031 | 1038 |
1032 if (m_testInterfaces->testRunner()->shouldDumpUserGestureInFrameLoadCallback
s()) | 1039 if (m_testInterfaces->testRunner()->shouldDumpUserGestureInFrameLoadCallback
s()) |
1033 printFrameUserGestureStatus(m_delegate, frame, " - in didStartProvisiona
lLoadForFrame\n"); | 1040 printFrameUserGestureStatus(m_delegate, frame, " - in didStartProvisiona
lLoadForFrame\n"); |
1034 } | 1041 } |
1035 | 1042 |
1036 void WebTestProxyBase::didReceiveServerRedirectForProvisionalLoad(WebFrame* fram
e) | 1043 void WebTestProxyBase::didReceiveServerRedirectForProvisionalLoad( |
1037 { | 1044 WebLocalFrame* frame) { |
1038 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1045 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1039 printFrameDescription(m_delegate, frame); | 1046 printFrameDescription(m_delegate, frame); |
1040 m_delegate->printMessage(" - didReceiveServerRedirectForProvisionalLoadF
orFrame\n"); | 1047 m_delegate->printMessage(" - didReceiveServerRedirectForProvisionalLoadF
orFrame\n"); |
1041 } | 1048 } |
1042 } | 1049 } |
1043 | 1050 |
1044 bool WebTestProxyBase::didFailProvisionalLoad(WebFrame* frame, const WebURLError
&) | 1051 bool WebTestProxyBase::didFailProvisionalLoad(WebLocalFrame* frame, |
1045 { | 1052 const WebURLError&) { |
1046 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1053 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1047 printFrameDescription(m_delegate, frame); | 1054 printFrameDescription(m_delegate, frame); |
1048 m_delegate->printMessage(" - didFailProvisionalLoadWithError\n"); | 1055 m_delegate->printMessage(" - didFailProvisionalLoadWithError\n"); |
1049 } | 1056 } |
1050 locationChangeDone(frame); | 1057 locationChangeDone(frame); |
1051 return !frame->provisionalDataSource(); | 1058 return !frame->provisionalDataSource(); |
1052 } | 1059 } |
1053 | 1060 |
1054 void WebTestProxyBase::didCommitProvisionalLoad(WebFrame* frame, bool) | 1061 void WebTestProxyBase::didCommitProvisionalLoad(WebLocalFrame* frame, bool) { |
1055 { | |
1056 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1062 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1057 printFrameDescription(m_delegate, frame); | 1063 printFrameDescription(m_delegate, frame); |
1058 m_delegate->printMessage(" - didCommitLoadForFrame\n"); | 1064 m_delegate->printMessage(" - didCommitLoadForFrame\n"); |
1059 } | 1065 } |
1060 } | 1066 } |
1061 | 1067 |
1062 void WebTestProxyBase::didReceiveTitle(WebFrame* frame, const WebString& title,
WebTextDirection direction) | 1068 void WebTestProxyBase::didReceiveTitle(WebLocalFrame* frame, |
1063 { | 1069 const WebString& title, |
| 1070 WebTextDirection direction) { |
1064 WebCString title8 = title.utf8(); | 1071 WebCString title8 = title.utf8(); |
1065 | 1072 |
1066 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1073 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1067 printFrameDescription(m_delegate, frame); | 1074 printFrameDescription(m_delegate, frame); |
1068 m_delegate->printMessage(string(" - didReceiveTitle: ") + title8.data()
+ "\n"); | 1075 m_delegate->printMessage(string(" - didReceiveTitle: ") + title8.data()
+ "\n"); |
1069 } | 1076 } |
1070 | 1077 |
1071 if (m_testInterfaces->testRunner()->shouldDumpTitleChanges()) | 1078 if (m_testInterfaces->testRunner()->shouldDumpTitleChanges()) |
1072 m_delegate->printMessage(string("TITLE CHANGED: '") + title8.data() + "'
\n"); | 1079 m_delegate->printMessage(string("TITLE CHANGED: '") + title8.data() + "'
\n"); |
1073 } | 1080 } |
1074 | 1081 |
1075 void WebTestProxyBase::didChangeIcon(WebFrame* frame, WebIconURL::Type) | 1082 void WebTestProxyBase::didChangeIcon(WebLocalFrame* frame, WebIconURL::Type) { |
1076 { | |
1077 if (m_testInterfaces->testRunner()->shouldDumpIconChanges()) { | 1083 if (m_testInterfaces->testRunner()->shouldDumpIconChanges()) { |
1078 printFrameDescription(m_delegate, frame); | 1084 printFrameDescription(m_delegate, frame); |
1079 m_delegate->printMessage(string(" - didChangeIcons\n")); | 1085 m_delegate->printMessage(string(" - didChangeIcons\n")); |
1080 } | 1086 } |
1081 } | 1087 } |
1082 | 1088 |
1083 void WebTestProxyBase::didFinishDocumentLoad(WebFrame* frame) | 1089 void WebTestProxyBase::didFinishDocumentLoad(WebLocalFrame* frame) { |
1084 { | |
1085 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1090 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1086 printFrameDescription(m_delegate, frame); | 1091 printFrameDescription(m_delegate, frame); |
1087 m_delegate->printMessage(" - didFinishDocumentLoadForFrame\n"); | 1092 m_delegate->printMessage(" - didFinishDocumentLoadForFrame\n"); |
1088 } else { | 1093 } else { |
1089 unsigned pendingUnloadEvents = frame->unloadListenerCount(); | 1094 unsigned pendingUnloadEvents = frame->unloadListenerCount(); |
1090 if (pendingUnloadEvents) { | 1095 if (pendingUnloadEvents) { |
1091 printFrameDescription(m_delegate, frame); | 1096 printFrameDescription(m_delegate, frame); |
1092 char buffer[100]; | 1097 char buffer[100]; |
1093 snprintf(buffer, sizeof(buffer), " - has %u onunload handler(s)\n",
pendingUnloadEvents); | 1098 snprintf(buffer, sizeof(buffer), " - has %u onunload handler(s)\n",
pendingUnloadEvents); |
1094 m_delegate->printMessage(buffer); | 1099 m_delegate->printMessage(buffer); |
1095 } | 1100 } |
1096 } | 1101 } |
1097 } | 1102 } |
1098 | 1103 |
1099 void WebTestProxyBase::didHandleOnloadEvents(WebFrame* frame) | 1104 void WebTestProxyBase::didHandleOnloadEvents(WebLocalFrame* frame) { |
1100 { | |
1101 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1105 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1102 printFrameDescription(m_delegate, frame); | 1106 printFrameDescription(m_delegate, frame); |
1103 m_delegate->printMessage(" - didHandleOnloadEventsForFrame\n"); | 1107 m_delegate->printMessage(" - didHandleOnloadEventsForFrame\n"); |
1104 } | 1108 } |
1105 } | 1109 } |
1106 | 1110 |
1107 void WebTestProxyBase::didFailLoad(WebFrame* frame, const WebURLError&) | 1111 void WebTestProxyBase::didFailLoad(WebLocalFrame* frame, const WebURLError&) { |
1108 { | |
1109 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1112 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1110 printFrameDescription(m_delegate, frame); | 1113 printFrameDescription(m_delegate, frame); |
1111 m_delegate->printMessage(" - didFailLoadWithError\n"); | 1114 m_delegate->printMessage(" - didFailLoadWithError\n"); |
1112 } | 1115 } |
1113 locationChangeDone(frame); | 1116 locationChangeDone(frame); |
1114 } | 1117 } |
1115 | 1118 |
1116 void WebTestProxyBase::didFinishLoad(WebFrame* frame) | 1119 void WebTestProxyBase::didFinishLoad(WebLocalFrame* frame) { |
1117 { | |
1118 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { | 1120 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) { |
1119 printFrameDescription(m_delegate, frame); | 1121 printFrameDescription(m_delegate, frame); |
1120 m_delegate->printMessage(" - didFinishLoadForFrame\n"); | 1122 m_delegate->printMessage(" - didFinishLoadForFrame\n"); |
1121 } | 1123 } |
1122 locationChangeDone(frame); | 1124 locationChangeDone(frame); |
1123 } | 1125 } |
1124 | 1126 |
1125 void WebTestProxyBase::didDetectXSS(WebFrame*, const WebURL&, bool) | 1127 void WebTestProxyBase::didDetectXSS(WebLocalFrame*, const WebURL&, bool) { |
1126 { | |
1127 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) | 1128 if (m_testInterfaces->testRunner()->shouldDumpFrameLoadCallbacks()) |
1128 m_delegate->printMessage("didDetectXSS\n"); | 1129 m_delegate->printMessage("didDetectXSS\n"); |
1129 } | 1130 } |
1130 | 1131 |
1131 void WebTestProxyBase::didDispatchPingLoader(WebFrame*, const WebURL& url) | 1132 void WebTestProxyBase::didDispatchPingLoader(WebLocalFrame*, |
1132 { | 1133 const WebURL& url) { |
1133 if (m_testInterfaces->testRunner()->shouldDumpPingLoaderCallbacks()) | 1134 if (m_testInterfaces->testRunner()->shouldDumpPingLoaderCallbacks()) |
1134 m_delegate->printMessage(string("PingLoader dispatched to '") + URLDescr
iption(url).c_str() + "'.\n"); | 1135 m_delegate->printMessage(string("PingLoader dispatched to '") + URLDescr
iption(url).c_str() + "'.\n"); |
1135 } | 1136 } |
1136 | 1137 |
1137 void WebTestProxyBase::willRequestResource(WebFrame* frame, const blink::WebCach
edURLRequest& request) | 1138 void WebTestProxyBase::willRequestResource( |
1138 { | 1139 WebLocalFrame* frame, |
| 1140 const blink::WebCachedURLRequest& request) { |
1139 if (m_testInterfaces->testRunner()->shouldDumpResourceRequestCallbacks()) { | 1141 if (m_testInterfaces->testRunner()->shouldDumpResourceRequestCallbacks()) { |
1140 printFrameDescription(m_delegate, frame); | 1142 printFrameDescription(m_delegate, frame); |
1141 m_delegate->printMessage(string(" - ") + request.initiatorName().utf8().
data()); | 1143 m_delegate->printMessage(string(" - ") + request.initiatorName().utf8().
data()); |
1142 m_delegate->printMessage(string(" requested '") + URLDescription(request
.urlRequest().url()).c_str() + "'\n"); | 1144 m_delegate->printMessage(string(" requested '") + URLDescription(request
.urlRequest().url()).c_str() + "'\n"); |
1143 } | 1145 } |
1144 } | 1146 } |
1145 | 1147 |
1146 void WebTestProxyBase::willSendRequest(WebFrame*, unsigned identifier, blink::We
bURLRequest& request, const blink::WebURLResponse& redirectResponse) | 1148 void WebTestProxyBase::willSendRequest( |
1147 { | 1149 WebLocalFrame*, |
| 1150 unsigned identifier, |
| 1151 blink::WebURLRequest& request, |
| 1152 const blink::WebURLResponse& redirectResponse) { |
1148 // Need to use GURL for host() and SchemeIs() | 1153 // Need to use GURL for host() and SchemeIs() |
1149 GURL url = request.url(); | 1154 GURL url = request.url(); |
1150 string requestURL = url.possibly_invalid_spec(); | 1155 string requestURL = url.possibly_invalid_spec(); |
1151 | 1156 |
1152 GURL mainDocumentURL = request.firstPartyForCookies(); | 1157 GURL mainDocumentURL = request.firstPartyForCookies(); |
1153 | 1158 |
1154 if (redirectResponse.isNull() && (m_testInterfaces->testRunner()->shouldDump
ResourceLoadCallbacks() || m_testInterfaces->testRunner()->shouldDumpResourcePri
orities())) { | 1159 if (redirectResponse.isNull() && (m_testInterfaces->testRunner()->shouldDump
ResourceLoadCallbacks() || m_testInterfaces->testRunner()->shouldDumpResourcePri
orities())) { |
1155 BLINK_ASSERT(m_resourceIdentifierMap.find(identifier) == m_resourceIdent
ifierMap.end()); | 1160 BLINK_ASSERT(m_resourceIdentifierMap.find(identifier) == m_resourceIdent
ifierMap.end()); |
1156 m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(r
equestURL); | 1161 m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(r
equestURL); |
1157 } | 1162 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 m_delegate->printMessage(string("Blocked access to external URL ") +
requestURL + "\n"); | 1198 m_delegate->printMessage(string("Blocked access to external URL ") +
requestURL + "\n"); |
1194 blockRequest(request); | 1199 blockRequest(request); |
1195 return; | 1200 return; |
1196 } | 1201 } |
1197 } | 1202 } |
1198 | 1203 |
1199 // Set the new substituted URL. | 1204 // Set the new substituted URL. |
1200 request.setURL(m_delegate->rewriteLayoutTestsURL(request.url().spec())); | 1205 request.setURL(m_delegate->rewriteLayoutTestsURL(request.url().spec())); |
1201 } | 1206 } |
1202 | 1207 |
1203 void WebTestProxyBase::didReceiveResponse(WebFrame*, unsigned identifier, const
blink::WebURLResponse& response) | 1208 void WebTestProxyBase::didReceiveResponse( |
1204 { | 1209 WebLocalFrame*, |
| 1210 unsigned identifier, |
| 1211 const blink::WebURLResponse& response) { |
1205 if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { | 1212 if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { |
1206 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) | 1213 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) |
1207 m_delegate->printMessage("<unknown>"); | 1214 m_delegate->printMessage("<unknown>"); |
1208 else | 1215 else |
1209 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); | 1216 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
1210 m_delegate->printMessage(" - didReceiveResponse "); | 1217 m_delegate->printMessage(" - didReceiveResponse "); |
1211 printResponseDescription(m_delegate, response); | 1218 printResponseDescription(m_delegate, response); |
1212 m_delegate->printMessage("\n"); | 1219 m_delegate->printMessage("\n"); |
1213 } | 1220 } |
1214 if (m_testInterfaces->testRunner()->shouldDumpResourceResponseMIMETypes()) { | 1221 if (m_testInterfaces->testRunner()->shouldDumpResourceResponseMIMETypes()) { |
1215 GURL url = response.url(); | 1222 GURL url = response.url(); |
1216 WebString mimeType = response.mimeType(); | 1223 WebString mimeType = response.mimeType(); |
1217 m_delegate->printMessage(url.ExtractFileName()); | 1224 m_delegate->printMessage(url.ExtractFileName()); |
1218 m_delegate->printMessage(" has MIME type "); | 1225 m_delegate->printMessage(" has MIME type "); |
1219 // Simulate NSURLResponse's mapping of empty/unknown MIME types to appli
cation/octet-stream | 1226 // Simulate NSURLResponse's mapping of empty/unknown MIME types to appli
cation/octet-stream |
1220 m_delegate->printMessage(mimeType.isEmpty() ? "application/octet-stream"
: mimeType.utf8().data()); | 1227 m_delegate->printMessage(mimeType.isEmpty() ? "application/octet-stream"
: mimeType.utf8().data()); |
1221 m_delegate->printMessage("\n"); | 1228 m_delegate->printMessage("\n"); |
1222 } | 1229 } |
1223 } | 1230 } |
1224 | 1231 |
1225 void WebTestProxyBase::didChangeResourcePriority(WebFrame*, unsigned identifier,
const blink::WebURLRequest::Priority& priority) | 1232 void WebTestProxyBase::didChangeResourcePriority( |
1226 { | 1233 WebLocalFrame*, |
| 1234 unsigned identifier, |
| 1235 const blink::WebURLRequest::Priority& priority) { |
1227 if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) { | 1236 if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) { |
1228 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) | 1237 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) |
1229 m_delegate->printMessage("<unknown>"); | 1238 m_delegate->printMessage("<unknown>"); |
1230 else | 1239 else |
1231 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); | 1240 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
1232 m_delegate->printMessage(" changed priority to "); | 1241 m_delegate->printMessage(" changed priority to "); |
1233 m_delegate->printMessage(PriorityDescription(priority)); | 1242 m_delegate->printMessage(PriorityDescription(priority)); |
1234 m_delegate->printMessage("\n"); | 1243 m_delegate->printMessage("\n"); |
1235 } | 1244 } |
1236 } | 1245 } |
1237 | 1246 |
1238 void WebTestProxyBase::didFinishResourceLoad(WebFrame*, unsigned identifier) | 1247 void WebTestProxyBase::didFinishResourceLoad(WebLocalFrame*, |
1239 { | 1248 unsigned identifier) { |
1240 if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { | 1249 if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) { |
1241 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) | 1250 if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.
end()) |
1242 m_delegate->printMessage("<unknown>"); | 1251 m_delegate->printMessage("<unknown>"); |
1243 else | 1252 else |
1244 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); | 1253 m_delegate->printMessage(m_resourceIdentifierMap[identifier]); |
1245 m_delegate->printMessage(" - didFinishLoading\n"); | 1254 m_delegate->printMessage(" - didFinishLoading\n"); |
1246 } | 1255 } |
1247 m_resourceIdentifierMap.erase(identifier); | 1256 m_resourceIdentifierMap.erase(identifier); |
1248 } | 1257 } |
1249 | 1258 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 size_t fileProtocol = newMessage.find("file://"); | 1291 size_t fileProtocol = newMessage.find("file://"); |
1283 if (fileProtocol != string::npos) { | 1292 if (fileProtocol != string::npos) { |
1284 newMessage = newMessage.substr(0, fileProtocol) | 1293 newMessage = newMessage.substr(0, fileProtocol) |
1285 + urlSuitableForTestResult(newMessage.substr(fileProtocol)); | 1294 + urlSuitableForTestResult(newMessage.substr(fileProtocol)); |
1286 } | 1295 } |
1287 m_delegate->printMessage(newMessage); | 1296 m_delegate->printMessage(newMessage); |
1288 } | 1297 } |
1289 m_delegate->printMessage(string("\n")); | 1298 m_delegate->printMessage(string("\n")); |
1290 } | 1299 } |
1291 | 1300 |
1292 void WebTestProxyBase::runModalAlertDialog(WebFrame*, const WebString& message) | 1301 void WebTestProxyBase::runModalAlertDialog(WebLocalFrame*, |
1293 { | 1302 const WebString& message) { |
1294 m_delegate->printMessage(string("ALERT: ") + message.utf8().data() + "\n"); | 1303 m_delegate->printMessage(string("ALERT: ") + message.utf8().data() + "\n"); |
1295 } | 1304 } |
1296 | 1305 |
1297 bool WebTestProxyBase::runModalConfirmDialog(WebFrame*, const WebString& message
) | 1306 bool WebTestProxyBase::runModalConfirmDialog(WebLocalFrame*, |
1298 { | 1307 const WebString& message) { |
1299 m_delegate->printMessage(string("CONFIRM: ") + message.utf8().data() + "\n")
; | 1308 m_delegate->printMessage(string("CONFIRM: ") + message.utf8().data() + "\n")
; |
1300 return true; | 1309 return true; |
1301 } | 1310 } |
1302 | 1311 |
1303 bool WebTestProxyBase::runModalPromptDialog(WebFrame* frame, const WebString& me
ssage, const WebString& defaultValue, WebString*) | 1312 bool WebTestProxyBase::runModalPromptDialog(WebLocalFrame* frame, |
1304 { | 1313 const WebString& message, |
| 1314 const WebString& defaultValue, |
| 1315 WebString*) { |
1305 m_delegate->printMessage(string("PROMPT: ") + message.utf8().data() + ", def
ault text: " + defaultValue.utf8().data() + "\n"); | 1316 m_delegate->printMessage(string("PROMPT: ") + message.utf8().data() + ", def
ault text: " + defaultValue.utf8().data() + "\n"); |
1306 return true; | 1317 return true; |
1307 } | 1318 } |
1308 | 1319 |
1309 bool WebTestProxyBase::runModalBeforeUnloadDialog(WebFrame*, const WebString& me
ssage) | 1320 bool WebTestProxyBase::runModalBeforeUnloadDialog(WebLocalFrame*, |
1310 { | 1321 const WebString& message) { |
1311 m_delegate->printMessage(string("CONFIRM NAVIGATION: ") + message.utf8().dat
a() + "\n"); | 1322 m_delegate->printMessage(string("CONFIRM NAVIGATION: ") + message.utf8().dat
a() + "\n"); |
1312 return !m_testInterfaces->testRunner()->shouldStayOnPageAfterHandlingBeforeU
nload(); | 1323 return !m_testInterfaces->testRunner()->shouldStayOnPageAfterHandlingBeforeU
nload(); |
1313 } | 1324 } |
1314 | 1325 |
1315 void WebTestProxyBase::locationChangeDone(WebFrame* frame) | 1326 void WebTestProxyBase::locationChangeDone(WebLocalFrame* frame) { |
1316 { | |
1317 if (frame != m_testInterfaces->testRunner()->topLoadingFrame()) | 1327 if (frame != m_testInterfaces->testRunner()->topLoadingFrame()) |
1318 return; | 1328 return; |
1319 m_testInterfaces->testRunner()->setTopLoadingFrame(frame, true); | 1329 m_testInterfaces->testRunner()->setTopLoadingFrame(frame, true); |
1320 } | 1330 } |
1321 | 1331 |
1322 WebNavigationPolicy WebTestProxyBase::decidePolicyForNavigation(WebFrame*, WebDa
taSource::ExtraData*, const WebURLRequest& request, WebNavigationType type, WebN
avigationPolicy defaultPolicy, bool isRedirect) | 1332 WebNavigationPolicy WebTestProxyBase::decidePolicyForNavigation( |
1323 { | 1333 WebLocalFrame*, |
| 1334 WebDataSource::ExtraData*, |
| 1335 const WebURLRequest& request, |
| 1336 WebNavigationType type, |
| 1337 WebNavigationPolicy defaultPolicy, |
| 1338 bool isRedirect) { |
1324 WebNavigationPolicy result; | 1339 WebNavigationPolicy result; |
1325 if (!m_testInterfaces->testRunner()->policyDelegateEnabled()) | 1340 if (!m_testInterfaces->testRunner()->policyDelegateEnabled()) |
1326 return defaultPolicy; | 1341 return defaultPolicy; |
1327 | 1342 |
1328 m_delegate->printMessage(string("Policy delegate: attempt to load ") + URLDe
scription(request.url()) + " with navigation type '" + webNavigationTypeToString
(type) + "'\n"); | 1343 m_delegate->printMessage(string("Policy delegate: attempt to load ") + URLDe
scription(request.url()) + " with navigation type '" + webNavigationTypeToString
(type) + "'\n"); |
1329 if (m_testInterfaces->testRunner()->policyDelegateIsPermissive()) | 1344 if (m_testInterfaces->testRunner()->policyDelegateIsPermissive()) |
1330 result = blink::WebNavigationPolicyCurrentTab; | 1345 result = blink::WebNavigationPolicyCurrentTab; |
1331 else | 1346 else |
1332 result = blink::WebNavigationPolicyIgnore; | 1347 result = blink::WebNavigationPolicyIgnore; |
1333 | 1348 |
1334 if (m_testInterfaces->testRunner()->policyDelegateShouldNotifyDone()) | 1349 if (m_testInterfaces->testRunner()->policyDelegateShouldNotifyDone()) |
1335 m_testInterfaces->testRunner()->policyDelegateDone(); | 1350 m_testInterfaces->testRunner()->policyDelegateDone(); |
1336 return result; | 1351 return result; |
1337 } | 1352 } |
1338 | 1353 |
1339 bool WebTestProxyBase::willCheckAndDispatchMessageEvent(WebFrame*, WebFrame*, We
bSecurityOrigin, WebDOMMessageEvent) | 1354 bool WebTestProxyBase::willCheckAndDispatchMessageEvent(WebLocalFrame*, |
1340 { | 1355 WebFrame*, |
| 1356 WebSecurityOrigin, |
| 1357 WebDOMMessageEvent) { |
1341 if (m_testInterfaces->testRunner()->shouldInterceptPostMessage()) { | 1358 if (m_testInterfaces->testRunner()->shouldInterceptPostMessage()) { |
1342 m_delegate->printMessage("intercepted postMessage\n"); | 1359 m_delegate->printMessage("intercepted postMessage\n"); |
1343 return true; | 1360 return true; |
1344 } | 1361 } |
1345 | 1362 |
1346 return false; | 1363 return false; |
1347 } | 1364 } |
1348 | 1365 |
1349 void WebTestProxyBase::postSpellCheckEvent(const WebString& eventName) | 1366 void WebTestProxyBase::postSpellCheckEvent(const WebString& eventName) |
1350 { | 1367 { |
1351 if (m_testInterfaces->testRunner()->shouldDumpSpellCheckCallbacks()) { | 1368 if (m_testInterfaces->testRunner()->shouldDumpSpellCheckCallbacks()) { |
1352 m_delegate->printMessage(string("SpellCheckEvent: ") + eventName.utf8().
data() + "\n"); | 1369 m_delegate->printMessage(string("SpellCheckEvent: ") + eventName.utf8().
data() + "\n"); |
1353 } | 1370 } |
1354 } | 1371 } |
1355 | 1372 |
1356 void WebTestProxyBase::resetInputMethod() | 1373 void WebTestProxyBase::resetInputMethod() |
1357 { | 1374 { |
1358 // If a composition text exists, then we need to let the browser process | 1375 // If a composition text exists, then we need to let the browser process |
1359 // to cancel the input method's ongoing composition session. | 1376 // to cancel the input method's ongoing composition session. |
1360 if (m_webWidget) | 1377 if (m_webWidget) |
1361 m_webWidget->confirmComposition(); | 1378 m_webWidget->confirmComposition(); |
1362 } | 1379 } |
1363 | 1380 |
1364 } | 1381 } |
OLD | NEW |