Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| index 2c89788af469ec07a1496b3d4d615866a55a038d..46393943136c964c3379d7f3f1e462ee73cda46a 100644 |
| --- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| +++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc |
| @@ -1595,4 +1595,57 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| NavigateToURL(shell(), test_server()->GetURL("files/title2.html"))); |
| } |
| +// Test for http://crbug.com/441966. |
| +IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| + RestoreSubframeFileAccessForHistoryNavigation) { |
| + StartServer(); |
| + base::FilePath file_path; |
|
nasko
2014/12/13 00:28:47
nit: I kept on reading "file_path" as in "path to
Charlie Reis
2014/12/13 01:00:08
Done.
|
| + EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
| + file_path = file_path.AppendASCII("bar"); |
| + |
| + // Navigate to url and get it to reference a file in its PageState. |
| + GURL url1(test_server()->GetURL("files/file_input_subframe.html")); |
| + NavigateToURL(shell(), url1); |
| + WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); |
| + FrameTreeNode* root = wc->GetFrameTree()->root(); |
| + int process_id = shell()->web_contents()->GetRenderProcessHost()->GetID(); |
| + scoped_ptr<FileChooserDelegate> delegate(new FileChooserDelegate(file_path)); |
| + shell()->web_contents()->SetDelegate(delegate.get()); |
| + EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), |
| + "document.getElementById('fileinput').click();")); |
| + EXPECT_TRUE(delegate->file_chosen()); |
| + EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
| + process_id, file_path)); |
| + |
| + // Navigate to a different process without access to the file, and wait for |
| + // the old process to exit. |
| + RenderProcessHostWatcher exit_observer( |
| + shell()->web_contents()->GetRenderProcessHost(), |
| + RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); |
| + NavigateToURL(shell(), GetCrossSiteURL("files/title1.html")); |
| + exit_observer.Wait(); |
| + EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
| + shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path)); |
| + |
| + // Ensure that the file ended up in the PageState of the previous entry. |
| + NavigationEntry* prev_entry = |
| + shell()->web_contents()->GetController().GetEntryAtIndex(0); |
| + EXPECT_EQ(url1, prev_entry->GetURL()); |
| + const std::vector<base::FilePath>& file_paths = |
| + prev_entry->GetPageState().GetReferencedFiles(); |
| + ASSERT_EQ(1U, file_paths.size()); |
| + EXPECT_EQ(file_path, file_paths.at(0)); |
| + |
| + // Go back, ending up in a different RenderProcessHost than before. |
| + TestNavigationObserver back_nav_load_observer(shell()->web_contents()); |
| + shell()->web_contents()->GetController().GoBack(); |
| + back_nav_load_observer.Wait(); |
| + EXPECT_NE(process_id, |
| + shell()->web_contents()->GetRenderProcessHost()->GetID()); |
| + |
| + // Ensure that the file access still exists in the new process ID. |
| + EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
| + shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path)); |
| +} |
| + |
| } // namespace content |