| 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/public/test/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cctype> | 9 #include <cctype> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "content/app/mojo/mojo_init.h" | 17 #include "content/app/mojo/mojo_init.h" |
| 18 #include "content/common/dom_storage/dom_storage_types.h" | 18 #include "content/common/dom_storage/dom_storage_types.h" |
| 19 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 20 #include "content/common/input_messages.h" | 20 #include "content/common/input_messages.h" |
| 21 #include "content/common/renderer.mojom.h" | 21 #include "content/common/renderer.mojom.h" |
| 22 #include "content/common/resize_params.h" | 22 #include "content/common/resize_params.h" |
| 23 #include "content/common/site_isolation_policy.h" | |
| 24 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
| 25 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
| 26 #include "content/public/browser/native_web_keyboard_event.h" | 25 #include "content/public/browser/native_web_keyboard_event.h" |
| 27 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/common/previews_state.h" | 28 #include "content/public/common/previews_state.h" |
| 30 #include "content/public/common/renderer_preferences.h" | 29 #include "content/public/common/renderer_preferences.h" |
| 31 #include "content/public/renderer/content_renderer_client.h" | 30 #include "content/public/renderer/content_renderer_client.h" |
| 32 #include "content/public/test/frame_load_waiter.h" | 31 #include "content/public/test/frame_load_waiter.h" |
| 33 #include "content/renderer/history_controller.h" | |
| 34 #include "content/renderer/history_serialization.h" | 32 #include "content/renderer/history_serialization.h" |
| 35 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
| 36 #include "content/renderer/render_view_impl.h" | 34 #include "content/renderer/render_view_impl.h" |
| 37 #include "content/renderer/renderer_blink_platform_impl.h" | 35 #include "content/renderer/renderer_blink_platform_impl.h" |
| 38 #include "content/renderer/renderer_main_platform_delegate.h" | 36 #include "content/renderer/renderer_main_platform_delegate.h" |
| 39 #include "content/test/fake_compositor_dependencies.h" | 37 #include "content/test/fake_compositor_dependencies.h" |
| 40 #include "content/test/mock_render_process.h" | 38 #include "content/test/mock_render_process.h" |
| 41 #include "content/test/test_content_client.h" | 39 #include "content/test/test_content_client.h" |
| 42 #include "content/test/test_render_frame.h" | 40 #include "content/test/test_render_frame.h" |
| 43 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 41 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 blink::WebURL(GURL(url_override))); | 203 blink::WebURL(GURL(url_override))); |
| 206 // The load actually happens asynchronously, so we pump messages to process | 204 // The load actually happens asynchronously, so we pump messages to process |
| 207 // the pending continuation. | 205 // the pending continuation. |
| 208 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); | 206 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); |
| 209 view_->GetWebView()->updateAllLifecyclePhases(); | 207 view_->GetWebView()->updateAllLifecyclePhases(); |
| 210 } | 208 } |
| 211 | 209 |
| 212 PageState RenderViewTest::GetCurrentPageState() { | 210 PageState RenderViewTest::GetCurrentPageState() { |
| 213 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); | 211 RenderViewImpl* view_impl = static_cast<RenderViewImpl*>(view_); |
| 214 | 212 |
| 215 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 213 // This returns a PageState object for the main frame, excluding subframes. |
| 216 // This returns a PageState object for the main frame, excluding subframes. | 214 // This could be extended to all local frames if needed by tests, but it |
| 217 // This could be extended to all local frames if needed by tests, but it | 215 // cannot include out-of-process frames. |
| 218 // cannot include out-of-process frames. | 216 TestRenderFrame* frame = |
| 219 TestRenderFrame* frame = | 217 static_cast<TestRenderFrame*>(view_impl->GetMainRenderFrame()); |
| 220 static_cast<TestRenderFrame*>(view_impl->GetMainRenderFrame()); | 218 return SingleHistoryItemToPageState(frame->current_history_item()); |
| 221 return SingleHistoryItemToPageState(frame->current_history_item()); | |
| 222 } else { | |
| 223 return HistoryEntryToPageState( | |
| 224 view_impl->history_controller()->GetCurrentEntry()); | |
| 225 } | |
| 226 } | 219 } |
| 227 | 220 |
| 228 void RenderViewTest::GoBack(const GURL& url, const PageState& state) { | 221 void RenderViewTest::GoBack(const GURL& url, const PageState& state) { |
| 229 GoToOffset(-1, url, state); | 222 GoToOffset(-1, url, state); |
| 230 } | 223 } |
| 231 | 224 |
| 232 void RenderViewTest::GoForward(const GURL& url, const PageState& state) { | 225 void RenderViewTest::GoForward(const GURL& url, const PageState& state) { |
| 233 GoToOffset(1, url, state); | 226 GoToOffset(1, url, state); |
| 234 } | 227 } |
| 235 | 228 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); | 666 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); |
| 674 frame->Navigate(common_params, StartNavigationParams(), request_params); | 667 frame->Navigate(common_params, StartNavigationParams(), request_params); |
| 675 | 668 |
| 676 // The load actually happens asynchronously, so we pump messages to process | 669 // The load actually happens asynchronously, so we pump messages to process |
| 677 // the pending continuation. | 670 // the pending continuation. |
| 678 FrameLoadWaiter(frame).Wait(); | 671 FrameLoadWaiter(frame).Wait(); |
| 679 view_->GetWebView()->updateAllLifecyclePhases(); | 672 view_->GetWebView()->updateAllLifecyclePhases(); |
| 680 } | 673 } |
| 681 | 674 |
| 682 } // namespace content | 675 } // namespace content |
| OLD | NEW |