Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1932 // the SwapOut ACK or a timeout. | 1932 // the SwapOut ACK or a timeout. |
| 1933 ASSERT_TRUE(rfh->IsRenderFrameLive()); | 1933 ASSERT_TRUE(rfh->IsRenderFrameLive()); |
| 1934 ASSERT_FALSE(rfh->is_active()); | 1934 ASSERT_FALSE(rfh->is_active()); |
| 1935 | 1935 |
| 1936 // We specifically want verify behavior between swap-out and RFH destruction. | 1936 // We specifically want verify behavior between swap-out and RFH destruction. |
| 1937 ASSERT_FALSE(rfh_observer.deleted()); | 1937 ASSERT_FALSE(rfh_observer.deleted()); |
| 1938 | 1938 |
| 1939 EXPECT_FALSE(handler->IsJavascriptAllowed()); | 1939 EXPECT_FALSE(handler->IsJavascriptAllowed()); |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 // Test for http://crbug.com/703303. | |
| 1943 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | |
| 1944 DontGrantAccessToInvalidFilePaths) { | |
|
Charlie Reis
2017/04/14 19:28:15
This is based mostly on the following RestoreFileA
| |
| 1945 StartServer(); | |
| 1946 | |
| 1947 // Use a file path with an invalid encoding, such that it can't be converted | |
| 1948 // to a WebString. | |
| 1949 base::FilePath file; | |
| 1950 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file)); | |
| 1951 file = file.Append("foo\337bar"); | |
| 1952 | |
| 1953 // Navigate and try to get page to reference this file in its PageState. | |
| 1954 GURL url1(embedded_test_server()->GetURL("/file_input.html")); | |
| 1955 NavigateToURL(shell(), url1); | |
| 1956 int process_id = shell()->web_contents()->GetRenderProcessHost()->GetID(); | |
| 1957 std::unique_ptr<FileChooserDelegate> delegate(new FileChooserDelegate(file)); | |
| 1958 shell()->web_contents()->SetDelegate(delegate.get()); | |
| 1959 EXPECT_TRUE( | |
| 1960 ExecuteScript(shell(), "document.getElementById('fileinput').click();")); | |
| 1961 EXPECT_TRUE(delegate->file_chosen()); | |
| 1962 | |
| 1963 // No access should have been granted, since the browser process should | |
| 1964 // realize Blink can't handle it. | |
| 1965 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | |
| 1966 process_id, file)); | |
| 1967 | |
| 1968 // Disable the swap out timer so we wait for the UpdateState message. | |
| 1969 static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 1970 ->GetMainFrame() | |
| 1971 ->DisableSwapOutTimerForTesting(); | |
| 1972 | |
| 1973 // Navigate to a different process and wait for the old process to exit. | |
| 1974 RenderProcessHostWatcher exit_observer( | |
| 1975 shell()->web_contents()->GetRenderProcessHost(), | |
| 1976 RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); | |
| 1977 NavigateToURL(shell(), GetCrossSiteURL("/title1.html")); | |
| 1978 exit_observer.Wait(); | |
| 1979 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | |
| 1980 shell()->web_contents()->GetRenderProcessHost()->GetID(), file)); | |
| 1981 | |
| 1982 // Ensure that the file did not end up in the PageState of the previous entry. | |
| 1983 NavigationEntry* prev_entry = | |
| 1984 shell()->web_contents()->GetController().GetEntryAtIndex(0); | |
| 1985 EXPECT_EQ(url1, prev_entry->GetURL()); | |
| 1986 const std::vector<base::FilePath>& files = | |
| 1987 prev_entry->GetPageState().GetReferencedFiles(); | |
| 1988 ASSERT_EQ(0U, files.size()); | |
| 1989 } | |
| 1990 | |
| 1942 // Test for http://crbug.com/262948. | 1991 // Test for http://crbug.com/262948. |
| 1943 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 1992 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 1944 RestoreFileAccessForHistoryNavigation) { | 1993 RestoreFileAccessForHistoryNavigation) { |
| 1945 StartServer(); | 1994 StartServer(); |
| 1946 base::FilePath file; | 1995 base::FilePath file; |
| 1947 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file)); | 1996 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file)); |
| 1948 file = file.AppendASCII("bar"); | 1997 file = file.AppendASCII("bar"); |
| 1949 | 1998 |
| 1950 // Navigate to url and get it to reference a file in its PageState. | 1999 // Navigate to url and get it to reference a file in its PageState. |
| 1951 GURL url1(embedded_test_server()->GetURL("/file_input.html")); | 2000 GURL url1(embedded_test_server()->GetURL("/file_input.html")); |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3274 // than one ancestor has the same URL (excluding fragments), and the | 3323 // than one ancestor has the same URL (excluding fragments), and the |
| 3275 // navigating frame's current URL shouldn't count toward that. | 3324 // navigating frame's current URL shouldn't count toward that. |
| 3276 EXPECT_TRUE( | 3325 EXPECT_TRUE( |
| 3277 ExecuteScript(child, "location.href = '" + first_url.spec() + "';")); | 3326 ExecuteScript(child, "location.href = '" + first_url.spec() + "';")); |
| 3278 observer2.Wait(); | 3327 observer2.Wait(); |
| 3279 | 3328 |
| 3280 EXPECT_EQ(child->current_url(), first_url); | 3329 EXPECT_EQ(child->current_url(), first_url); |
| 3281 } | 3330 } |
| 3282 | 3331 |
| 3283 } // namespace content | 3332 } // namespace content |
| OLD | NEW |