Chromium Code Reviews| 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/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 DCHECK(source == web_contents_); | 268 DCHECK(source == web_contents_); |
| 269 | 269 |
| 270 std::string ascii_message = base::UTF16ToASCII(message); | 270 std::string ascii_message = base::UTF16ToASCII(message); |
| 271 if (base::MatchPattern(ascii_message, filter_)) { | 271 if (base::MatchPattern(ascii_message, filter_)) { |
| 272 message_ = ascii_message; | 272 message_ = ascii_message; |
| 273 message_loop_runner_->Quit(); | 273 message_loop_runner_->Quit(); |
| 274 } | 274 } |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 | 277 |
| 278 // A BrowserMessageFilter that drops SwapOut ACK messages. | |
| 279 class SwapoutACKMessageFilter : public BrowserMessageFilter { | |
| 280 public: | |
| 281 SwapoutACKMessageFilter() : BrowserMessageFilter(FrameMsgStart) {} | |
| 282 | |
| 283 protected: | |
| 284 ~SwapoutACKMessageFilter() override {} | |
| 285 | |
| 286 private: | |
| 287 // BrowserMessageFilter: | |
| 288 bool OnMessageReceived(const IPC::Message& message) override { | |
| 289 return message.type() == FrameHostMsg_SwapOut_ACK::ID; | |
| 290 } | |
| 291 | |
| 292 DISALLOW_COPY_AND_ASSIGN(SwapoutACKMessageFilter); | |
| 293 }; | |
| 294 | |
| 278 } // namespace | 295 } // namespace |
| 279 | 296 |
| 280 // | 297 // |
| 281 // SitePerProcessBrowserTest | 298 // SitePerProcessBrowserTest |
| 282 // | 299 // |
| 283 | 300 |
| 284 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { | 301 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { |
| 285 }; | 302 }; |
| 286 | 303 |
| 287 std::string SitePerProcessBrowserTest::DepictFrameTree(FrameTreeNode* node) { | 304 std::string SitePerProcessBrowserTest::DepictFrameTree(FrameTreeNode* node) { |
| (...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3364 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 3381 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 3365 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 3382 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 3366 popup_root->child_at(0)->current_frame_host(), | 3383 popup_root->child_at(0)->current_frame_host(), |
| 3367 "window.domAutomationController.send(" | 3384 "window.domAutomationController.send(" |
| 3368 " postToOpenerOfSibling('subframe2', 'msg', '*'));", | 3385 " postToOpenerOfSibling('subframe2', 'msg', '*'));", |
| 3369 &success)); | 3386 &success)); |
| 3370 EXPECT_TRUE(success); | 3387 EXPECT_TRUE(success); |
| 3371 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 3388 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 3372 } | 3389 } |
| 3373 | 3390 |
| 3391 // Test for https://crbug.com/515302. Perform two navigations, A->B->A, and | |
| 3392 // delay the SwapOut ACK from the A->B navigation, so that the second B->A | |
| 3393 // navigation is initiated before the first page receives the SwapOut ACK. | |
| 3394 // Ensure that the RVH(A) that's pending deletion is not reused in that case. | |
| 3395 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 3396 RenderViewHostPendingDeletionIsNotReused) { | |
| 3397 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | |
| 3398 NavigateToURL(shell(), a_url); | |
| 3399 | |
| 3400 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 3401 ->GetFrameTree() | |
| 3402 ->root(); | |
| 3403 RenderFrameHostImpl* rfhi = root->current_frame_host(); | |
|
nasko
2015/09/18 19:06:17
nit: Either rfh or rvhi, for consistency. IMHO, th
alexmos
2015/09/18 22:37:05
Done.
| |
| 3404 RenderViewHostImpl* rvh = rfhi->render_view_host(); | |
| 3405 | |
| 3406 // Install a BrowserMessageFilter to drop SwapOut ACK messages in A's | |
| 3407 // process. | |
| 3408 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); | |
| 3409 rfhi->GetProcess()->AddFilter(filter.get()); | |
| 3410 | |
| 3411 // Navigate to B. The SwapOut completion should be delayed. | |
| 3412 GURL b_url(embedded_test_server()->GetURL("b.com", "/title2.html")); | |
| 3413 NavigateToURL(shell(), b_url); | |
| 3414 | |
| 3415 // Navigate back to A. Since there was no SwapOut ACK for A->B, this should | |
| 3416 // happen while first page's RenderFrameHost and RenderViewHost are pending | |
| 3417 // deletion. | |
| 3418 EXPECT_TRUE(root->render_manager()->IsPendingDeletion(rfhi)); | |
|
nasko
2015/09/18 19:06:17
nit: I would put those expectations right after th
alexmos
2015/09/18 22:37:05
Done.
| |
| 3419 EXPECT_TRUE(rvh->is_pending_deletion()); | |
| 3420 NavigateToURL(shell(), a_url); | |
|
nasko
2015/09/18 19:06:17
nit: I wonder if we should make this navigation as
alexmos
2015/09/18 22:37:05
Done.
| |
| 3421 | |
| 3422 // Check that the RenderViewHost wasn't reused. | |
| 3423 EXPECT_NE(rvh, shell()->web_contents()->GetRenderViewHost()); | |
| 3424 | |
| 3425 // Simulate that the dropped SwapOut ACK message arrives now on the original | |
| 3426 // RenderFrameHost. | |
| 3427 rfhi->OnSwappedOut(); | |
|
nasko
2015/09/18 19:06:17
For going the extra mile, should we put a RenderFr
alexmos
2015/09/18 22:37:05
Done.
| |
| 3428 } | |
| 3429 | |
| 3374 } // namespace content | 3430 } // namespace content |
| OLD | NEW |