| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webkit_test_runner.h" | 5 #include "content/shell/renderer/webkit_test_runner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <clocale> | 8 #include <clocale> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/debugger.h" | 13 #include "base/debug/debugger.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/md5.h" | 15 #include "base/md5.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 25 #include "content/public/renderer/history_item_serialization.h" | |
| 26 #include "content/public/renderer/render_view.h" | 25 #include "content/public/renderer/render_view.h" |
| 27 #include "content/public/renderer/render_view_visitor.h" | 26 #include "content/public/renderer/render_view_visitor.h" |
| 28 #include "content/public/test/layouttest_support.h" | 27 #include "content/public/test/layouttest_support.h" |
| 29 #include "content/shell/common/shell_messages.h" | 28 #include "content/shell/common/shell_messages.h" |
| 30 #include "content/shell/common/shell_switches.h" | 29 #include "content/shell/common/shell_switches.h" |
| 31 #include "content/shell/common/webkit_test_helpers.h" | 30 #include "content/shell/common/webkit_test_helpers.h" |
| 32 #include "content/shell/renderer/gc_controller.h" | 31 #include "content/shell/renderer/gc_controller.h" |
| 33 #include "content/shell/renderer/leak_detector.h" | 32 #include "content/shell/renderer/leak_detector.h" |
| 34 #include "content/shell/renderer/shell_render_process_observer.h" | 33 #include "content/shell/renderer/shell_render_process_observer.h" |
| 35 #include "content/shell/renderer/test_runner/WebTask.h" | 34 #include "content/shell/renderer/test_runner/WebTask.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 void WebKitTestRunner::loadURLForFrame(const WebURL& url, | 532 void WebKitTestRunner::loadURLForFrame(const WebURL& url, |
| 534 const std::string& frame_name) { | 533 const std::string& frame_name) { |
| 535 Send(new ShellViewHostMsg_LoadURLForFrame( | 534 Send(new ShellViewHostMsg_LoadURLForFrame( |
| 536 routing_id(), url, frame_name)); | 535 routing_id(), url, frame_name)); |
| 537 } | 536 } |
| 538 | 537 |
| 539 bool WebKitTestRunner::allowExternalPages() { | 538 bool WebKitTestRunner::allowExternalPages() { |
| 540 return test_config_.allow_external_pages; | 539 return test_config_.allow_external_pages; |
| 541 } | 540 } |
| 542 | 541 |
| 543 void WebKitTestRunner::captureHistoryForWindow( | 542 std::string WebKitTestRunner::dumpHistoryForWindow(WebTestProxyBase* proxy) { |
| 544 WebTestProxyBase* proxy, | |
| 545 WebVector<blink::WebHistoryItem>* history, | |
| 546 size_t* currentEntryIndex) { | |
| 547 size_t pos = 0; | 543 size_t pos = 0; |
| 548 std::vector<int>::iterator id; | 544 std::vector<int>::iterator id; |
| 549 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) { | 545 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) { |
| 550 RenderView* render_view = RenderView::FromRoutingID(*id); | 546 RenderView* render_view = RenderView::FromRoutingID(*id); |
| 551 if (!render_view) { | 547 if (!render_view) { |
| 552 NOTREACHED(); | 548 NOTREACHED(); |
| 553 continue; | 549 continue; |
| 554 } | 550 } |
| 555 if (WebKitTestRunner::Get(render_view)->proxy() == proxy) | 551 if (WebKitTestRunner::Get(render_view)->proxy() == proxy) |
| 556 break; | 552 break; |
| 557 } | 553 } |
| 558 | 554 |
| 559 if (id == routing_ids_.end()) { | 555 if (id == routing_ids_.end()) { |
| 560 NOTREACHED(); | 556 NOTREACHED(); |
| 561 return; | 557 return std::string(); |
| 562 } | 558 } |
| 563 size_t num_entries = session_histories_[pos].size(); | 559 return DumpBackForwardList(session_histories_[pos], |
| 564 *currentEntryIndex = current_entry_indexes_[pos]; | 560 current_entry_indexes_[pos]); |
| 565 WebVector<WebHistoryItem> result(num_entries); | |
| 566 for (size_t entry = 0; entry < num_entries; ++entry) { | |
| 567 result[entry] = | |
| 568 PageStateToHistoryItem(session_histories_[pos][entry]); | |
| 569 } | |
| 570 history->swap(result); | |
| 571 } | 561 } |
| 572 | 562 |
| 573 // RenderViewObserver -------------------------------------------------------- | 563 // RenderViewObserver -------------------------------------------------------- |
| 574 | 564 |
| 575 void WebKitTestRunner::DidClearWindowObject(WebLocalFrame* frame, | 565 void WebKitTestRunner::DidClearWindowObject(WebLocalFrame* frame, |
| 576 int world_id) { | 566 int world_id) { |
| 577 WebTestingSupport::injectInternalsObject(frame); | 567 WebTestingSupport::injectInternalsObject(frame); |
| 578 if (world_id == 0) { | 568 if (world_id == 0) { |
| 579 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); | 569 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); |
| 580 GCController::Install(frame); | 570 GCController::Install(frame); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 | 729 |
| 740 leak_detector_->TryLeakDetection(main_frame); | 730 leak_detector_->TryLeakDetection(main_frame); |
| 741 } | 731 } |
| 742 | 732 |
| 743 void WebKitTestRunner::ReportLeakDetectionResult( | 733 void WebKitTestRunner::ReportLeakDetectionResult( |
| 744 const LeakDetectionResult& report) { | 734 const LeakDetectionResult& report) { |
| 745 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 735 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
| 746 } | 736 } |
| 747 | 737 |
| 748 } // namespace content | 738 } // namespace content |
| OLD | NEW |