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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "content/browser/browser_thread_impl.h" | 6 #include "content/browser/browser_thread_impl.h" |
7 #include "content/browser/renderer_host/test_render_view_host.h" | 7 #include "content/browser/renderer_host/test_render_view_host.h" |
8 #include "content/browser/site_instance_impl.h" | 8 #include "content/browser/site_instance_impl.h" |
9 #include "content/browser/web_contents/navigation_controller_impl.h" | 9 #include "content/browser/web_contents/navigation_controller_impl.h" |
10 #include "content/browser/web_contents/navigation_entry_impl.h" | 10 #include "content/browser/web_contents/navigation_entry_impl.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
24 #include "content/public/test/mock_render_process_host.h" | 24 #include "content/public/test/mock_render_process_host.h" |
25 #include "content/public/test/test_browser_context.h" | 25 #include "content/public/test/test_browser_context.h" |
26 #include "content/public/test/test_notification_tracker.h" | 26 #include "content/public/test/test_notification_tracker.h" |
27 #include "content/test/test_content_browser_client.h" | 27 #include "content/test/test_content_browser_client.h" |
28 #include "content/test/test_content_client.h" | 28 #include "content/test/test_content_client.h" |
29 #include "googleurl/src/url_util.h" | 29 #include "googleurl/src/url_util.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "webkit/glue/glue_serialize.h" | 31 #include "webkit/glue/glue_serialize.h" |
32 | 32 |
33 using content::BrowserContext; | 33 namespace content { |
34 using content::BrowserThread; | |
35 using content::BrowserThreadImpl; | |
36 using content::MockRenderProcessHost; | |
37 using content::NavigationController; | |
38 using content::NavigationEntry; | |
39 using content::NavigationEntryImpl; | |
40 using content::RenderViewHost; | |
41 using content::RenderViewHostImpl; | |
42 using content::RenderViewHostImplTestHarness; | |
43 using content::SiteInstance; | |
44 using content::TestRenderViewHost; | |
45 using content::TestWebContents; | |
46 using content::WebContents; | |
47 using content::WebUI; | |
48 using content::WebUIController; | |
49 | |
50 namespace { | 34 namespace { |
51 | 35 |
52 class RenderViewHostManagerTestWebUIControllerFactory | 36 class RenderViewHostManagerTestWebUIControllerFactory |
53 : public content::WebUIControllerFactory { | 37 : public WebUIControllerFactory { |
54 public: | 38 public: |
55 RenderViewHostManagerTestWebUIControllerFactory() | 39 RenderViewHostManagerTestWebUIControllerFactory() |
56 : should_create_webui_(false) { | 40 : should_create_webui_(false) { |
57 } | 41 } |
58 virtual ~RenderViewHostManagerTestWebUIControllerFactory() {} | 42 virtual ~RenderViewHostManagerTestWebUIControllerFactory() {} |
59 | 43 |
60 void set_should_create_webui(bool should_create_webui) { | 44 void set_should_create_webui(bool should_create_webui) { |
61 should_create_webui_ = should_create_webui; | 45 should_create_webui_ = should_create_webui; |
62 } | 46 } |
63 | 47 |
64 // WebUIFactory implementation. | 48 // WebUIFactory implementation. |
65 virtual WebUIController* CreateWebUIControllerForURL( | 49 virtual WebUIController* CreateWebUIControllerForURL( |
66 WebUI* web_ui, const GURL& url) const OVERRIDE { | 50 WebUI* web_ui, const GURL& url) const OVERRIDE { |
67 if (!(should_create_webui_ && | 51 if (!(should_create_webui_ && GetContentClient()->HasWebUIScheme(url))) |
68 content::GetContentClient()->HasWebUIScheme(url))) | |
69 return NULL; | 52 return NULL; |
70 return new WebUIController(web_ui); | 53 return new WebUIController(web_ui); |
71 } | 54 } |
72 | 55 |
73 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, | 56 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
74 const GURL& url) const OVERRIDE { | 57 const GURL& url) const OVERRIDE { |
75 return WebUI::kNoWebUI; | 58 return WebUI::kNoWebUI; |
76 } | 59 } |
77 | 60 |
78 virtual bool UseWebUIForURL(BrowserContext* browser_context, | 61 virtual bool UseWebUIForURL(BrowserContext* browser_context, |
79 const GURL& url) const OVERRIDE { | 62 const GURL& url) const OVERRIDE { |
80 return content::GetContentClient()->HasWebUIScheme(url); | 63 return GetContentClient()->HasWebUIScheme(url); |
81 } | 64 } |
82 | 65 |
83 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, | 66 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
84 const GURL& url) const OVERRIDE { | 67 const GURL& url) const OVERRIDE { |
85 return content::GetContentClient()->HasWebUIScheme(url); | 68 return GetContentClient()->HasWebUIScheme(url); |
86 } | 69 } |
87 | 70 |
88 virtual bool IsURLAcceptableForWebUI( | 71 virtual bool IsURLAcceptableForWebUI( |
89 BrowserContext* browser_context, | 72 BrowserContext* browser_context, |
90 const GURL& url, | 73 const GURL& url, |
91 bool data_urls_allowed) const OVERRIDE { | 74 bool data_urls_allowed) const OVERRIDE { |
92 return content::GetContentClient()->HasWebUIScheme(url); | 75 return GetContentClient()->HasWebUIScheme(url); |
93 } | 76 } |
94 | 77 |
95 private: | 78 private: |
96 bool should_create_webui_; | 79 bool should_create_webui_; |
97 | 80 |
98 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestWebUIControllerFactory); | 81 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestWebUIControllerFactory); |
99 }; | 82 }; |
100 | 83 |
101 class RenderViewHostManagerTestClient : public TestContentClient { | 84 class RenderViewHostManagerTestClient : public TestContentClient { |
102 public: | 85 public: |
103 RenderViewHostManagerTestClient() { | 86 RenderViewHostManagerTestClient() { |
104 } | 87 } |
105 | 88 |
106 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 89 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
107 return url.SchemeIs(chrome::kChromeUIScheme); | 90 return url.SchemeIs(chrome::kChromeUIScheme); |
108 } | 91 } |
109 }; | 92 }; |
110 | 93 |
111 class RenderViewHostManagerTestBrowserClient | 94 class RenderViewHostManagerTestBrowserClient |
112 : public content::TestContentBrowserClient { | 95 : public TestContentBrowserClient { |
113 public: | 96 public: |
114 RenderViewHostManagerTestBrowserClient() {} | 97 RenderViewHostManagerTestBrowserClient() {} |
115 virtual ~RenderViewHostManagerTestBrowserClient() {} | 98 virtual ~RenderViewHostManagerTestBrowserClient() {} |
116 | 99 |
117 void set_should_create_webui(bool should_create_webui) { | 100 void set_should_create_webui(bool should_create_webui) { |
118 factory_.set_should_create_webui(should_create_webui); | 101 factory_.set_should_create_webui(should_create_webui); |
119 } | 102 } |
120 | 103 |
121 // content::TestContentBrowserClient implementation. | 104 // TestContentBrowserClient implementation. |
122 virtual content::WebUIControllerFactory* | 105 virtual WebUIControllerFactory* |
123 GetWebUIControllerFactory() OVERRIDE { | 106 GetWebUIControllerFactory() OVERRIDE { |
124 return &factory_; | 107 return &factory_; |
125 } | 108 } |
126 | 109 |
127 private: | 110 private: |
128 RenderViewHostManagerTestWebUIControllerFactory factory_; | 111 RenderViewHostManagerTestWebUIControllerFactory factory_; |
129 | 112 |
130 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestBrowserClient); | 113 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManagerTestBrowserClient); |
131 }; | 114 }; |
132 | 115 |
133 } // namespace | 116 } // namespace |
134 | 117 |
135 class RenderViewHostManagerTest | 118 class RenderViewHostManagerTest |
136 : public RenderViewHostImplTestHarness { | 119 : public RenderViewHostImplTestHarness { |
137 public: | 120 public: |
138 virtual void SetUp() OVERRIDE { | 121 virtual void SetUp() OVERRIDE { |
139 RenderViewHostImplTestHarness::SetUp(); | 122 RenderViewHostImplTestHarness::SetUp(); |
140 old_client_ = content::GetContentClient(); | 123 old_client_ = GetContentClient(); |
141 old_browser_client_ = content::GetContentClient()->browser(); | 124 old_browser_client_ = GetContentClient()->browser(); |
142 content::SetContentClient(&client_); | 125 SetContentClient(&client_); |
143 content::GetContentClient()->set_browser_for_testing(&browser_client_); | 126 GetContentClient()->set_browser_for_testing(&browser_client_); |
144 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 127 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
145 } | 128 } |
146 | 129 |
147 virtual void TearDown() OVERRIDE { | 130 virtual void TearDown() OVERRIDE { |
148 RenderViewHostImplTestHarness::TearDown(); | 131 RenderViewHostImplTestHarness::TearDown(); |
149 content::GetContentClient()->set_browser_for_testing(old_browser_client_); | 132 GetContentClient()->set_browser_for_testing(old_browser_client_); |
150 content::SetContentClient(old_client_); | 133 SetContentClient(old_client_); |
151 } | 134 } |
152 | 135 |
153 void set_should_create_webui(bool should_create_webui) { | 136 void set_should_create_webui(bool should_create_webui) { |
154 browser_client_.set_should_create_webui(should_create_webui); | 137 browser_client_.set_should_create_webui(should_create_webui); |
155 } | 138 } |
156 | 139 |
157 void NavigateActiveAndCommit(const GURL& url) { | 140 void NavigateActiveAndCommit(const GURL& url) { |
158 // Note: we navigate the active RenderViewHost because previous navigations | 141 // Note: we navigate the active RenderViewHost because previous navigations |
159 // won't have committed yet, so NavigateAndCommit does the wrong thing | 142 // won't have committed yet, so NavigateAndCommit does the wrong thing |
160 // for us. | 143 // for us. |
161 controller().LoadURL( | 144 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
162 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | |
163 TestRenderViewHost* old_rvh = test_rvh(); | 145 TestRenderViewHost* old_rvh = test_rvh(); |
164 | 146 |
165 // Simulate the ShouldClose_ACK that is received from the current renderer | 147 // Simulate the ShouldClose_ACK that is received from the current renderer |
166 // for a cross-site navigation. | 148 // for a cross-site navigation. |
167 if (old_rvh != active_rvh()) | 149 if (old_rvh != active_rvh()) |
168 old_rvh->SendShouldCloseACK(true); | 150 old_rvh->SendShouldCloseACK(true); |
169 | 151 |
170 // Commit the navigation with a new page ID. | 152 // Commit the navigation with a new page ID. |
171 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( | 153 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( |
172 active_rvh()->GetSiteInstance()); | 154 active_rvh()->GetSiteInstance()); |
173 active_test_rvh()->SendNavigate(max_page_id + 1, url); | 155 active_test_rvh()->SendNavigate(max_page_id + 1, url); |
174 | 156 |
175 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation | 157 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation |
176 // without making any network requests. | 158 // without making any network requests. |
177 if (old_rvh != active_rvh()) | 159 if (old_rvh != active_rvh()) |
178 old_rvh->OnSwapOutACK(false); | 160 old_rvh->OnSwapOutACK(false); |
179 } | 161 } |
180 | 162 |
181 bool ShouldSwapProcesses(RenderViewHostManager* manager, | 163 bool ShouldSwapProcesses(RenderViewHostManager* manager, |
182 const NavigationEntryImpl* cur_entry, | 164 const NavigationEntryImpl* cur_entry, |
183 const NavigationEntryImpl* new_entry) const { | 165 const NavigationEntryImpl* new_entry) const { |
184 return manager->ShouldSwapProcessesForNavigation(cur_entry, new_entry); | 166 return manager->ShouldSwapProcessesForNavigation(cur_entry, new_entry); |
185 } | 167 } |
186 | 168 |
187 private: | 169 private: |
188 RenderViewHostManagerTestClient client_; | 170 RenderViewHostManagerTestClient client_; |
189 RenderViewHostManagerTestBrowserClient browser_client_; | 171 RenderViewHostManagerTestBrowserClient browser_client_; |
190 content::ContentClient* old_client_; | 172 ContentClient* old_client_; |
191 content::ContentBrowserClient* old_browser_client_; | 173 ContentBrowserClient* old_browser_client_; |
192 }; | 174 }; |
193 | 175 |
194 // Tests that when you navigate from the New TabPage to another page, and | 176 // Tests that when you navigate from the New TabPage to another page, and |
195 // then do that same thing in another tab, that the two resulting pages have | 177 // then do that same thing in another tab, that the two resulting pages have |
196 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is | 178 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is |
197 // a regression test for bug 9364. | 179 // a regression test for bug 9364. |
198 TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { | 180 TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { |
199 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 181 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
200 const GURL kNtpUrl(content::kTestNewTabURL); | 182 const GURL kNtpUrl(kTestNewTabURL); |
201 const GURL kDestUrl("http://www.google.com/"); | 183 const GURL kDestUrl("http://www.google.com/"); |
202 | 184 |
203 // Navigate our first tab to the new tab page and then to the destination. | 185 // Navigate our first tab to the new tab page and then to the destination. |
204 NavigateActiveAndCommit(kNtpUrl); | 186 NavigateActiveAndCommit(kNtpUrl); |
205 NavigateActiveAndCommit(kDestUrl); | 187 NavigateActiveAndCommit(kDestUrl); |
206 | 188 |
207 // Make a second tab. | 189 // Make a second tab. |
208 scoped_ptr<TestWebContents> contents2( | 190 scoped_ptr<TestWebContents> contents2( |
209 TestWebContents::Create(browser_context(), NULL)); | 191 TestWebContents::Create(browser_context(), NULL)); |
210 | 192 |
211 // Load the two URLs in the second tab. Note that the first navigation creates | 193 // Load the two URLs in the second tab. Note that the first navigation creates |
212 // a RVH that's not pending (since there is no cross-site transition), so | 194 // a RVH that's not pending (since there is no cross-site transition), so |
213 // we use the committed one. | 195 // we use the committed one. |
214 contents2->GetController().LoadURL( | 196 contents2->GetController().LoadURL( |
215 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, | 197 kNtpUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
216 std::string()); | |
217 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( | 198 TestRenderViewHost* ntp_rvh2 = static_cast<TestRenderViewHost*>( |
218 contents2->GetRenderManagerForTesting()->current_host()); | 199 contents2->GetRenderManagerForTesting()->current_host()); |
219 EXPECT_FALSE(contents2->cross_navigation_pending()); | 200 EXPECT_FALSE(contents2->cross_navigation_pending()); |
220 ntp_rvh2->SendNavigate(100, kNtpUrl); | 201 ntp_rvh2->SendNavigate(100, kNtpUrl); |
221 | 202 |
222 // The second one is the opposite, creating a cross-site transition and | 203 // The second one is the opposite, creating a cross-site transition and |
223 // requiring a beforeunload ack. | 204 // requiring a beforeunload ack. |
224 contents2->GetController().LoadURL( | 205 contents2->GetController().LoadURL( |
225 kDestUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, | 206 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
226 std::string()); | |
227 EXPECT_TRUE(contents2->cross_navigation_pending()); | 207 EXPECT_TRUE(contents2->cross_navigation_pending()); |
228 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( | 208 TestRenderViewHost* dest_rvh2 = static_cast<TestRenderViewHost*>( |
229 contents2->GetRenderManagerForTesting()->pending_render_view_host()); | 209 contents2->GetRenderManagerForTesting()->pending_render_view_host()); |
230 ASSERT_TRUE(dest_rvh2); | 210 ASSERT_TRUE(dest_rvh2); |
231 ntp_rvh2->SendShouldCloseACK(true); | 211 ntp_rvh2->SendShouldCloseACK(true); |
232 dest_rvh2->SendNavigate(101, kDestUrl); | 212 dest_rvh2->SendNavigate(101, kDestUrl); |
233 ntp_rvh2->OnSwapOutACK(false); | 213 ntp_rvh2->OnSwapOutACK(false); |
234 | 214 |
235 // The two RVH's should be different in every way. | 215 // The two RVH's should be different in every way. |
236 EXPECT_NE(active_rvh()->GetProcess(), dest_rvh2->GetProcess()); | 216 EXPECT_NE(active_rvh()->GetProcess(), dest_rvh2->GetProcess()); |
237 EXPECT_NE(active_rvh()->GetSiteInstance(), dest_rvh2->GetSiteInstance()); | 217 EXPECT_NE(active_rvh()->GetSiteInstance(), dest_rvh2->GetSiteInstance()); |
238 EXPECT_FALSE(active_rvh()->GetSiteInstance()->IsRelatedSiteInstance( | 218 EXPECT_FALSE(active_rvh()->GetSiteInstance()->IsRelatedSiteInstance( |
239 dest_rvh2->GetSiteInstance())); | 219 dest_rvh2->GetSiteInstance())); |
240 | 220 |
241 // Navigate both to the new tab page, and verify that they share a | 221 // Navigate both to the new tab page, and verify that they share a |
242 // RenderProcessHost (not a SiteInstance). | 222 // RenderProcessHost (not a SiteInstance). |
243 NavigateActiveAndCommit(kNtpUrl); | 223 NavigateActiveAndCommit(kNtpUrl); |
244 | 224 |
245 contents2->GetController().LoadURL( | 225 contents2->GetController().LoadURL( |
246 kNtpUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, | 226 kNtpUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
247 std::string()); | |
248 dest_rvh2->SendShouldCloseACK(true); | 227 dest_rvh2->SendShouldCloseACK(true); |
249 static_cast<TestRenderViewHost*>(contents2->GetRenderManagerForTesting()-> | 228 static_cast<TestRenderViewHost*>(contents2->GetRenderManagerForTesting()-> |
250 pending_render_view_host())->SendNavigate(102, kNtpUrl); | 229 pending_render_view_host())->SendNavigate(102, kNtpUrl); |
251 dest_rvh2->OnSwapOutACK(false); | 230 dest_rvh2->OnSwapOutACK(false); |
252 | 231 |
253 EXPECT_NE(active_rvh()->GetSiteInstance(), | 232 EXPECT_NE(active_rvh()->GetSiteInstance(), |
254 contents2->GetRenderViewHost()->GetSiteInstance()); | 233 contents2->GetRenderViewHost()->GetSiteInstance()); |
255 EXPECT_EQ(active_rvh()->GetSiteInstance()->GetProcess(), | 234 EXPECT_EQ(active_rvh()->GetSiteInstance()->GetProcess(), |
256 contents2->GetRenderViewHost()->GetSiteInstance()->GetProcess()); | 235 contents2->GetRenderViewHost()->GetSiteInstance()->GetProcess()); |
257 } | 236 } |
258 | 237 |
259 // Ensure that the browser ignores most IPC messages that arrive from a | 238 // Ensure that the browser ignores most IPC messages that arrive from a |
260 // RenderViewHost that has been swapped out. We do not want to take | 239 // RenderViewHost that has been swapped out. We do not want to take |
261 // action on requests from a non-active renderer. The main exception is | 240 // action on requests from a non-active renderer. The main exception is |
262 // for synchronous messages, which cannot be ignored without leaving the | 241 // for synchronous messages, which cannot be ignored without leaving the |
263 // renderer in a stuck state. See http://crbug.com/93427. | 242 // renderer in a stuck state. See http://crbug.com/93427. |
264 TEST_F(RenderViewHostManagerTest, FilterMessagesWhileSwappedOut) { | 243 TEST_F(RenderViewHostManagerTest, FilterMessagesWhileSwappedOut) { |
265 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 244 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
266 const GURL kNtpUrl(content::kTestNewTabURL); | 245 const GURL kNtpUrl(kTestNewTabURL); |
267 const GURL kDestUrl("http://www.google.com/"); | 246 const GURL kDestUrl("http://www.google.com/"); |
268 | 247 |
269 // Navigate our first tab to the new tab page and then to the destination. | 248 // Navigate our first tab to the new tab page and then to the destination. |
270 NavigateActiveAndCommit(kNtpUrl); | 249 NavigateActiveAndCommit(kNtpUrl); |
271 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( | 250 TestRenderViewHost* ntp_rvh = static_cast<TestRenderViewHost*>( |
272 contents()->GetRenderManagerForTesting()->current_host()); | 251 contents()->GetRenderManagerForTesting()->current_host()); |
273 | 252 |
274 // Send an update title message and make sure it works. | 253 // Send an update title message and make sure it works. |
275 const string16 ntp_title = ASCIIToUTF16("NTP Title"); | 254 const string16 ntp_title = ASCIIToUTF16("NTP Title"); |
276 WebKit::WebTextDirection direction = WebKit::WebTextDirectionLeftToRight; | 255 WebKit::WebTextDirection direction = WebKit::WebTextDirectionLeftToRight; |
277 EXPECT_TRUE(ntp_rvh->OnMessageReceived( | 256 EXPECT_TRUE(ntp_rvh->OnMessageReceived( |
278 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); | 257 ViewHostMsg_UpdateTitle(rvh()->GetRoutingID(), 0, ntp_title, direction))); |
279 EXPECT_EQ(ntp_title, contents()->GetTitle()); | 258 EXPECT_EQ(ntp_title, contents()->GetTitle()); |
280 | 259 |
281 // Navigate to a cross-site URL. | 260 // Navigate to a cross-site URL. |
282 contents()->GetController().LoadURL( | 261 contents()->GetController().LoadURL( |
283 kDestUrl, content::Referrer(), content::PAGE_TRANSITION_LINK, | 262 kDestUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
284 std::string()); | |
285 EXPECT_TRUE(contents()->cross_navigation_pending()); | 263 EXPECT_TRUE(contents()->cross_navigation_pending()); |
286 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( | 264 TestRenderViewHost* dest_rvh = static_cast<TestRenderViewHost*>( |
287 contents()->GetRenderManagerForTesting()->pending_render_view_host()); | 265 contents()->GetRenderManagerForTesting()->pending_render_view_host()); |
288 ASSERT_TRUE(dest_rvh); | 266 ASSERT_TRUE(dest_rvh); |
289 EXPECT_NE(ntp_rvh, dest_rvh); | 267 EXPECT_NE(ntp_rvh, dest_rvh); |
290 | 268 |
291 // BeforeUnload finishes. | 269 // BeforeUnload finishes. |
292 ntp_rvh->SendShouldCloseACK(true); | 270 ntp_rvh->SendShouldCloseACK(true); |
293 | 271 |
294 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits. | 272 // Assume SwapOutACK times out, so the dest_rvh proceeds and commits. |
(...skipping 27 matching lines...) Expand all Loading... |
322 rvh()->GetRoutingID(), kNtpUrl, msg, false, &result, &unused); | 300 rvh()->GetRoutingID(), kNtpUrl, msg, false, &result, &unused); |
323 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. | 301 // Enable pumping for check in BrowserMessageFilter::CheckCanDispatchOnUI. |
324 before_unload_msg.EnableMessagePumping(); | 302 before_unload_msg.EnableMessagePumping(); |
325 EXPECT_TRUE(ntp_rvh->OnMessageReceived(before_unload_msg)); | 303 EXPECT_TRUE(ntp_rvh->OnMessageReceived(before_unload_msg)); |
326 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); | 304 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); |
327 | 305 |
328 // Also test RunJavaScriptMessage. | 306 // Also test RunJavaScriptMessage. |
329 ntp_process_host->sink().ClearMessages(); | 307 ntp_process_host->sink().ClearMessages(); |
330 ViewHostMsg_RunJavaScriptMessage js_msg( | 308 ViewHostMsg_RunJavaScriptMessage js_msg( |
331 rvh()->GetRoutingID(), msg, msg, kNtpUrl, | 309 rvh()->GetRoutingID(), msg, msg, kNtpUrl, |
332 content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); | 310 JAVASCRIPT_MESSAGE_TYPE_CONFIRM, &result, &unused); |
333 js_msg.EnableMessagePumping(); | 311 js_msg.EnableMessagePumping(); |
334 EXPECT_TRUE(ntp_rvh->OnMessageReceived(js_msg)); | 312 EXPECT_TRUE(ntp_rvh->OnMessageReceived(js_msg)); |
335 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); | 313 EXPECT_TRUE(ntp_process_host->sink().GetUniqueMessageMatching(IPC_REPLY_ID)); |
336 } | 314 } |
337 | 315 |
338 // When there is an error with the specified page, renderer exits view-source | 316 // When there is an error with the specified page, renderer exits view-source |
339 // mode. See WebFrameImpl::DidFail(). We check by this test that | 317 // mode. See WebFrameImpl::DidFail(). We check by this test that |
340 // EnableViewSourceMode message is sent on every navigation regardless | 318 // EnableViewSourceMode message is sent on every navigation regardless |
341 // RenderView is being newly created or reused. | 319 // RenderView is being newly created or reused. |
342 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { | 320 TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { |
343 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 321 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
344 const GURL kNtpUrl(content::kTestNewTabURL); | 322 const GURL kNtpUrl(kTestNewTabURL); |
345 const GURL kUrl("view-source:http://foo"); | 323 const GURL kUrl("view-source:http://foo"); |
346 | 324 |
347 // We have to navigate to some page at first since without this, the first | 325 // We have to navigate to some page at first since without this, the first |
348 // navigation will reuse the SiteInstance created by Init(), and the second | 326 // navigation will reuse the SiteInstance created by Init(), and the second |
349 // one will create a new SiteInstance. Because current_instance and | 327 // one will create a new SiteInstance. Because current_instance and |
350 // new_instance will be different, a new RenderViewHost will be created for | 328 // new_instance will be different, a new RenderViewHost will be created for |
351 // the second navigation. We have to avoid this in order to exercise the | 329 // the second navigation. We have to avoid this in order to exercise the |
352 // target code patch. | 330 // target code patch. |
353 NavigateActiveAndCommit(kNtpUrl); | 331 NavigateActiveAndCommit(kNtpUrl); |
354 | 332 |
355 // Navigate. | 333 // Navigate. |
356 controller().LoadURL( | 334 controller().LoadURL( |
357 kUrl, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 335 kUrl, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
358 // Simulate response from RenderView for FirePageBeforeUnload. | 336 // Simulate response from RenderView for FirePageBeforeUnload. |
359 test_rvh()->OnMessageReceived(ViewHostMsg_ShouldClose_ACK( | 337 test_rvh()->OnMessageReceived(ViewHostMsg_ShouldClose_ACK( |
360 rvh()->GetRoutingID(), true, base::TimeTicks(), base::TimeTicks())); | 338 rvh()->GetRoutingID(), true, base::TimeTicks(), base::TimeTicks())); |
361 ASSERT_TRUE(pending_rvh()); // New pending RenderViewHost will be created. | 339 ASSERT_TRUE(pending_rvh()); // New pending RenderViewHost will be created. |
362 RenderViewHost* last_rvh = pending_rvh(); | 340 RenderViewHost* last_rvh = pending_rvh(); |
363 int32 new_id = contents()->GetMaxPageIDForSiteInstance( | 341 int32 new_id = contents()->GetMaxPageIDForSiteInstance( |
364 active_rvh()->GetSiteInstance()) + 1; | 342 active_rvh()->GetSiteInstance()) + 1; |
365 pending_test_rvh()->SendNavigate(new_id, kUrl); | 343 pending_test_rvh()->SendNavigate(new_id, kUrl); |
366 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); | 344 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); |
367 ASSERT_TRUE(controller().GetLastCommittedEntry()); | 345 ASSERT_TRUE(controller().GetLastCommittedEntry()); |
368 EXPECT_TRUE(kUrl == controller().GetLastCommittedEntry()->GetURL()); | 346 EXPECT_TRUE(kUrl == controller().GetLastCommittedEntry()->GetURL()); |
369 EXPECT_FALSE(controller().GetPendingEntry()); | 347 EXPECT_FALSE(controller().GetPendingEntry()); |
370 // Because we're using TestWebContents and TestRenderViewHost in this | 348 // Because we're using TestWebContents and TestRenderViewHost in this |
371 // unittest, no one calls WebContentsImpl::RenderViewCreated(). So, we see no | 349 // unittest, no one calls WebContentsImpl::RenderViewCreated(). So, we see no |
372 // EnableViewSourceMode message, here. | 350 // EnableViewSourceMode message, here. |
373 | 351 |
374 // Clear queued messages before load. | 352 // Clear queued messages before load. |
375 process()->sink().ClearMessages(); | 353 process()->sink().ClearMessages(); |
376 // Navigate, again. | 354 // Navigate, again. |
377 controller().LoadURL( | 355 controller().LoadURL( |
378 kUrl, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 356 kUrl, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
379 // The same RenderViewHost should be reused. | 357 // The same RenderViewHost should be reused. |
380 EXPECT_FALSE(pending_rvh()); | 358 EXPECT_FALSE(pending_rvh()); |
381 EXPECT_TRUE(last_rvh == rvh()); | 359 EXPECT_TRUE(last_rvh == rvh()); |
382 test_rvh()->SendNavigate(new_id, kUrl); // The same page_id returned. | 360 test_rvh()->SendNavigate(new_id, kUrl); // The same page_id returned. |
383 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); | 361 EXPECT_EQ(controller().GetLastCommittedEntryIndex(), 1); |
384 EXPECT_FALSE(controller().GetPendingEntry()); | 362 EXPECT_FALSE(controller().GetPendingEntry()); |
385 // New message should be sent out to make sure to enter view-source mode. | 363 // New message should be sent out to make sure to enter view-source mode. |
386 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( | 364 EXPECT_TRUE(process()->sink().GetUniqueMessageMatching( |
387 ViewMsg_EnableViewSourceMode::ID)); | 365 ViewMsg_EnableViewSourceMode::ID)); |
388 } | 366 } |
(...skipping 16 matching lines...) Expand all Loading... |
405 ASSERT_TRUE(host); | 383 ASSERT_TRUE(host); |
406 EXPECT_EQ(instance, host->GetSiteInstance()); | 384 EXPECT_EQ(instance, host->GetSiteInstance()); |
407 EXPECT_EQ(web_contents.get(), host->GetDelegate()); | 385 EXPECT_EQ(web_contents.get(), host->GetDelegate()); |
408 EXPECT_TRUE(manager.GetRenderWidgetHostView()); | 386 EXPECT_TRUE(manager.GetRenderWidgetHostView()); |
409 EXPECT_FALSE(manager.pending_render_view_host()); | 387 EXPECT_FALSE(manager.pending_render_view_host()); |
410 } | 388 } |
411 | 389 |
412 // Tests the Navigate function. We navigate three sites consecutively and check | 390 // Tests the Navigate function. We navigate three sites consecutively and check |
413 // how the pending/committed RenderViewHost are modified. | 391 // how the pending/committed RenderViewHost are modified. |
414 TEST_F(RenderViewHostManagerTest, Navigate) { | 392 TEST_F(RenderViewHostManagerTest, Navigate) { |
415 content::TestNotificationTracker notifications; | 393 TestNotificationTracker notifications; |
416 | 394 |
417 SiteInstance* instance = SiteInstance::Create(browser_context()); | 395 SiteInstance* instance = SiteInstance::Create(browser_context()); |
418 | 396 |
419 scoped_ptr<TestWebContents> web_contents( | 397 scoped_ptr<TestWebContents> web_contents( |
420 TestWebContents::Create(browser_context(), instance)); | 398 TestWebContents::Create(browser_context(), instance)); |
421 notifications.ListenFor( | 399 notifications.ListenFor( |
422 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 400 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
423 content::Source<NavigationController>( | 401 Source<NavigationController>(&web_contents->GetController())); |
424 &web_contents->GetController())); | |
425 | 402 |
426 // Create. | 403 // Create. |
427 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 404 RenderViewHostManager manager(web_contents.get(), web_contents.get(), |
428 web_contents.get()); | 405 web_contents.get()); |
429 | 406 |
430 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 407 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
431 | 408 |
432 RenderViewHost* host; | 409 RenderViewHost* host; |
433 | 410 |
434 // 1) The first navigation. -------------------------- | 411 // 1) The first navigation. -------------------------- |
435 const GURL kUrl1("http://www.google.com/"); | 412 const GURL kUrl1("http://www.google.com/"); |
436 NavigationEntryImpl entry1( | 413 NavigationEntryImpl entry1( |
437 NULL /* instance */, -1 /* page_id */, kUrl1, content::Referrer(), | 414 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), |
438 string16() /* title */, content::PAGE_TRANSITION_TYPED, | 415 string16() /* title */, PAGE_TRANSITION_TYPED, |
439 false /* is_renderer_init */); | 416 false /* is_renderer_init */); |
440 host = manager.Navigate(entry1); | 417 host = manager.Navigate(entry1); |
441 | 418 |
442 // The RenderViewHost created in Init will be reused. | 419 // The RenderViewHost created in Init will be reused. |
443 EXPECT_TRUE(host == manager.current_host()); | 420 EXPECT_TRUE(host == manager.current_host()); |
444 EXPECT_FALSE(manager.pending_render_view_host()); | 421 EXPECT_FALSE(manager.pending_render_view_host()); |
445 | 422 |
446 // Commit. | 423 // Commit. |
447 manager.DidNavigateMainFrame(host); | 424 manager.DidNavigateMainFrame(host); |
448 // Commit to SiteInstance should be delayed until RenderView commit. | 425 // Commit to SiteInstance should be delayed until RenderView commit. |
449 EXPECT_TRUE(host == manager.current_host()); | 426 EXPECT_TRUE(host == manager.current_host()); |
450 ASSERT_TRUE(host); | 427 ASSERT_TRUE(host); |
451 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 428 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
452 HasSite()); | 429 HasSite()); |
453 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); | 430 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); |
454 | 431 |
455 // 2) Navigate to next site. ------------------------- | 432 // 2) Navigate to next site. ------------------------- |
456 const GURL kUrl2("http://www.google.com/foo"); | 433 const GURL kUrl2("http://www.google.com/foo"); |
457 NavigationEntryImpl entry2( | 434 NavigationEntryImpl entry2( |
458 NULL /* instance */, -1 /* page_id */, kUrl2, | 435 NULL /* instance */, -1 /* page_id */, kUrl2, |
459 content::Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), | 436 Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), |
460 string16() /* title */, content::PAGE_TRANSITION_LINK, | 437 string16() /* title */, PAGE_TRANSITION_LINK, |
461 true /* is_renderer_init */); | 438 true /* is_renderer_init */); |
462 host = manager.Navigate(entry2); | 439 host = manager.Navigate(entry2); |
463 | 440 |
464 // The RenderViewHost created in Init will be reused. | 441 // The RenderViewHost created in Init will be reused. |
465 EXPECT_TRUE(host == manager.current_host()); | 442 EXPECT_TRUE(host == manager.current_host()); |
466 EXPECT_FALSE(manager.pending_render_view_host()); | 443 EXPECT_FALSE(manager.pending_render_view_host()); |
467 | 444 |
468 // Commit. | 445 // Commit. |
469 manager.DidNavigateMainFrame(host); | 446 manager.DidNavigateMainFrame(host); |
470 EXPECT_TRUE(host == manager.current_host()); | 447 EXPECT_TRUE(host == manager.current_host()); |
471 ASSERT_TRUE(host); | 448 ASSERT_TRUE(host); |
472 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 449 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
473 HasSite()); | 450 HasSite()); |
474 | 451 |
475 // 3) Cross-site navigate to next site. -------------- | 452 // 3) Cross-site navigate to next site. -------------- |
476 const GURL kUrl3("http://webkit.org/"); | 453 const GURL kUrl3("http://webkit.org/"); |
477 NavigationEntryImpl entry3( | 454 NavigationEntryImpl entry3( |
478 NULL /* instance */, -1 /* page_id */, kUrl3, | 455 NULL /* instance */, -1 /* page_id */, kUrl3, |
479 content::Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), | 456 Referrer(kUrl2, WebKit::WebReferrerPolicyDefault), |
480 string16() /* title */, content::PAGE_TRANSITION_LINK, | 457 string16() /* title */, PAGE_TRANSITION_LINK, |
481 false /* is_renderer_init */); | 458 false /* is_renderer_init */); |
482 host = manager.Navigate(entry3); | 459 host = manager.Navigate(entry3); |
483 | 460 |
484 // A new RenderViewHost should be created. | 461 // A new RenderViewHost should be created. |
485 EXPECT_TRUE(manager.pending_render_view_host()); | 462 EXPECT_TRUE(manager.pending_render_view_host()); |
486 ASSERT_EQ(host, manager.pending_render_view_host()); | 463 ASSERT_EQ(host, manager.pending_render_view_host()); |
487 | 464 |
488 notifications.Reset(); | 465 notifications.Reset(); |
489 | 466 |
490 // Commit. | 467 // Commit. |
491 manager.DidNavigateMainFrame(manager.pending_render_view_host()); | 468 manager.DidNavigateMainFrame(manager.pending_render_view_host()); |
492 EXPECT_TRUE(host == manager.current_host()); | 469 EXPECT_TRUE(host == manager.current_host()); |
493 ASSERT_TRUE(host); | 470 ASSERT_TRUE(host); |
494 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 471 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
495 HasSite()); | 472 HasSite()); |
496 // Check the pending RenderViewHost has been committed. | 473 // Check the pending RenderViewHost has been committed. |
497 EXPECT_FALSE(manager.pending_render_view_host()); | 474 EXPECT_FALSE(manager.pending_render_view_host()); |
498 | 475 |
499 // We should observe a notification. | 476 // We should observe a notification. |
500 EXPECT_TRUE(notifications.Check1AndReset( | 477 EXPECT_TRUE(notifications.Check1AndReset( |
501 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 478 NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
502 } | 479 } |
503 | 480 |
504 // Tests the Navigate function. In this unit test we verify that the Navigate | 481 // Tests the Navigate function. In this unit test we verify that the Navigate |
505 // function can handle a new navigation event before the previous navigation | 482 // function can handle a new navigation event before the previous navigation |
506 // has been committed. This is also a regression test for | 483 // has been committed. This is also a regression test for |
507 // http://crbug.com/104600. | 484 // http://crbug.com/104600. |
508 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { | 485 TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { |
509 content::TestNotificationTracker notifications; | 486 TestNotificationTracker notifications; |
510 | 487 |
511 SiteInstance* instance = SiteInstance::Create(browser_context()); | 488 SiteInstance* instance = SiteInstance::Create(browser_context()); |
512 | 489 |
513 scoped_ptr<TestWebContents> web_contents( | 490 scoped_ptr<TestWebContents> web_contents( |
514 TestWebContents::Create(browser_context(), instance)); | 491 TestWebContents::Create(browser_context(), instance)); |
515 notifications.ListenFor( | 492 notifications.ListenFor( |
516 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 493 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
517 content::Source<NavigationController>( | 494 Source<NavigationController>(&web_contents->GetController())); |
518 &web_contents->GetController())); | |
519 | 495 |
520 // Create. | 496 // Create. |
521 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 497 RenderViewHostManager manager(web_contents.get(), web_contents.get(), |
522 web_contents.get()); | 498 web_contents.get()); |
523 | 499 |
524 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 500 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
525 | 501 |
526 // 1) The first navigation. -------------------------- | 502 // 1) The first navigation. -------------------------- |
527 const GURL kUrl1("http://www.google.com/"); | 503 const GURL kUrl1("http://www.google.com/"); |
528 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, | 504 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, |
529 content::Referrer(), string16() /* title */, | 505 Referrer(), string16() /* title */, |
530 content::PAGE_TRANSITION_TYPED, | 506 PAGE_TRANSITION_TYPED, |
531 false /* is_renderer_init */); | 507 false /* is_renderer_init */); |
532 RenderViewHost* host = manager.Navigate(entry1); | 508 RenderViewHost* host = manager.Navigate(entry1); |
533 | 509 |
534 // The RenderViewHost created in Init will be reused. | 510 // The RenderViewHost created in Init will be reused. |
535 EXPECT_TRUE(host == manager.current_host()); | 511 EXPECT_TRUE(host == manager.current_host()); |
536 EXPECT_FALSE(manager.pending_render_view_host()); | 512 EXPECT_FALSE(manager.pending_render_view_host()); |
537 | 513 |
538 // We should observe a notification. | 514 // We should observe a notification. |
539 EXPECT_TRUE(notifications.Check1AndReset( | 515 EXPECT_TRUE(notifications.Check1AndReset( |
540 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 516 NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
541 notifications.Reset(); | 517 notifications.Reset(); |
542 | 518 |
543 // Commit. | 519 // Commit. |
544 manager.DidNavigateMainFrame(host); | 520 manager.DidNavigateMainFrame(host); |
545 | 521 |
546 // Commit to SiteInstance should be delayed until RenderView commit. | 522 // Commit to SiteInstance should be delayed until RenderView commit. |
547 EXPECT_TRUE(host == manager.current_host()); | 523 EXPECT_TRUE(host == manager.current_host()); |
548 ASSERT_TRUE(host); | 524 ASSERT_TRUE(host); |
549 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 525 EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
550 HasSite()); | 526 HasSite()); |
551 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); | 527 static_cast<SiteInstanceImpl*>(host->GetSiteInstance())->SetSite(kUrl1); |
552 | 528 |
553 // 2) Cross-site navigate to next site. ------------------------- | 529 // 2) Cross-site navigate to next site. ------------------------- |
554 const GURL kUrl2("http://www.example.com"); | 530 const GURL kUrl2("http://www.example.com"); |
555 NavigationEntryImpl entry2( | 531 NavigationEntryImpl entry2( |
556 NULL /* instance */, -1 /* page_id */, kUrl2, content::Referrer(), | 532 NULL /* instance */, -1 /* page_id */, kUrl2, Referrer(), |
557 string16() /* title */, content::PAGE_TRANSITION_TYPED, | 533 string16() /* title */, PAGE_TRANSITION_TYPED, |
558 false /* is_renderer_init */); | 534 false /* is_renderer_init */); |
559 RenderViewHostImpl* host2 = static_cast<RenderViewHostImpl*>( | 535 RenderViewHostImpl* host2 = static_cast<RenderViewHostImpl*>( |
560 manager.Navigate(entry2)); | 536 manager.Navigate(entry2)); |
561 int host2_process_id = host2->GetProcess()->GetID(); | 537 int host2_process_id = host2->GetProcess()->GetID(); |
562 | 538 |
563 // A new RenderViewHost should be created. | 539 // A new RenderViewHost should be created. |
564 EXPECT_TRUE(manager.pending_render_view_host()); | 540 EXPECT_TRUE(manager.pending_render_view_host()); |
565 ASSERT_EQ(host2, manager.pending_render_view_host()); | 541 ASSERT_EQ(host2, manager.pending_render_view_host()); |
566 EXPECT_NE(host2, host); | 542 EXPECT_NE(host2, host); |
567 | 543 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 EXPECT_FALSE(static_cast<RenderViewHostImpl*>( | 575 EXPECT_FALSE(static_cast<RenderViewHostImpl*>( |
600 manager.current_host())->is_swapped_out()); | 576 manager.current_host())->is_swapped_out()); |
601 EXPECT_EQ(host2, manager.pending_render_view_host()); | 577 EXPECT_EQ(host2, manager.pending_render_view_host()); |
602 // There should be still no navigation messages being sent. | 578 // There should be still no navigation messages being sent. |
603 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( | 579 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( |
604 ViewMsg_Navigate::ID)); | 580 ViewMsg_Navigate::ID)); |
605 | 581 |
606 // 3) Cross-site navigate to next site before 2) has committed. -------------- | 582 // 3) Cross-site navigate to next site before 2) has committed. -------------- |
607 const GURL kUrl3("http://webkit.org/"); | 583 const GURL kUrl3("http://webkit.org/"); |
608 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3, | 584 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3, |
609 content::Referrer(), string16() /* title */, | 585 Referrer(), string16() /* title */, |
610 content::PAGE_TRANSITION_TYPED, | 586 PAGE_TRANSITION_TYPED, |
611 false /* is_renderer_init */); | 587 false /* is_renderer_init */); |
612 test_process_host->sink().ClearMessages(); | 588 test_process_host->sink().ClearMessages(); |
613 RenderViewHost* host3 = manager.Navigate(entry3); | 589 RenderViewHost* host3 = manager.Navigate(entry3); |
614 | 590 |
615 // A new RenderViewHost should be created. host2 is now deleted. | 591 // A new RenderViewHost should be created. host2 is now deleted. |
616 EXPECT_TRUE(manager.pending_render_view_host()); | 592 EXPECT_TRUE(manager.pending_render_view_host()); |
617 ASSERT_EQ(host3, manager.pending_render_view_host()); | 593 ASSERT_EQ(host3, manager.pending_render_view_host()); |
618 EXPECT_NE(host3, host); | 594 EXPECT_NE(host3, host); |
619 EXPECT_NE(host3->GetProcess()->GetID(), host2_process_id); | 595 EXPECT_NE(host3->GetProcess()->GetID(), host2_process_id); |
620 | 596 |
(...skipping 26 matching lines...) Expand all Loading... |
647 manager.DidNavigateMainFrame(host3); | 623 manager.DidNavigateMainFrame(host3); |
648 EXPECT_TRUE(host3 == manager.current_host()); | 624 EXPECT_TRUE(host3 == manager.current_host()); |
649 ASSERT_TRUE(host3); | 625 ASSERT_TRUE(host3); |
650 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> | 626 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> |
651 HasSite()); | 627 HasSite()); |
652 // Check the pending RenderViewHost has been committed. | 628 // Check the pending RenderViewHost has been committed. |
653 EXPECT_FALSE(manager.pending_render_view_host()); | 629 EXPECT_FALSE(manager.pending_render_view_host()); |
654 | 630 |
655 // We should observe a notification. | 631 // We should observe a notification. |
656 EXPECT_TRUE(notifications.Check1AndReset( | 632 EXPECT_TRUE(notifications.Check1AndReset( |
657 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 633 NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
658 } | 634 } |
659 | 635 |
660 // Tests WebUI creation. | 636 // Tests WebUI creation. |
661 TEST_F(RenderViewHostManagerTest, WebUI) { | 637 TEST_F(RenderViewHostManagerTest, WebUI) { |
662 set_should_create_webui(true); | 638 set_should_create_webui(true); |
663 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); | 639 BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); |
664 SiteInstance* instance = SiteInstance::Create(browser_context()); | 640 SiteInstance* instance = SiteInstance::Create(browser_context()); |
665 | 641 |
666 scoped_ptr<TestWebContents> web_contents( | 642 scoped_ptr<TestWebContents> web_contents( |
667 TestWebContents::Create(browser_context(), instance)); | 643 TestWebContents::Create(browser_context(), instance)); |
668 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 644 RenderViewHostManager manager(web_contents.get(), web_contents.get(), |
669 web_contents.get()); | 645 web_contents.get()); |
670 | 646 |
671 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 647 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
672 | 648 |
673 const GURL kUrl(content::kTestNewTabURL); | 649 const GURL kUrl(kTestNewTabURL); |
674 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, | 650 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, |
675 content::Referrer(), string16() /* title */, | 651 Referrer(), string16() /* title */, |
676 content::PAGE_TRANSITION_TYPED, | 652 PAGE_TRANSITION_TYPED, |
677 false /* is_renderer_init */); | 653 false /* is_renderer_init */); |
678 RenderViewHost* host = manager.Navigate(entry); | 654 RenderViewHost* host = manager.Navigate(entry); |
679 | 655 |
680 EXPECT_TRUE(host); | 656 EXPECT_TRUE(host); |
681 EXPECT_TRUE(host == manager.current_host()); | 657 EXPECT_TRUE(host == manager.current_host()); |
682 EXPECT_FALSE(manager.pending_render_view_host()); | 658 EXPECT_FALSE(manager.pending_render_view_host()); |
683 | 659 |
684 // It's important that the site instance get set on the Web UI page as soon | 660 // It's important that the site instance get set on the Web UI page as soon |
685 // as the navigation starts, rather than lazily after it commits, so we don't | 661 // as the navigation starts, rather than lazily after it commits, so we don't |
686 // try to re-use the SiteInstance/process for non DOM-UI things that may | 662 // try to re-use the SiteInstance/process for non DOM-UI things that may |
687 // get loaded in between. | 663 // get loaded in between. |
688 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 664 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
689 HasSite()); | 665 HasSite()); |
690 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); | 666 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); |
691 | 667 |
692 // The Web UI is committed immediately because the RenderViewHost has not been | 668 // The Web UI is committed immediately because the RenderViewHost has not been |
693 // used yet. UpdateRendererStateForNavigate() took the short cut path. | 669 // used yet. UpdateRendererStateForNavigate() took the short cut path. |
694 EXPECT_FALSE(manager.pending_web_ui()); | 670 EXPECT_FALSE(manager.pending_web_ui()); |
695 EXPECT_TRUE(manager.web_ui()); | 671 EXPECT_TRUE(manager.web_ui()); |
696 | 672 |
697 // Commit. | 673 // Commit. |
698 manager.DidNavigateMainFrame(host); | 674 manager.DidNavigateMainFrame(host); |
699 EXPECT_TRUE(host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI); | 675 EXPECT_TRUE(host->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
700 } | 676 } |
701 | 677 |
702 // Tests that we don't end up in an inconsistent state if a page does a back and | 678 // Tests that we don't end up in an inconsistent state if a page does a back and |
703 // then reload. http://crbug.com/51680 | 679 // then reload. http://crbug.com/51680 |
704 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { | 680 TEST_F(RenderViewHostManagerTest, PageDoesBackAndReload) { |
705 const GURL kUrl1("http://www.google.com/"); | 681 const GURL kUrl1("http://www.google.com/"); |
706 const GURL kUrl2("http://www.evil-site.com/"); | 682 const GURL kUrl2("http://www.evil-site.com/"); |
707 | 683 |
708 // Navigate to a safe site, then an evil site. | 684 // Navigate to a safe site, then an evil site. |
709 // This will switch RenderViewHosts. We cannot assert that the first and | 685 // This will switch RenderViewHosts. We cannot assert that the first and |
710 // second RVHs are different, though, because the first one may be promptly | 686 // second RVHs are different, though, because the first one may be promptly |
711 // deleted. | 687 // deleted. |
712 contents()->NavigateAndCommit(kUrl1); | 688 contents()->NavigateAndCommit(kUrl1); |
713 contents()->NavigateAndCommit(kUrl2); | 689 contents()->NavigateAndCommit(kUrl2); |
714 RenderViewHost* evil_rvh = contents()->GetRenderViewHost(); | 690 RenderViewHost* evil_rvh = contents()->GetRenderViewHost(); |
715 | 691 |
716 // Now let's simulate the evil page calling history.back(). | 692 // Now let's simulate the evil page calling history.back(). |
717 contents()->OnGoToEntryAtOffset(-1); | 693 contents()->OnGoToEntryAtOffset(-1); |
718 // We should have a new pending RVH. | 694 // We should have a new pending RVH. |
719 // Note that in this case, the navigation has not committed, so evil_rvh will | 695 // Note that in this case, the navigation has not committed, so evil_rvh will |
720 // not be deleted yet. | 696 // not be deleted yet. |
721 EXPECT_NE(evil_rvh, contents()->GetRenderManagerForTesting()-> | 697 EXPECT_NE(evil_rvh, contents()->GetRenderManagerForTesting()-> |
722 pending_render_view_host()); | 698 pending_render_view_host()); |
723 | 699 |
724 // Before that RVH has committed, the evil page reloads itself. | 700 // Before that RVH has committed, the evil page reloads itself. |
725 ViewHostMsg_FrameNavigate_Params params; | 701 ViewHostMsg_FrameNavigate_Params params; |
726 params.page_id = 1; | 702 params.page_id = 1; |
727 params.url = kUrl2; | 703 params.url = kUrl2; |
728 params.transition = content::PAGE_TRANSITION_CLIENT_REDIRECT; | 704 params.transition = PAGE_TRANSITION_CLIENT_REDIRECT; |
729 params.should_update_history = false; | 705 params.should_update_history = false; |
730 params.gesture = NavigationGestureAuto; | 706 params.gesture = NavigationGestureAuto; |
731 params.was_within_same_page = false; | 707 params.was_within_same_page = false; |
732 params.is_post = false; | 708 params.is_post = false; |
733 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(kUrl2)); | 709 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(kUrl2)); |
734 contents()->DidNavigate(evil_rvh, params); | 710 contents()->DidNavigate(evil_rvh, params); |
735 | 711 |
736 // That should have cancelled the pending RVH, and the evil RVH should be the | 712 // That should have cancelled the pending RVH, and the evil RVH should be the |
737 // current one. | 713 // current one. |
738 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 714 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 EXPECT_FALSE(rvh2->is_swapped_out()); | 759 EXPECT_FALSE(rvh2->is_swapped_out()); |
784 EXPECT_TRUE(rvh1->is_swapped_out()); | 760 EXPECT_TRUE(rvh1->is_swapped_out()); |
785 } | 761 } |
786 | 762 |
787 // Test that we create swapped out RVHs for the opener chain when navigating an | 763 // Test that we create swapped out RVHs for the opener chain when navigating an |
788 // opened tab cross-process. This allows us to support certain cross-process | 764 // opened tab cross-process. This allows us to support certain cross-process |
789 // JavaScript calls (http://crbug.com/99202). | 765 // JavaScript calls (http://crbug.com/99202). |
790 TEST_F(RenderViewHostManagerTest, CreateSwappedOutOpenerRVHs) { | 766 TEST_F(RenderViewHostManagerTest, CreateSwappedOutOpenerRVHs) { |
791 const GURL kUrl1("http://www.google.com/"); | 767 const GURL kUrl1("http://www.google.com/"); |
792 const GURL kUrl2("http://www.chromium.org/"); | 768 const GURL kUrl2("http://www.chromium.org/"); |
793 const GURL kNtpUrl(content::kTestNewTabURL); | 769 const GURL kNtpUrl(kTestNewTabURL); |
794 | 770 |
795 // Navigate to an initial URL. | 771 // Navigate to an initial URL. |
796 contents()->NavigateAndCommit(kUrl1); | 772 contents()->NavigateAndCommit(kUrl1); |
797 RenderViewHostManager* manager = contents()->GetRenderManagerForTesting(); | 773 RenderViewHostManager* manager = contents()->GetRenderManagerForTesting(); |
798 TestRenderViewHost* rvh1 = test_rvh(); | 774 TestRenderViewHost* rvh1 = test_rvh(); |
799 | 775 |
800 // Create 2 new tabs and simulate them being the opener chain for the main | 776 // Create 2 new tabs and simulate them being the opener chain for the main |
801 // tab. They should be in the same SiteInstance. | 777 // tab. They should be in the same SiteInstance. |
802 scoped_ptr<TestWebContents> opener1( | 778 scoped_ptr<TestWebContents> opener1( |
803 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); | 779 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 TEST_F(RenderViewHostManagerTest, EnableWebUIWithSwappedOutOpener) { | 833 TEST_F(RenderViewHostManagerTest, EnableWebUIWithSwappedOutOpener) { |
858 set_should_create_webui(true); | 834 set_should_create_webui(true); |
859 const GURL kSettingsUrl("chrome://chrome/settings"); | 835 const GURL kSettingsUrl("chrome://chrome/settings"); |
860 const GURL kPluginUrl("chrome://plugins"); | 836 const GURL kPluginUrl("chrome://plugins"); |
861 | 837 |
862 // Navigate to an initial WebUI URL. | 838 // Navigate to an initial WebUI URL. |
863 contents()->NavigateAndCommit(kSettingsUrl); | 839 contents()->NavigateAndCommit(kSettingsUrl); |
864 | 840 |
865 // Ensure the RVH has WebUI bindings. | 841 // Ensure the RVH has WebUI bindings. |
866 TestRenderViewHost* rvh1 = test_rvh(); | 842 TestRenderViewHost* rvh1 = test_rvh(); |
867 EXPECT_TRUE(rvh1->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI); | 843 EXPECT_TRUE(rvh1->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
868 | 844 |
869 // Create a new tab and simulate it being the opener for the main | 845 // Create a new tab and simulate it being the opener for the main |
870 // tab. It should be in the same SiteInstance. | 846 // tab. It should be in the same SiteInstance. |
871 scoped_ptr<TestWebContents> opener1( | 847 scoped_ptr<TestWebContents> opener1( |
872 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); | 848 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); |
873 RenderViewHostManager* opener1_manager = | 849 RenderViewHostManager* opener1_manager = |
874 opener1->GetRenderManagerForTesting(); | 850 opener1->GetRenderManagerForTesting(); |
875 contents()->SetOpener(opener1.get()); | 851 contents()->SetOpener(opener1.get()); |
876 | 852 |
877 // Navigate to a different WebUI URL (different SiteInstance, same | 853 // Navigate to a different WebUI URL (different SiteInstance, same |
878 // BrowsingInstance). | 854 // BrowsingInstance). |
879 contents()->NavigateAndCommit(kPluginUrl); | 855 contents()->NavigateAndCommit(kPluginUrl); |
880 TestRenderViewHost* rvh2 = test_rvh(); | 856 TestRenderViewHost* rvh2 = test_rvh(); |
881 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 857 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
882 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 858 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
883 rvh2->GetSiteInstance())); | 859 rvh2->GetSiteInstance())); |
884 | 860 |
885 // Ensure a swapped out RVH is created in the first opener tab. | 861 // Ensure a swapped out RVH is created in the first opener tab. |
886 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 862 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
887 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 863 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
888 EXPECT_TRUE(opener1_manager->IsSwappedOut(opener1_rvh)); | 864 EXPECT_TRUE(opener1_manager->IsSwappedOut(opener1_rvh)); |
889 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 865 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
890 | 866 |
891 // Ensure the new RVH has WebUI bindings. | 867 // Ensure the new RVH has WebUI bindings. |
892 EXPECT_TRUE(rvh2->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI); | 868 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
893 } | 869 } |
894 | 870 |
895 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 871 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
896 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { | 872 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { |
897 content::TestNotificationTracker notifications; | 873 TestNotificationTracker notifications; |
898 | 874 |
899 GURL guest_url("guest://abc123"); | 875 GURL guest_url("guest://abc123"); |
900 SiteInstance* instance = | 876 SiteInstance* instance = |
901 SiteInstance::CreateForURL(browser_context(), guest_url); | 877 SiteInstance::CreateForURL(browser_context(), guest_url); |
902 scoped_ptr<TestWebContents> web_contents( | 878 scoped_ptr<TestWebContents> web_contents( |
903 TestWebContents::Create(browser_context(), instance)); | 879 TestWebContents::Create(browser_context(), instance)); |
904 | 880 |
905 // Create. | 881 // Create. |
906 RenderViewHostManager manager(web_contents.get(), web_contents.get(), | 882 RenderViewHostManager manager(web_contents.get(), web_contents.get(), |
907 web_contents.get()); | 883 web_contents.get()); |
908 | 884 |
909 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); | 885 manager.Init(browser_context(), instance, MSG_ROUTING_NONE); |
910 | 886 |
911 RenderViewHost* host; | 887 RenderViewHost* host; |
912 | 888 |
913 // 1) The first navigation. -------------------------- | 889 // 1) The first navigation. -------------------------- |
914 const GURL kUrl1("http://www.google.com/"); | 890 const GURL kUrl1("http://www.google.com/"); |
915 NavigationEntryImpl entry1( | 891 NavigationEntryImpl entry1( |
916 NULL /* instance */, -1 /* page_id */, kUrl1, content::Referrer(), | 892 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), |
917 string16() /* title */, content::PAGE_TRANSITION_TYPED, | 893 string16() /* title */, PAGE_TRANSITION_TYPED, |
918 false /* is_renderer_init */); | 894 false /* is_renderer_init */); |
919 host = manager.Navigate(entry1); | 895 host = manager.Navigate(entry1); |
920 | 896 |
921 // The RenderViewHost created in Init will be reused. | 897 // The RenderViewHost created in Init will be reused. |
922 EXPECT_TRUE(host == manager.current_host()); | 898 EXPECT_TRUE(host == manager.current_host()); |
923 EXPECT_FALSE(manager.pending_render_view_host()); | 899 EXPECT_FALSE(manager.pending_render_view_host()); |
924 EXPECT_EQ(manager.current_host()->GetSiteInstance(), instance); | 900 EXPECT_EQ(manager.current_host()->GetSiteInstance(), instance); |
925 | 901 |
926 // Commit. | 902 // Commit. |
927 manager.DidNavigateMainFrame(host); | 903 manager.DidNavigateMainFrame(host); |
928 // Commit to SiteInstance should be delayed until RenderView commit. | 904 // Commit to SiteInstance should be delayed until RenderView commit. |
929 EXPECT_EQ(host, manager.current_host()); | 905 EXPECT_EQ(host, manager.current_host()); |
930 ASSERT_TRUE(host); | 906 ASSERT_TRUE(host); |
931 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> | 907 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->GetSiteInstance())-> |
932 HasSite()); | 908 HasSite()); |
933 | 909 |
934 // 2) Navigate to a different domain. ------------------------- | 910 // 2) Navigate to a different domain. ------------------------- |
935 // Guests stay in the same process on navigation. | 911 // Guests stay in the same process on navigation. |
936 const GURL kUrl2("http://www.chromium.org"); | 912 const GURL kUrl2("http://www.chromium.org"); |
937 NavigationEntryImpl entry2( | 913 NavigationEntryImpl entry2( |
938 NULL /* instance */, -1 /* page_id */, kUrl2, | 914 NULL /* instance */, -1 /* page_id */, kUrl2, |
939 content::Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), | 915 Referrer(kUrl1, WebKit::WebReferrerPolicyDefault), |
940 string16() /* title */, content::PAGE_TRANSITION_LINK, | 916 string16() /* title */, PAGE_TRANSITION_LINK, |
941 true /* is_renderer_init */); | 917 true /* is_renderer_init */); |
942 host = manager.Navigate(entry2); | 918 host = manager.Navigate(entry2); |
943 | 919 |
944 // The RenderViewHost created in Init will be reused. | 920 // The RenderViewHost created in Init will be reused. |
945 EXPECT_EQ(host, manager.current_host()); | 921 EXPECT_EQ(host, manager.current_host()); |
946 EXPECT_FALSE(manager.pending_render_view_host()); | 922 EXPECT_FALSE(manager.pending_render_view_host()); |
947 | 923 |
948 // Commit. | 924 // Commit. |
949 manager.DidNavigateMainFrame(host); | 925 manager.DidNavigateMainFrame(host); |
950 EXPECT_EQ(host, manager.current_host()); | 926 EXPECT_EQ(host, manager.current_host()); |
951 ASSERT_TRUE(host); | 927 ASSERT_TRUE(host); |
952 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), | 928 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), |
953 instance); | 929 instance); |
| 930 } |
954 | 931 |
955 } | 932 } // namespace content |
OLD | NEW |