Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 805563003: Track referenced files of subframes in PageState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/page_state_serialization.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | content/common/page_state_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698