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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/common/page_state_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <set> 5 #include <set>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 // Ensure that the file access still exists in the new process ID. 1588 // Ensure that the file access still exists in the new process ID.
1589 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( 1589 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
1590 shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path)); 1590 shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path));
1591 1591
1592 // Navigate to a same site page to trigger a PageState update and ensure the 1592 // Navigate to a same site page to trigger a PageState update and ensure the
1593 // renderer is not killed. 1593 // renderer is not killed.
1594 EXPECT_TRUE( 1594 EXPECT_TRUE(
1595 NavigateToURL(shell(), test_server()->GetURL("files/title2.html"))); 1595 NavigateToURL(shell(), test_server()->GetURL("files/title2.html")));
1596 } 1596 }
1597 1597
1598 // Test for http://crbug.com/441966.
1599 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
1600 RestoreSubframeFileAccessForHistoryNavigation) {
1601 StartServer();
1602 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.
1603 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
1604 file_path = file_path.AppendASCII("bar");
1605
1606 // Navigate to url and get it to reference a file in its PageState.
1607 GURL url1(test_server()->GetURL("files/file_input_subframe.html"));
1608 NavigateToURL(shell(), url1);
1609 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
1610 FrameTreeNode* root = wc->GetFrameTree()->root();
1611 int process_id = shell()->web_contents()->GetRenderProcessHost()->GetID();
1612 scoped_ptr<FileChooserDelegate> delegate(new FileChooserDelegate(file_path));
1613 shell()->web_contents()->SetDelegate(delegate.get());
1614 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(),
1615 "document.getElementById('fileinput').click();"));
1616 EXPECT_TRUE(delegate->file_chosen());
1617 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
1618 process_id, file_path));
1619
1620 // Navigate to a different process without access to the file, and wait for
1621 // the old process to exit.
1622 RenderProcessHostWatcher exit_observer(
1623 shell()->web_contents()->GetRenderProcessHost(),
1624 RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION);
1625 NavigateToURL(shell(), GetCrossSiteURL("files/title1.html"));
1626 exit_observer.Wait();
1627 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
1628 shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path));
1629
1630 // Ensure that the file ended up in the PageState of the previous entry.
1631 NavigationEntry* prev_entry =
1632 shell()->web_contents()->GetController().GetEntryAtIndex(0);
1633 EXPECT_EQ(url1, prev_entry->GetURL());
1634 const std::vector<base::FilePath>& file_paths =
1635 prev_entry->GetPageState().GetReferencedFiles();
1636 ASSERT_EQ(1U, file_paths.size());
1637 EXPECT_EQ(file_path, file_paths.at(0));
1638
1639 // Go back, ending up in a different RenderProcessHost than before.
1640 TestNavigationObserver back_nav_load_observer(shell()->web_contents());
1641 shell()->web_contents()->GetController().GoBack();
1642 back_nav_load_observer.Wait();
1643 EXPECT_NE(process_id,
1644 shell()->web_contents()->GetRenderProcessHost()->GetID());
1645
1646 // Ensure that the file access still exists in the new process ID.
1647 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
1648 shell()->web_contents()->GetRenderProcessHost()->GetID(), file_path));
1649 }
1650
1598 } // namespace content 1651 } // namespace content
OLDNEW
« 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