OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/test_runner/web_frame_test_client.h" | 5 #include "components/test_runner/web_frame_test_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 case blink::WebNavigationTypeOther: | 159 case blink::WebNavigationTypeOther: |
160 return kOtherString; | 160 return kOtherString; |
161 } | 161 } |
162 return kIllegalString; | 162 return kIllegalString; |
163 } | 163 } |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 | 166 |
167 WebFrameTestClient::WebFrameTestClient( | 167 WebFrameTestClient::WebFrameTestClient( |
168 TestRunner* test_runner, | 168 TestRunner* test_runner, |
169 WebTestDelegate* delegate, | |
170 WebViewTestProxyBase* web_view_test_proxy_base, | 169 WebViewTestProxyBase* web_view_test_proxy_base, |
171 WebFrameTestProxyBase* web_frame_test_proxy_base) | 170 WebFrameTestProxyBase* web_frame_test_proxy_base) |
172 : test_runner_(test_runner), | 171 : test_runner_(test_runner), |
173 delegate_(delegate), | |
174 web_view_test_proxy_base_(web_view_test_proxy_base), | 172 web_view_test_proxy_base_(web_view_test_proxy_base), |
175 web_frame_test_proxy_base_(web_frame_test_proxy_base) { | 173 web_frame_test_proxy_base_(web_frame_test_proxy_base) { |
176 DCHECK(test_runner); | 174 DCHECK(test_runner); |
177 DCHECK(delegate_); | |
178 DCHECK(web_view_test_proxy_base_); | 175 DCHECK(web_view_test_proxy_base_); |
179 } | 176 } |
180 | 177 |
181 WebFrameTestClient::~WebFrameTestClient() {} | 178 WebFrameTestClient::~WebFrameTestClient() {} |
182 | 179 |
183 blink::WebColorChooser* WebFrameTestClient::createColorChooser( | 180 blink::WebColorChooser* WebFrameTestClient::createColorChooser( |
184 blink::WebColorChooserClient* client, | 181 blink::WebColorChooserClient* client, |
185 const blink::WebColor& color, | 182 const blink::WebColor& color, |
186 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { | 183 const blink::WebVector<blink::WebColorSuggestion>& suggestions) { |
187 // This instance is deleted by WebCore::ColorInputType | 184 // This instance is deleted by WebCore::ColorInputType |
188 return new MockColorChooser(client, delegate_, test_runner_); | 185 return new MockColorChooser(client, delegate(), test_runner_); |
189 } | 186 } |
190 | 187 |
191 void WebFrameTestClient::runModalAlertDialog(const blink::WebString& message) { | 188 void WebFrameTestClient::runModalAlertDialog(const blink::WebString& message) { |
192 delegate_->PrintMessage(std::string("ALERT: ") + message.utf8().data() + | 189 delegate()->PrintMessage(std::string("ALERT: ") + message.utf8().data() + |
193 "\n"); | 190 "\n"); |
194 } | 191 } |
195 | 192 |
196 bool WebFrameTestClient::runModalConfirmDialog( | 193 bool WebFrameTestClient::runModalConfirmDialog( |
197 const blink::WebString& message) { | 194 const blink::WebString& message) { |
198 delegate_->PrintMessage(std::string("CONFIRM: ") + message.utf8().data() + | 195 delegate()->PrintMessage(std::string("CONFIRM: ") + message.utf8().data() + |
199 "\n"); | 196 "\n"); |
200 return true; | 197 return true; |
201 } | 198 } |
202 | 199 |
203 bool WebFrameTestClient::runModalPromptDialog( | 200 bool WebFrameTestClient::runModalPromptDialog( |
204 const blink::WebString& message, | 201 const blink::WebString& message, |
205 const blink::WebString& default_value, | 202 const blink::WebString& default_value, |
206 blink::WebString* actual_value) { | 203 blink::WebString* actual_value) { |
207 delegate_->PrintMessage(std::string("PROMPT: ") + message.utf8().data() + | 204 delegate()->PrintMessage(std::string("PROMPT: ") + message.utf8().data() + |
208 ", default text: " + default_value.utf8().data() + | 205 ", default text: " + default_value.utf8().data() + |
209 "\n"); | 206 "\n"); |
210 return true; | 207 return true; |
211 } | 208 } |
212 | 209 |
213 bool WebFrameTestClient::runModalBeforeUnloadDialog(bool is_reload) { | 210 bool WebFrameTestClient::runModalBeforeUnloadDialog(bool is_reload) { |
214 delegate_->PrintMessage(std::string("CONFIRM NAVIGATION\n")); | 211 delegate()->PrintMessage(std::string("CONFIRM NAVIGATION\n")); |
215 return !test_runner_->shouldStayOnPageAfterHandlingBeforeUnload(); | 212 return !test_runner_->shouldStayOnPageAfterHandlingBeforeUnload(); |
216 } | 213 } |
217 | 214 |
218 blink::WebScreenOrientationClient* | 215 blink::WebScreenOrientationClient* |
219 WebFrameTestClient::webScreenOrientationClient() { | 216 WebFrameTestClient::webScreenOrientationClient() { |
220 return test_runner_->getMockScreenOrientationClient(); | 217 return test_runner_->getMockScreenOrientationClient(); |
221 } | 218 } |
222 | 219 |
223 void WebFrameTestClient::postAccessibilityEvent(const blink::WebAXObject& obj, | 220 void WebFrameTestClient::postAccessibilityEvent(const blink::WebAXObject& obj, |
224 blink::WebAXEvent event) { | 221 blink::WebAXEvent event) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 340 |
344 blink::WebNode node = obj.node(); | 341 blink::WebNode node = obj.node(); |
345 if (!node.isNull() && node.isElementNode()) { | 342 if (!node.isNull() && node.isElementNode()) { |
346 blink::WebElement element = node.to<blink::WebElement>(); | 343 blink::WebElement element = node.to<blink::WebElement>(); |
347 if (element.hasAttribute("id")) { | 344 if (element.hasAttribute("id")) { |
348 message += " - id:"; | 345 message += " - id:"; |
349 message += element.getAttribute("id").utf8().data(); | 346 message += element.getAttribute("id").utf8().data(); |
350 } | 347 } |
351 } | 348 } |
352 | 349 |
353 delegate_->PrintMessage(message + "\n"); | 350 delegate()->PrintMessage(message + "\n"); |
354 } | 351 } |
355 } | 352 } |
356 | 353 |
357 void WebFrameTestClient::didChangeSelection(bool is_empty_callback) { | 354 void WebFrameTestClient::didChangeSelection(bool is_empty_callback) { |
358 if (test_runner_->shouldDumpEditingCallbacks()) | 355 if (test_runner_->shouldDumpEditingCallbacks()) |
359 delegate_->PrintMessage( | 356 delegate()->PrintMessage( |
360 "EDITING DELEGATE: " | 357 "EDITING DELEGATE: " |
361 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); | 358 "webViewDidChangeSelection:WebViewDidChangeSelectionNotification\n"); |
362 } | 359 } |
363 | 360 |
364 blink::WebPlugin* WebFrameTestClient::createPlugin( | 361 blink::WebPlugin* WebFrameTestClient::createPlugin( |
365 blink::WebLocalFrame* frame, | 362 blink::WebLocalFrame* frame, |
366 const blink::WebPluginParams& params) { | 363 const blink::WebPluginParams& params) { |
367 if (TestPlugin::IsSupportedMimeType(params.mimeType)) | 364 if (TestPlugin::IsSupportedMimeType(params.mimeType)) |
368 return TestPlugin::create(frame, params, delegate_); | 365 return TestPlugin::create(frame, params, delegate()); |
369 return delegate_->CreatePluginPlaceholder(frame, params); | 366 return delegate()->CreatePluginPlaceholder(frame, params); |
370 } | 367 } |
371 | 368 |
372 void WebFrameTestClient::showContextMenu( | 369 void WebFrameTestClient::showContextMenu( |
373 const blink::WebContextMenuData& context_menu_data) { | 370 const blink::WebContextMenuData& context_menu_data) { |
374 web_view_test_proxy_base_->event_sender()->SetContextMenuData( | 371 web_view_test_proxy_base_->event_sender()->SetContextMenuData( |
375 context_menu_data); | 372 context_menu_data); |
376 } | 373 } |
377 | 374 |
378 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() { | 375 blink::WebUserMediaClient* WebFrameTestClient::userMediaClient() { |
379 return test_runner_->getMockWebUserMediaClient(); | 376 return test_runner_->getMockWebUserMediaClient(); |
380 } | 377 } |
381 | 378 |
382 void WebFrameTestClient::loadURLExternally( | 379 void WebFrameTestClient::loadURLExternally( |
383 const blink::WebURLRequest& request, | 380 const blink::WebURLRequest& request, |
384 blink::WebNavigationPolicy policy, | 381 blink::WebNavigationPolicy policy, |
385 const blink::WebString& suggested_name, | 382 const blink::WebString& suggested_name, |
386 bool replaces_current_history_item) { | 383 bool replaces_current_history_item) { |
387 if (test_runner_->shouldWaitUntilExternalURLLoad()) { | 384 if (test_runner_->shouldWaitUntilExternalURLLoad()) { |
388 if (policy == blink::WebNavigationPolicyDownload) { | 385 if (policy == blink::WebNavigationPolicyDownload) { |
389 delegate_->PrintMessage( | 386 delegate()->PrintMessage( |
390 std::string("Downloading URL with suggested filename \"") + | 387 std::string("Downloading URL with suggested filename \"") + |
391 suggested_name.utf8() + "\"\n"); | 388 suggested_name.utf8() + "\"\n"); |
392 } else { | 389 } else { |
393 delegate_->PrintMessage(std::string("Loading URL externally - \"") + | 390 delegate()->PrintMessage(std::string("Loading URL externally - \"") + |
394 URLDescription(request.url()) + "\"\n"); | 391 URLDescription(request.url()) + "\"\n"); |
395 } | 392 } |
396 delegate_->TestFinished(); | 393 delegate()->TestFinished(); |
397 } | 394 } |
398 } | 395 } |
399 | 396 |
400 void WebFrameTestClient::didStartProvisionalLoad(blink::WebLocalFrame* frame, | 397 void WebFrameTestClient::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
401 double trigering_event_time) { | 398 double trigering_event_time) { |
402 test_runner_->tryToSetTopLoadingFrame(frame); | 399 test_runner_->tryToSetTopLoadingFrame(frame); |
403 | 400 |
404 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 401 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
405 PrintFrameDescription(delegate_, frame); | 402 PrintFrameDescription(delegate(), frame); |
406 delegate_->PrintMessage(" - didStartProvisionalLoadForFrame\n"); | 403 delegate()->PrintMessage(" - didStartProvisionalLoadForFrame\n"); |
407 } | 404 } |
408 | 405 |
409 if (test_runner_->shouldDumpUserGestureInFrameLoadCallbacks()) { | 406 if (test_runner_->shouldDumpUserGestureInFrameLoadCallbacks()) { |
410 PrintFrameuserGestureStatus(delegate_, frame, | 407 PrintFrameuserGestureStatus(delegate(), frame, |
411 " - in didStartProvisionalLoadForFrame\n"); | 408 " - in didStartProvisionalLoadForFrame\n"); |
412 } | 409 } |
413 } | 410 } |
414 | 411 |
415 void WebFrameTestClient::didReceiveServerRedirectForProvisionalLoad( | 412 void WebFrameTestClient::didReceiveServerRedirectForProvisionalLoad( |
416 blink::WebLocalFrame* frame) { | 413 blink::WebLocalFrame* frame) { |
417 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 414 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
418 PrintFrameDescription(delegate_, frame); | 415 PrintFrameDescription(delegate(), frame); |
419 delegate_->PrintMessage( | 416 delegate()->PrintMessage( |
420 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); | 417 " - didReceiveServerRedirectForProvisionalLoadForFrame\n"); |
421 } | 418 } |
422 } | 419 } |
423 | 420 |
424 void WebFrameTestClient::didFailProvisionalLoad( | 421 void WebFrameTestClient::didFailProvisionalLoad( |
425 blink::WebLocalFrame* frame, | 422 blink::WebLocalFrame* frame, |
426 const blink::WebURLError& error, | 423 const blink::WebURLError& error, |
427 blink::WebHistoryCommitType commit_type) { | 424 blink::WebHistoryCommitType commit_type) { |
428 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 425 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
429 PrintFrameDescription(delegate_, frame); | 426 PrintFrameDescription(delegate(), frame); |
430 delegate_->PrintMessage(" - didFailProvisionalLoadWithError\n"); | 427 delegate()->PrintMessage(" - didFailProvisionalLoadWithError\n"); |
431 } | 428 } |
432 } | 429 } |
433 | 430 |
434 void WebFrameTestClient::didCommitProvisionalLoad( | 431 void WebFrameTestClient::didCommitProvisionalLoad( |
435 blink::WebLocalFrame* frame, | 432 blink::WebLocalFrame* frame, |
436 const blink::WebHistoryItem& history_item, | 433 const blink::WebHistoryItem& history_item, |
437 blink::WebHistoryCommitType history_type) { | 434 blink::WebHistoryCommitType history_type) { |
438 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 435 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
439 PrintFrameDescription(delegate_, frame); | 436 PrintFrameDescription(delegate(), frame); |
440 delegate_->PrintMessage(" - didCommitLoadForFrame\n"); | 437 delegate()->PrintMessage(" - didCommitLoadForFrame\n"); |
441 } | 438 } |
442 } | 439 } |
443 | 440 |
444 void WebFrameTestClient::didReceiveTitle(blink::WebLocalFrame* frame, | 441 void WebFrameTestClient::didReceiveTitle(blink::WebLocalFrame* frame, |
445 const blink::WebString& title, | 442 const blink::WebString& title, |
446 blink::WebTextDirection direction) { | 443 blink::WebTextDirection direction) { |
447 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 444 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
448 PrintFrameDescription(delegate_, frame); | 445 PrintFrameDescription(delegate(), frame); |
449 delegate_->PrintMessage(std::string(" - didReceiveTitle: ") + title.utf8() + | 446 delegate()->PrintMessage(std::string(" - didReceiveTitle: ") + |
450 "\n"); | 447 title.utf8() + "\n"); |
451 } | 448 } |
452 | 449 |
453 if (test_runner_->shouldDumpTitleChanges()) | 450 if (test_runner_->shouldDumpTitleChanges()) |
454 delegate_->PrintMessage(std::string("TITLE CHANGED: '") + title.utf8() + | 451 delegate()->PrintMessage(std::string("TITLE CHANGED: '") + title.utf8() + |
455 "'\n"); | 452 "'\n"); |
456 } | 453 } |
457 | 454 |
458 void WebFrameTestClient::didChangeIcon(blink::WebLocalFrame* frame, | 455 void WebFrameTestClient::didChangeIcon(blink::WebLocalFrame* frame, |
459 blink::WebIconURL::Type icon_type) { | 456 blink::WebIconURL::Type icon_type) { |
460 if (test_runner_->shouldDumpIconChanges()) { | 457 if (test_runner_->shouldDumpIconChanges()) { |
461 PrintFrameDescription(delegate_, frame); | 458 PrintFrameDescription(delegate(), frame); |
462 delegate_->PrintMessage(std::string(" - didChangeIcons\n")); | 459 delegate()->PrintMessage(std::string(" - didChangeIcons\n")); |
463 } | 460 } |
464 } | 461 } |
465 | 462 |
466 void WebFrameTestClient::didFinishDocumentLoad(blink::WebLocalFrame* frame) { | 463 void WebFrameTestClient::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
467 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 464 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
468 PrintFrameDescription(delegate_, frame); | 465 PrintFrameDescription(delegate(), frame); |
469 delegate_->PrintMessage(" - didFinishDocumentLoadForFrame\n"); | 466 delegate()->PrintMessage(" - didFinishDocumentLoadForFrame\n"); |
470 } | 467 } |
471 } | 468 } |
472 | 469 |
473 void WebFrameTestClient::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 470 void WebFrameTestClient::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
474 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 471 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
475 PrintFrameDescription(delegate_, frame); | 472 PrintFrameDescription(delegate(), frame); |
476 delegate_->PrintMessage(" - didHandleOnloadEventsForFrame\n"); | 473 delegate()->PrintMessage(" - didHandleOnloadEventsForFrame\n"); |
477 } | 474 } |
478 } | 475 } |
479 | 476 |
480 void WebFrameTestClient::didFailLoad(blink::WebLocalFrame* frame, | 477 void WebFrameTestClient::didFailLoad(blink::WebLocalFrame* frame, |
481 const blink::WebURLError& error, | 478 const blink::WebURLError& error, |
482 blink::WebHistoryCommitType commit_type) { | 479 blink::WebHistoryCommitType commit_type) { |
483 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 480 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
484 PrintFrameDescription(delegate_, frame); | 481 PrintFrameDescription(delegate(), frame); |
485 delegate_->PrintMessage(" - didFailLoadWithError\n"); | 482 delegate()->PrintMessage(" - didFailLoadWithError\n"); |
486 } | 483 } |
487 } | 484 } |
488 | 485 |
489 void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) { | 486 void WebFrameTestClient::didFinishLoad(blink::WebLocalFrame* frame) { |
490 if (test_runner_->shouldDumpFrameLoadCallbacks()) { | 487 if (test_runner_->shouldDumpFrameLoadCallbacks()) { |
491 PrintFrameDescription(delegate_, frame); | 488 PrintFrameDescription(delegate(), frame); |
492 delegate_->PrintMessage(" - didFinishLoadForFrame\n"); | 489 delegate()->PrintMessage(" - didFinishLoadForFrame\n"); |
493 } | 490 } |
494 } | 491 } |
495 | 492 |
496 void WebFrameTestClient::didNavigateWithinPage( | 493 void WebFrameTestClient::didNavigateWithinPage( |
497 blink::WebLocalFrame* frame, | 494 blink::WebLocalFrame* frame, |
498 const blink::WebHistoryItem& history_item, | 495 const blink::WebHistoryItem& history_item, |
499 blink::WebHistoryCommitType commit_type, | 496 blink::WebHistoryCommitType commit_type, |
500 bool contentInitiated) { | 497 bool contentInitiated) { |
501 test_runner_->OnNavigationEnd(); | 498 test_runner_->OnNavigationEnd(); |
502 } | 499 } |
503 | 500 |
504 void WebFrameTestClient::didStartLoading(bool to_different_document) { | 501 void WebFrameTestClient::didStartLoading(bool to_different_document) { |
505 test_runner_->OnNavigationBegin(web_frame_test_proxy_base_->web_frame()); | 502 test_runner_->OnNavigationBegin(web_frame_test_proxy_base_->web_frame()); |
506 } | 503 } |
507 | 504 |
508 void WebFrameTestClient::didStopLoading() { | 505 void WebFrameTestClient::didStopLoading() { |
509 test_runner_->tryToClearTopLoadingFrame( | 506 test_runner_->tryToClearTopLoadingFrame( |
510 web_frame_test_proxy_base_->web_frame()); | 507 web_frame_test_proxy_base_->web_frame()); |
511 } | 508 } |
512 | 509 |
513 void WebFrameTestClient::didDetectXSS(const blink::WebURL& insecure_url, | 510 void WebFrameTestClient::didDetectXSS(const blink::WebURL& insecure_url, |
514 bool did_block_entire_page) { | 511 bool did_block_entire_page) { |
515 if (test_runner_->shouldDumpFrameLoadCallbacks()) | 512 if (test_runner_->shouldDumpFrameLoadCallbacks()) |
516 delegate_->PrintMessage("didDetectXSS\n"); | 513 delegate()->PrintMessage("didDetectXSS\n"); |
517 } | 514 } |
518 | 515 |
519 void WebFrameTestClient::didDispatchPingLoader(const blink::WebURL& url) { | 516 void WebFrameTestClient::didDispatchPingLoader(const blink::WebURL& url) { |
520 if (test_runner_->shouldDumpPingLoaderCallbacks()) | 517 if (test_runner_->shouldDumpPingLoaderCallbacks()) |
521 delegate_->PrintMessage(std::string("PingLoader dispatched to '") + | 518 delegate()->PrintMessage(std::string("PingLoader dispatched to '") + |
522 URLDescription(url).c_str() + "'.\n"); | 519 URLDescription(url).c_str() + "'.\n"); |
523 } | 520 } |
524 | 521 |
525 void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, | 522 void WebFrameTestClient::willSendRequest(blink::WebLocalFrame* frame, |
526 blink::WebURLRequest& request) { | 523 blink::WebURLRequest& request) { |
527 // Need to use GURL for host() and SchemeIs() | 524 // Need to use GURL for host() and SchemeIs() |
528 GURL url = request.url(); | 525 GURL url = request.url(); |
529 std::string request_url = url.possibly_invalid_spec(); | 526 std::string request_url = url.possibly_invalid_spec(); |
530 | 527 |
531 GURL main_document_url = request.firstPartyForCookies(); | 528 GURL main_document_url = request.firstPartyForCookies(); |
532 | 529 |
533 if (test_runner_->shouldDumpResourceLoadCallbacks()) { | 530 if (test_runner_->shouldDumpResourceLoadCallbacks()) { |
534 delegate_->PrintMessage(DescriptionSuitableForTestResult(request_url)); | 531 delegate()->PrintMessage(DescriptionSuitableForTestResult(request_url)); |
535 delegate_->PrintMessage(" - willSendRequest <NSURLRequest URL "); | 532 delegate()->PrintMessage(" - willSendRequest <NSURLRequest URL "); |
536 delegate_->PrintMessage( | 533 delegate()->PrintMessage( |
537 DescriptionSuitableForTestResult(request_url).c_str()); | 534 DescriptionSuitableForTestResult(request_url).c_str()); |
538 delegate_->PrintMessage(", main document URL "); | 535 delegate()->PrintMessage(", main document URL "); |
539 delegate_->PrintMessage(URLDescription(main_document_url).c_str()); | 536 delegate()->PrintMessage(URLDescription(main_document_url).c_str()); |
540 delegate_->PrintMessage(", http method "); | 537 delegate()->PrintMessage(", http method "); |
541 delegate_->PrintMessage(request.httpMethod().utf8().data()); | 538 delegate()->PrintMessage(request.httpMethod().utf8().data()); |
542 delegate_->PrintMessage(">\n"); | 539 delegate()->PrintMessage(">\n"); |
543 } | 540 } |
544 | 541 |
545 if (test_runner_->httpHeadersToClear()) { | 542 if (test_runner_->httpHeadersToClear()) { |
546 const std::set<std::string>* clearHeaders = | 543 const std::set<std::string>* clearHeaders = |
547 test_runner_->httpHeadersToClear(); | 544 test_runner_->httpHeadersToClear(); |
548 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); | 545 for (std::set<std::string>::const_iterator header = clearHeaders->begin(); |
549 header != clearHeaders->end(); ++header) | 546 header != clearHeaders->end(); ++header) |
550 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); | 547 request.clearHTTPHeaderField(blink::WebString::fromUTF8(*header)); |
551 } | 548 } |
552 | 549 |
553 std::string host = url.host(); | 550 std::string host = url.host(); |
554 if (!host.empty() && | 551 if (!host.empty() && |
555 (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))) { | 552 (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme))) { |
556 if (!IsLocalHost(host) && !IsTestHost(host) && | 553 if (!IsLocalHost(host) && !IsTestHost(host) && |
557 !HostIsUsedBySomeTestsToGenerateError(host) && | 554 !HostIsUsedBySomeTestsToGenerateError(host) && |
558 ((!main_document_url.SchemeIs(url::kHttpScheme) && | 555 ((!main_document_url.SchemeIs(url::kHttpScheme) && |
559 !main_document_url.SchemeIs(url::kHttpsScheme)) || | 556 !main_document_url.SchemeIs(url::kHttpsScheme)) || |
560 IsLocalHost(main_document_url.host())) && | 557 IsLocalHost(main_document_url.host())) && |
561 !delegate_->AllowExternalPages()) { | 558 !delegate()->AllowExternalPages()) { |
562 delegate_->PrintMessage(std::string("Blocked access to external URL ") + | 559 delegate()->PrintMessage(std::string("Blocked access to external URL ") + |
563 request_url + "\n"); | 560 request_url + "\n"); |
564 BlockRequest(request); | 561 BlockRequest(request); |
565 return; | 562 return; |
566 } | 563 } |
567 } | 564 } |
568 | 565 |
569 // Set the new substituted URL. | 566 // Set the new substituted URL. |
570 request.setURL(delegate_->RewriteLayoutTestsURL( | 567 request.setURL(delegate()->RewriteLayoutTestsURL( |
571 request.url().string().utf8(), | 568 request.url().string().utf8(), |
572 test_runner_->is_web_platform_tests_mode())); | 569 test_runner_->is_web_platform_tests_mode())); |
573 } | 570 } |
574 | 571 |
575 void WebFrameTestClient::didReceiveResponse( | 572 void WebFrameTestClient::didReceiveResponse( |
576 const blink::WebURLResponse& response) { | 573 const blink::WebURLResponse& response) { |
577 if (test_runner_->shouldDumpResourceLoadCallbacks()) { | 574 if (test_runner_->shouldDumpResourceLoadCallbacks()) { |
578 delegate_->PrintMessage(DescriptionSuitableForTestResult( | 575 delegate()->PrintMessage(DescriptionSuitableForTestResult( |
579 GURL(response.url()).possibly_invalid_spec())); | 576 GURL(response.url()).possibly_invalid_spec())); |
580 delegate_->PrintMessage(" - didReceiveResponse "); | 577 delegate()->PrintMessage(" - didReceiveResponse "); |
581 PrintResponseDescription(delegate_, response); | 578 PrintResponseDescription(delegate(), response); |
582 delegate_->PrintMessage("\n"); | 579 delegate()->PrintMessage("\n"); |
583 } | 580 } |
584 if (test_runner_->shouldDumpResourceResponseMIMETypes()) { | 581 if (test_runner_->shouldDumpResourceResponseMIMETypes()) { |
585 GURL url = response.url(); | 582 GURL url = response.url(); |
586 blink::WebString mime_type = response.mimeType(); | 583 blink::WebString mime_type = response.mimeType(); |
587 delegate_->PrintMessage(url.ExtractFileName()); | 584 delegate()->PrintMessage(url.ExtractFileName()); |
588 delegate_->PrintMessage(" has MIME type "); | 585 delegate()->PrintMessage(" has MIME type "); |
589 // Simulate NSURLResponse's mapping of empty/unknown MIME types to | 586 // Simulate NSURLResponse's mapping of empty/unknown MIME types to |
590 // application/octet-stream | 587 // application/octet-stream |
591 delegate_->PrintMessage(mime_type.isEmpty() ? "application/octet-stream" | 588 delegate()->PrintMessage(mime_type.isEmpty() ? "application/octet-stream" |
592 : mime_type.utf8().data()); | 589 : mime_type.utf8().data()); |
593 delegate_->PrintMessage("\n"); | 590 delegate()->PrintMessage("\n"); |
594 } | 591 } |
595 } | 592 } |
596 | 593 |
597 void WebFrameTestClient::didAddMessageToConsole( | 594 void WebFrameTestClient::didAddMessageToConsole( |
598 const blink::WebConsoleMessage& message, | 595 const blink::WebConsoleMessage& message, |
599 const blink::WebString& source_name, | 596 const blink::WebString& source_name, |
600 unsigned source_line, | 597 unsigned source_line, |
601 const blink::WebString& stack_trace) { | 598 const blink::WebString& stack_trace) { |
602 if (!test_runner_->ShouldDumpConsoleMessages()) | 599 if (!test_runner_->ShouldDumpConsoleMessages()) |
603 return; | 600 return; |
(...skipping 10 matching lines...) Expand all Loading... |
614 break; | 611 break; |
615 case blink::WebConsoleMessage::LevelWarning: | 612 case blink::WebConsoleMessage::LevelWarning: |
616 level = "WARNING"; | 613 level = "WARNING"; |
617 break; | 614 break; |
618 case blink::WebConsoleMessage::LevelError: | 615 case blink::WebConsoleMessage::LevelError: |
619 level = "ERROR"; | 616 level = "ERROR"; |
620 break; | 617 break; |
621 default: | 618 default: |
622 level = "MESSAGE"; | 619 level = "MESSAGE"; |
623 } | 620 } |
624 delegate_->PrintMessage(std::string("CONSOLE ") + level + ": "); | 621 delegate()->PrintMessage(std::string("CONSOLE ") + level + ": "); |
625 if (source_line) { | 622 if (source_line) { |
626 delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line)); | 623 delegate()->PrintMessage(base::StringPrintf("line %d: ", source_line)); |
627 } | 624 } |
628 if (!message.text.isEmpty()) { | 625 if (!message.text.isEmpty()) { |
629 std::string new_message; | 626 std::string new_message; |
630 new_message = message.text.utf8(); | 627 new_message = message.text.utf8(); |
631 size_t file_protocol = new_message.find("file://"); | 628 size_t file_protocol = new_message.find("file://"); |
632 if (file_protocol != std::string::npos) { | 629 if (file_protocol != std::string::npos) { |
633 new_message = new_message.substr(0, file_protocol) + | 630 new_message = new_message.substr(0, file_protocol) + |
634 URLSuitableForTestResult(new_message.substr(file_protocol)); | 631 URLSuitableForTestResult(new_message.substr(file_protocol)); |
635 } | 632 } |
636 delegate_->PrintMessage(new_message); | 633 delegate()->PrintMessage(new_message); |
637 } | 634 } |
638 delegate_->PrintMessage(std::string("\n")); | 635 delegate()->PrintMessage(std::string("\n")); |
639 } | 636 } |
640 | 637 |
641 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( | 638 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( |
642 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 639 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
643 if (test_runner_->shouldDumpNavigationPolicy()) { | 640 if (test_runner_->shouldDumpNavigationPolicy()) { |
644 delegate_->PrintMessage("Default policy for navigation to '" + | 641 delegate()->PrintMessage("Default policy for navigation to '" + |
645 URLDescription(info.urlRequest.url()) + "' is '" + | 642 URLDescription(info.urlRequest.url()) + "' is '" + |
646 WebNavigationPolicyToString(info.defaultPolicy) + | 643 WebNavigationPolicyToString(info.defaultPolicy) + |
647 "'\n"); | 644 "'\n"); |
648 } | 645 } |
649 | 646 |
650 blink::WebNavigationPolicy result; | 647 blink::WebNavigationPolicy result; |
651 if (!test_runner_->policyDelegateEnabled()) | 648 if (!test_runner_->policyDelegateEnabled()) |
652 return info.defaultPolicy; | 649 return info.defaultPolicy; |
653 | 650 |
654 delegate_->PrintMessage( | 651 delegate()->PrintMessage( |
655 std::string("Policy delegate: attempt to load ") + | 652 std::string("Policy delegate: attempt to load ") + |
656 URLDescription(info.urlRequest.url()) + " with navigation type '" + | 653 URLDescription(info.urlRequest.url()) + " with navigation type '" + |
657 WebNavigationTypeToString(info.navigationType) + "'\n"); | 654 WebNavigationTypeToString(info.navigationType) + "'\n"); |
658 if (test_runner_->policyDelegateIsPermissive()) | 655 if (test_runner_->policyDelegateIsPermissive()) |
659 result = blink::WebNavigationPolicyCurrentTab; | 656 result = blink::WebNavigationPolicyCurrentTab; |
660 else | 657 else |
661 result = blink::WebNavigationPolicyIgnore; | 658 result = blink::WebNavigationPolicyIgnore; |
662 | 659 |
663 if (test_runner_->policyDelegateShouldNotifyDone()) { | 660 if (test_runner_->policyDelegateShouldNotifyDone()) { |
664 test_runner_->policyDelegateDone(); | 661 test_runner_->policyDelegateDone(); |
(...skipping 18 matching lines...) Expand all Loading... |
683 } | 680 } |
684 | 681 |
685 void WebFrameTestClient::didClearWindowObject(blink::WebLocalFrame* frame) { | 682 void WebFrameTestClient::didClearWindowObject(blink::WebLocalFrame* frame) { |
686 web_view_test_proxy_base_->test_interfaces()->BindTo(frame); | 683 web_view_test_proxy_base_->test_interfaces()->BindTo(frame); |
687 web_view_test_proxy_base_->BindTo(frame); | 684 web_view_test_proxy_base_->BindTo(frame); |
688 } | 685 } |
689 | 686 |
690 bool WebFrameTestClient::runFileChooser( | 687 bool WebFrameTestClient::runFileChooser( |
691 const blink::WebFileChooserParams& params, | 688 const blink::WebFileChooserParams& params, |
692 blink::WebFileChooserCompletion* completion) { | 689 blink::WebFileChooserCompletion* completion) { |
693 delegate_->PrintMessage("Mock: Opening a file chooser.\n"); | 690 delegate()->PrintMessage("Mock: Opening a file chooser.\n"); |
694 // FIXME: Add ability to set file names to a file upload control. | 691 // FIXME: Add ability to set file names to a file upload control. |
695 return false; | 692 return false; |
696 } | 693 } |
697 | 694 |
| 695 WebTestDelegate* WebFrameTestClient::delegate() { |
| 696 return web_view_test_proxy_base_->delegate(); |
| 697 } |
| 698 |
698 } // namespace test_runner | 699 } // namespace test_runner |
OLD | NEW |