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> | |
9 #include <set> | 8 #include <set> |
10 | 9 |
11 #include "base/command_line.h" | 10 #include "base/command_line.h" |
12 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
13 #include "base/location.h" | 12 #include "base/location.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/path_service.h" | 14 #include "base/path_service.h" |
16 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
18 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
32 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
33 #include "content/public/browser/navigation_entry.h" | 32 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
35 #include "content/public/browser/resource_dispatcher_host.h" | 34 #include "content/public/browser/resource_dispatcher_host.h" |
36 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_contents_observer.h" | 36 #include "content/public/browser/web_contents_observer.h" |
38 #include "content/public/browser/web_ui_message_handler.h" | 37 #include "content/public/browser/web_ui_message_handler.h" |
39 #include "content/public/common/bindings_policy.h" | 38 #include "content/public/common/bindings_policy.h" |
40 #include "content/public/common/browser_side_navigation_policy.h" | 39 #include "content/public/common/browser_side_navigation_policy.h" |
41 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
| 41 #include "content/public/common/file_chooser_file_info.h" |
| 42 #include "content/public/common/file_chooser_params.h" |
42 #include "content/public/common/page_state.h" | 43 #include "content/public/common/page_state.h" |
43 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
44 #include "content/public/test/browser_test_utils.h" | 45 #include "content/public/test/browser_test_utils.h" |
45 #include "content/public/test/content_browser_test.h" | 46 #include "content/public/test/content_browser_test.h" |
46 #include "content/public/test/content_browser_test_utils.h" | 47 #include "content/public/test/content_browser_test_utils.h" |
47 #include "content/public/test/test_navigation_observer.h" | 48 #include "content/public/test/test_navigation_observer.h" |
48 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
49 #include "content/shell/browser/shell.h" | 50 #include "content/shell/browser/shell.h" |
50 #include "content/test/content_browser_test_utils_internal.h" | 51 #include "content/test/content_browser_test_utils_internal.h" |
51 #include "content/test/test_frame_navigation_observer.h" | 52 #include "content/test/test_frame_navigation_observer.h" |
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 // the SwapOut ACK or a timeout. | 1923 // the SwapOut ACK or a timeout. |
1923 ASSERT_TRUE(rfh->IsRenderFrameLive()); | 1924 ASSERT_TRUE(rfh->IsRenderFrameLive()); |
1924 ASSERT_FALSE(rfh->is_active()); | 1925 ASSERT_FALSE(rfh->is_active()); |
1925 | 1926 |
1926 // We specifically want verify behavior between swap-out and RFH destruction. | 1927 // We specifically want verify behavior between swap-out and RFH destruction. |
1927 ASSERT_FALSE(rfh_observer.deleted()); | 1928 ASSERT_FALSE(rfh_observer.deleted()); |
1928 | 1929 |
1929 EXPECT_FALSE(handler->IsJavascriptAllowed()); | 1930 EXPECT_FALSE(handler->IsJavascriptAllowed()); |
1930 } | 1931 } |
1931 | 1932 |
| 1933 class FileChooserDelegate : public WebContentsDelegate { |
| 1934 public: |
| 1935 FileChooserDelegate(const base::FilePath& file) |
| 1936 : file_(file), file_chosen_(false) {} |
| 1937 |
| 1938 void RunFileChooser(RenderFrameHost* render_frame_host, |
| 1939 const FileChooserParams& params) override { |
| 1940 // Send the selected file to the renderer process. |
| 1941 FileChooserFileInfo file_info; |
| 1942 file_info.file_path = file_; |
| 1943 std::vector<FileChooserFileInfo> files; |
| 1944 files.push_back(file_info); |
| 1945 render_frame_host->FilesSelectedInChooser(files, FileChooserParams::Open); |
| 1946 |
| 1947 file_chosen_ = true; |
| 1948 } |
| 1949 |
| 1950 bool file_chosen() { return file_chosen_; } |
| 1951 |
| 1952 private: |
| 1953 base::FilePath file_; |
| 1954 bool file_chosen_; |
| 1955 }; |
| 1956 |
1932 // Test for http://crbug.com/262948. | 1957 // Test for http://crbug.com/262948. |
1933 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 1958 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
1934 RestoreFileAccessForHistoryNavigation) { | 1959 RestoreFileAccessForHistoryNavigation) { |
1935 StartServer(); | 1960 StartServer(); |
1936 base::FilePath file; | 1961 base::FilePath file; |
1937 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file)); | 1962 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file)); |
1938 file = file.AppendASCII("bar"); | 1963 file = file.AppendASCII("bar"); |
1939 | 1964 |
1940 // Navigate to url and get it to reference a file in its PageState. | 1965 // Navigate to url and get it to reference a file in its PageState. |
1941 GURL url1(embedded_test_server()->GetURL("/file_input.html")); | 1966 GURL url1(embedded_test_server()->GetURL("/file_input.html")); |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 TestNavigationObserver commit_observer(web_contents); | 2809 TestNavigationObserver commit_observer(web_contents); |
2785 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); | 2810 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); |
2786 commit_observer.Wait(); | 2811 commit_observer.Wait(); |
2787 exit_observer.Wait(); | 2812 exit_observer.Wait(); |
2788 | 2813 |
2789 // Ensure the entry's title hasn't changed after the ignored commit. | 2814 // Ensure the entry's title hasn't changed after the ignored commit. |
2790 EXPECT_EQ(title, entry->GetTitle()); | 2815 EXPECT_EQ(title, entry->GetTitle()); |
2791 } | 2816 } |
2792 | 2817 |
2793 } // namespace content | 2818 } // namespace content |
OLD | NEW |