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 #ifndef CONTENT_TEST_TEST_WEB_CONTENTS_H_ | 5 #ifndef CONTENT_TEST_TEST_WEB_CONTENTS_H_ |
6 #define CONTENT_TEST_TEST_WEB_CONTENTS_H_ | 6 #define CONTENT_TEST_TEST_WEB_CONTENTS_H_ |
7 | 7 |
8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
9 #include "content/public/common/web_preferences.h" | 9 #include "content/public/common/web_preferences.h" |
10 #include "content/public/test/web_contents_tester.h" | 10 #include "content/public/test/web_contents_tester.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // to |ExpectSetHistoryLengthAndPrune()|. | 89 // to |ExpectSetHistoryLengthAndPrune()|. |
90 void SetHistoryLengthAndPrune(const SiteInstance* site_instance, | 90 void SetHistoryLengthAndPrune(const SiteInstance* site_instance, |
91 int history_length, | 91 int history_length, |
92 int32 min_page_id) override; | 92 int32 min_page_id) override; |
93 | 93 |
94 void TestDidFinishLoad(const GURL& url); | 94 void TestDidFinishLoad(const GURL& url); |
95 void TestDidFailLoadWithError(const GURL& url, | 95 void TestDidFailLoadWithError(const GURL& url, |
96 int error_code, | 96 int error_code, |
97 const base::string16& error_description); | 97 const base::string16& error_description); |
98 | 98 |
| 99 // Simulates the renderer reponse for a navigation. Currently, this is |
| 100 // receiving the BeforeUnload ack for a cross-site navigation. |
| 101 // PlzNavigate: this simulates receiving a BeginNavigation IPC in response to |
| 102 // a RequestNavigation IPC. |
| 103 void ProceedNavigationWithRendererResponse(const GURL& url); |
| 104 |
| 105 // Commits the pending navigation and simulates clearing the history. |
| 106 // Note: this function does not simulate receiving the SwapOut ACK from the |
| 107 // old renderer during cross-site navigations. |
| 108 void CommitPendingNavigationWithHistoryCleared( |
| 109 bool had_live_renderer, |
| 110 bool simulate_history_list_was_cleared); |
| 111 |
| 112 // Commits a navigation with the particular url |url| and the page ID |
| 113 // |page_id|. |
| 114 // Note: this function does not simulate receiving the SwapOut ACK from the |
| 115 // old renderer during cross-site navigations. |
| 116 void CommitNavigationWithPageID(int page_id, |
| 117 const GURL& url, |
| 118 bool had_live_renderer); |
| 119 |
| 120 // Commits the pending navigation and simulates giving the bindings |
| 121 // |binding_flags| to the renderer that commits it. |
| 122 // Note: this function does not simulate receiving the SwapOut ACK from the |
| 123 // old renderer during cross-site navigations. |
| 124 void CommitPendingNavigationWithBindings(int binding_flags, |
| 125 bool had_live_renderer); |
| 126 |
| 127 // Commits the pending navigation when no live renderer was present when the |
| 128 // navigation started. |
| 129 void CommitPendingNavigationNoLiveRenderer(); |
| 130 |
| 131 // Simulates the commit of a renderer initiated navigation. |
| 132 // PlzNavigate: also simulates receiving a BeginNavigation IPC from the |
| 133 // renderer before the DidCommitProvisionalLoad IPC. |
| 134 void SimulateRendererInitiatedNavigation(int page_id, const GURL& url); |
| 135 |
99 protected: | 136 protected: |
100 // The deprecated WebContentsTester still needs to subclass this. | 137 // The deprecated WebContentsTester still needs to subclass this. |
101 explicit TestWebContents(BrowserContext* browser_context); | 138 explicit TestWebContents(BrowserContext* browser_context); |
102 | 139 |
103 private: | 140 private: |
104 // WebContentsImpl overrides | 141 // WebContentsImpl overrides |
105 void CreateNewWindow( | 142 void CreateNewWindow( |
106 int render_process_id, | 143 int render_process_id, |
107 int route_id, | 144 int route_id, |
108 int main_frame_route_id, | 145 int main_frame_route_id, |
109 const ViewHostMsg_CreateWindow_Params& params, | 146 const ViewHostMsg_CreateWindow_Params& params, |
110 SessionStorageNamespace* session_storage_namespace) override; | 147 SessionStorageNamespace* session_storage_namespace) override; |
111 void CreateNewWidget(int render_process_id, | 148 void CreateNewWidget(int render_process_id, |
112 int route_id, | 149 int route_id, |
113 blink::WebPopupType popup_type) override; | 150 blink::WebPopupType popup_type) override; |
114 void CreateNewFullscreenWidget(int render_process_id, int route_id) override; | 151 void CreateNewFullscreenWidget(int render_process_id, int route_id) override; |
115 void ShowCreatedWindow(int route_id, | 152 void ShowCreatedWindow(int route_id, |
116 WindowOpenDisposition disposition, | 153 WindowOpenDisposition disposition, |
117 const gfx::Rect& initial_pos, | 154 const gfx::Rect& initial_pos, |
118 bool user_gesture) override; | 155 bool user_gesture) override; |
119 void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) override; | 156 void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) override; |
120 void ShowCreatedFullscreenWidget(int route_id) override; | 157 void ShowCreatedFullscreenWidget(int route_id) override; |
121 | 158 |
| 159 // Commits a navigation with the specified params. If |page_id| is -1, then an |
| 160 // appropriate page id is computed based on the pending navigation entry. |
| 161 // Otherwise the navigation will be committed with the specified |page_id|. |
| 162 // Note: this function does not simulate receiving the SwapOut ACK from the |
| 163 // old renderer during cross-site navigations. |
| 164 void CommitNavigationWithParams(int32 page_id, |
| 165 const GURL& url, |
| 166 bool had_live_renderer, |
| 167 bool simulate_history_list_was_cleared, |
| 168 int binding_flags); |
| 169 |
| 170 // PlzNavigate |
| 171 // Simulates receiving a BeginNavigation IPC in response to a |
| 172 // RequestNavigation IPC. |
| 173 void SimulateIOThreadResponse(); |
| 174 |
122 RenderViewHostDelegateView* delegate_view_override_; | 175 RenderViewHostDelegateView* delegate_view_override_; |
123 | 176 |
124 // Expectations for arguments of |SetHistoryLengthAndPrune()|. | 177 // Expectations for arguments of |SetHistoryLengthAndPrune()|. |
125 bool expect_set_history_length_and_prune_; | 178 bool expect_set_history_length_and_prune_; |
126 scoped_refptr<const SiteInstanceImpl> | 179 scoped_refptr<const SiteInstanceImpl> |
127 expect_set_history_length_and_prune_site_instance_; | 180 expect_set_history_length_and_prune_site_instance_; |
128 int expect_set_history_length_and_prune_history_length_; | 181 int expect_set_history_length_and_prune_history_length_; |
129 int32 expect_set_history_length_and_prune_min_page_id_; | 182 int32 expect_set_history_length_and_prune_min_page_id_; |
130 }; | 183 }; |
131 | 184 |
132 } // namespace content | 185 } // namespace content |
133 | 186 |
134 #endif // CONTENT_TEST_TEST_WEB_CONTENTS_H_ | 187 #endif // CONTENT_TEST_TEST_WEB_CONTENTS_H_ |
OLD | NEW |