| 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" |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); | 920 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 | 923 |
| 924 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame, | 924 bool WebTestProxyBase::DidFailProvisionalLoad(blink::WebLocalFrame* frame, |
| 925 const blink::WebURLError& error) { | 925 const blink::WebURLError& error) { |
| 926 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 926 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
| 927 PrintFrameDescription(delegate_, frame); | 927 PrintFrameDescription(delegate_, frame); |
| 928 delegate_->printMessage(" - didFailProvisionalLoadWithError\n"); | 928 delegate_->printMessage(" - didFailProvisionalLoadWithError\n"); |
| 929 } | 929 } |
| 930 LocationChangeDone(frame); | 930 CheckDone(frame, MainResourceLoadFailed); |
| 931 return !frame->provisionalDataSource(); | 931 return !frame->provisionalDataSource(); |
| 932 } | 932 } |
| 933 | 933 |
| 934 void WebTestProxyBase::DidCommitProvisionalLoad( | 934 void WebTestProxyBase::DidCommitProvisionalLoad( |
| 935 blink::WebLocalFrame* frame, | 935 blink::WebLocalFrame* frame, |
| 936 const blink::WebHistoryItem& history_item, | 936 const blink::WebHistoryItem& history_item, |
| 937 blink::WebHistoryCommitType history_type) { | 937 blink::WebHistoryCommitType history_type) { |
| 938 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 938 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
| 939 PrintFrameDescription(delegate_, frame); | 939 PrintFrameDescription(delegate_, frame); |
| 940 delegate_->printMessage(" - didCommitLoadForFrame\n"); | 940 delegate_->printMessage(" - didCommitLoadForFrame\n"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 delegate_->printMessage(" - didHandleOnloadEventsForFrame\n"); | 985 delegate_->printMessage(" - didHandleOnloadEventsForFrame\n"); |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 | 988 |
| 989 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame, | 989 void WebTestProxyBase::DidFailLoad(blink::WebLocalFrame* frame, |
| 990 const blink::WebURLError& error) { | 990 const blink::WebURLError& error) { |
| 991 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 991 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
| 992 PrintFrameDescription(delegate_, frame); | 992 PrintFrameDescription(delegate_, frame); |
| 993 delegate_->printMessage(" - didFailLoadWithError\n"); | 993 delegate_->printMessage(" - didFailLoadWithError\n"); |
| 994 } | 994 } |
| 995 LocationChangeDone(frame); | 995 CheckDone(frame, MainResourceLoadFailed); |
| 996 } | 996 } |
| 997 | 997 |
| 998 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) { | 998 void WebTestProxyBase::DidFinishLoad(blink::WebLocalFrame* frame) { |
| 999 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { | 999 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) { |
| 1000 PrintFrameDescription(delegate_, frame); | 1000 PrintFrameDescription(delegate_, frame); |
| 1001 delegate_->printMessage(" - didFinishLoadForFrame\n"); | 1001 delegate_->printMessage(" - didFinishLoadForFrame\n"); |
| 1002 } | 1002 } |
| 1003 LocationChangeDone(frame); | 1003 CheckDone(frame, LoadFinished); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame, | 1006 void WebTestProxyBase::DidDetectXSS(blink::WebLocalFrame* frame, |
| 1007 const blink::WebURL& insecure_url, | 1007 const blink::WebURL& insecure_url, |
| 1008 bool did_block_entire_page) { | 1008 bool did_block_entire_page) { |
| 1009 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) | 1009 if (test_interfaces_->GetTestRunner()->shouldDumpFrameLoadCallbacks()) |
| 1010 delegate_->printMessage("didDetectXSS\n"); | 1010 delegate_->printMessage("didDetectXSS\n"); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame, | 1013 void WebTestProxyBase::DidDispatchPingLoader(blink::WebLocalFrame* frame, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 unsigned identifier) { | 1153 unsigned identifier) { |
| 1154 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { | 1154 if (test_interfaces_->GetTestRunner()->shouldDumpResourceLoadCallbacks()) { |
| 1155 if (resource_identifier_map_.find(identifier) == | 1155 if (resource_identifier_map_.find(identifier) == |
| 1156 resource_identifier_map_.end()) | 1156 resource_identifier_map_.end()) |
| 1157 delegate_->printMessage("<unknown>"); | 1157 delegate_->printMessage("<unknown>"); |
| 1158 else | 1158 else |
| 1159 delegate_->printMessage(resource_identifier_map_[identifier]); | 1159 delegate_->printMessage(resource_identifier_map_[identifier]); |
| 1160 delegate_->printMessage(" - didFinishLoading\n"); | 1160 delegate_->printMessage(" - didFinishLoading\n"); |
| 1161 } | 1161 } |
| 1162 resource_identifier_map_.erase(identifier); | 1162 resource_identifier_map_.erase(identifier); |
| 1163 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) |
| 1164 CheckDone(frame, ResourceLoadCompleted); |
| 1165 #endif |
| 1163 } | 1166 } |
| 1164 | 1167 |
| 1165 void WebTestProxyBase::DidAddMessageToConsole( | 1168 void WebTestProxyBase::DidAddMessageToConsole( |
| 1166 const blink::WebConsoleMessage& message, | 1169 const blink::WebConsoleMessage& message, |
| 1167 const blink::WebString& source_name, | 1170 const blink::WebString& source_name, |
| 1168 unsigned source_line) { | 1171 unsigned source_line) { |
| 1169 // This matches win DumpRenderTree's UIDelegate.cpp. | 1172 // This matches win DumpRenderTree's UIDelegate.cpp. |
| 1170 if (!log_console_output_) | 1173 if (!log_console_output_) |
| 1171 return; | 1174 return; |
| 1172 std::string level; | 1175 std::string level; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1197 size_t file_protocol = new_message.find("file://"); | 1200 size_t file_protocol = new_message.find("file://"); |
| 1198 if (file_protocol != std::string::npos) { | 1201 if (file_protocol != std::string::npos) { |
| 1199 new_message = new_message.substr(0, file_protocol) + | 1202 new_message = new_message.substr(0, file_protocol) + |
| 1200 URLSuitableForTestResult(new_message.substr(file_protocol)); | 1203 URLSuitableForTestResult(new_message.substr(file_protocol)); |
| 1201 } | 1204 } |
| 1202 delegate_->printMessage(new_message); | 1205 delegate_->printMessage(new_message); |
| 1203 } | 1206 } |
| 1204 delegate_->printMessage(std::string("\n")); | 1207 delegate_->printMessage(std::string("\n")); |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1207 void WebTestProxyBase::LocationChangeDone(blink::WebFrame* frame) { | 1210 void WebTestProxyBase::CheckDone(blink::WebLocalFrame* frame, |
| 1211 CheckDoneReason reason) { |
| 1208 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) | 1212 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) |
| 1209 return; | 1213 return; |
| 1214 |
| 1215 #if !defined(ENABLE_LOAD_COMPLETION_HACKS) |
| 1216 // Quirk for MHTML prematurely completing on resource load completion. |
| 1217 std::string mime_type = frame->dataSource()->response().mimeType().utf8(); |
| 1218 if (reason == ResourceLoadCompleted && mime_type == "multipart/related") |
| 1219 return; |
| 1220 |
| 1221 if (reason != MainResourceLoadFailed && |
| 1222 (frame->isResourceLoadInProgress() || frame->isLoading())) |
| 1223 return; |
| 1224 #endif |
| 1210 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); | 1225 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); |
| 1211 } | 1226 } |
| 1212 | 1227 |
| 1213 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( | 1228 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( |
| 1214 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 1229 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
| 1215 blink::WebNavigationPolicy result; | 1230 blink::WebNavigationPolicy result; |
| 1216 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled()) | 1231 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled()) |
| 1217 return info.defaultPolicy; | 1232 return info.defaultPolicy; |
| 1218 | 1233 |
| 1219 delegate_->printMessage(std::string("Policy delegate: attempt to load ") + | 1234 delegate_->printMessage(std::string("Policy delegate: attempt to load ") + |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 if (!push_client_.get()) | 1280 if (!push_client_.get()) |
| 1266 push_client_.reset(new MockWebPushClient); | 1281 push_client_.reset(new MockWebPushClient); |
| 1267 return push_client_.get(); | 1282 return push_client_.get(); |
| 1268 } | 1283 } |
| 1269 | 1284 |
| 1270 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { | 1285 blink::WebPushClient* WebTestProxyBase::GetWebPushClient() { |
| 1271 return GetPushClientMock(); | 1286 return GetPushClientMock(); |
| 1272 } | 1287 } |
| 1273 | 1288 |
| 1274 } // namespace content | 1289 } // namespace content |
| OLD | NEW |