OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <deque> | 5 #include <deque> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 url, referrer), | 82 url, referrer), |
83 number_of_loads_(0), | 83 number_of_loads_(0), |
84 expected_number_of_loads_(number_of_loads), | 84 expected_number_of_loads_(number_of_loads), |
85 expected_final_status_(expected_final_status), | 85 expected_final_status_(expected_final_status), |
86 new_render_view_host_(NULL), | 86 new_render_view_host_(NULL), |
87 was_hidden_(false), | 87 was_hidden_(false), |
88 was_shown_(false) { | 88 was_shown_(false) { |
89 } | 89 } |
90 | 90 |
91 virtual ~TestPrerenderContents() { | 91 virtual ~TestPrerenderContents() { |
92 EXPECT_EQ(expected_final_status_, final_status()) << | 92 EXPECT_EQ(FinalStatusCanonicalize(expected_final_status_), |
| 93 FinalStatusCanonicalize(final_status())) << |
93 " when testing URL " << prerender_url().path(); | 94 " when testing URL " << prerender_url().path(); |
94 // Prerendering RenderViewHosts should be hidden before the first | 95 // Prerendering RenderViewHosts should be hidden before the first |
95 // navigation, so this should be happen for every PrerenderContents for | 96 // navigation, so this should be happen for every PrerenderContents for |
96 // which a RenderViewHost is created, regardless of whether or not it's | 97 // which a RenderViewHost is created, regardless of whether or not it's |
97 // used. | 98 // used. |
98 if (new_render_view_host_) { | 99 if (new_render_view_host_) { |
99 EXPECT_TRUE(was_hidden_); | 100 EXPECT_TRUE(was_hidden_); |
100 } | 101 } |
101 | 102 |
102 // A used PrerenderContents will only be destroyed when we swap out | 103 // A used PrerenderContents will only be destroyed when we swap out |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Once hidden, a prerendered RenderViewHost should only be shown after | 171 // Once hidden, a prerendered RenderViewHost should only be shown after |
171 // being removed from the PrerenderContents for display. | 172 // being removed from the PrerenderContents for display. |
172 EXPECT_FALSE(render_view_host()); | 173 EXPECT_FALSE(render_view_host()); |
173 was_shown_ = true; | 174 was_shown_ = true; |
174 } | 175 } |
175 return; | 176 return; |
176 } | 177 } |
177 PrerenderContents::Observe(type, source, details); | 178 PrerenderContents::Observe(type, source, details); |
178 } | 179 } |
179 | 180 |
| 181 static FinalStatus FinalStatusCanonicalize(FinalStatus final) { |
| 182 if (final == FINAL_STATUS_JS_OUT_OF_MEMORY) { |
| 183 return FINAL_STATUS_MEMORY_LIMIT_EXCEEDED; |
| 184 } |
| 185 return final; |
| 186 } |
| 187 |
180 int number_of_loads_; | 188 int number_of_loads_; |
181 int expected_number_of_loads_; | 189 int expected_number_of_loads_; |
182 FinalStatus expected_final_status_; | 190 FinalStatus expected_final_status_; |
183 | 191 |
184 // The RenderViewHost created for the prerender, if any. | 192 // The RenderViewHost created for the prerender, if any. |
185 RenderViewHost* new_render_view_host_; | 193 RenderViewHost* new_render_view_host_; |
186 // Set to true when the prerendering RenderWidget is hidden. | 194 // Set to true when the prerendering RenderWidget is hidden. |
187 bool was_hidden_; | 195 bool was_hidden_; |
188 // Set to true when the prerendering RenderWidget is shown, after having been | 196 // Set to true when the prerendering RenderWidget is shown, after having been |
189 // hidden. | 197 // hidden. |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1316 |
1309 // Checks that a local storage write will not cause prerender to fail. | 1317 // Checks that a local storage write will not cause prerender to fail. |
1310 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { | 1318 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderLocalStorageWrite) { |
1311 PrerenderTestURL("files/prerender/prerender_localstorage_write.html", | 1319 PrerenderTestURL("files/prerender/prerender_localstorage_write.html", |
1312 FINAL_STATUS_USED, | 1320 FINAL_STATUS_USED, |
1313 1); | 1321 1); |
1314 NavigateToDestURL(); | 1322 NavigateToDestURL(); |
1315 } | 1323 } |
1316 | 1324 |
1317 } // namespace prerender | 1325 } // namespace prerender |
OLD | NEW |