OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Disable everything on windows only. http://crbug.com/306144 | 5 // Disable everything on windows only. http://crbug.com/306144 |
6 #ifndef OS_WIN | 6 #ifndef OS_WIN |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 #endif | 1566 #endif |
1567 | 1567 |
1568 // Test that we disallow certain headers case-insensitively. | 1568 // Test that we disallow certain headers case-insensitively. |
1569 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 1569 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
1570 MAYBE_DownloadExtensionTest_Download_UnsafeHeaders) { | 1570 MAYBE_DownloadExtensionTest_Download_UnsafeHeaders) { |
1571 LoadExtension("downloads_split"); | 1571 LoadExtension("downloads_split"); |
1572 ASSERT_TRUE(StartEmbeddedTestServer()); | 1572 ASSERT_TRUE(StartEmbeddedTestServer()); |
1573 ASSERT_TRUE(test_server()->Start()); | 1573 ASSERT_TRUE(test_server()->Start()); |
1574 GoOnTheRecord(); | 1574 GoOnTheRecord(); |
1575 | 1575 |
1576 static const char* kUnsafeHeaders[] = { | 1576 static const char* const kUnsafeHeaders[] = { |
1577 "Accept-chArsEt", | 1577 "Accept-chArsEt", |
1578 "accept-eNcoding", | 1578 "accept-eNcoding", |
1579 "coNNection", | 1579 "coNNection", |
1580 "coNteNt-leNgth", | 1580 "coNteNt-leNgth", |
1581 "cooKIE", | 1581 "cooKIE", |
1582 "cOOkie2", | 1582 "cOOkie2", |
1583 "coNteNt-traNsfer-eNcodiNg", | 1583 "coNteNt-traNsfer-eNcodiNg", |
1584 "dAtE", | 1584 "dAtE", |
1585 "ExpEcT", | 1585 "ExpEcT", |
1586 "hOsT", | 1586 "hOsT", |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 #define MAYBE_DownloadExtensionTest_Download_InvalidURLs \ | 1724 #define MAYBE_DownloadExtensionTest_Download_InvalidURLs \ |
1725 DownloadExtensionTest_Download_InvalidURLs | 1725 DownloadExtensionTest_Download_InvalidURLs |
1726 #endif | 1726 #endif |
1727 | 1727 |
1728 // Test that downloading invalid URLs immediately returns kInvalidURLError. | 1728 // Test that downloading invalid URLs immediately returns kInvalidURLError. |
1729 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 1729 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
1730 MAYBE_DownloadExtensionTest_Download_InvalidURLs) { | 1730 MAYBE_DownloadExtensionTest_Download_InvalidURLs) { |
1731 LoadExtension("downloads_split"); | 1731 LoadExtension("downloads_split"); |
1732 GoOnTheRecord(); | 1732 GoOnTheRecord(); |
1733 | 1733 |
1734 static const char* kInvalidURLs[] = { | 1734 static const char* const kInvalidURLs[] = { |
1735 "foo bar", | 1735 "foo bar", |
1736 "../hello", | 1736 "../hello", |
1737 "/hello", | 1737 "/hello", |
1738 "http://", | 1738 "http://", |
1739 "#frag", | 1739 "#frag", |
1740 "foo/bar.html#frag", | 1740 "foo/bar.html#frag", |
1741 "google.com/", | 1741 "google.com/", |
1742 }; | 1742 }; |
1743 | 1743 |
1744 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) { | 1744 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 | 2115 |
2116 // Test that DownloadsDownloadFunction propagates the Authorization header | 2116 // Test that DownloadsDownloadFunction propagates the Authorization header |
2117 // correctly. | 2117 // correctly. |
2118 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2118 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2119 DownloadExtensionTest_Download_AuthBasic) { | 2119 DownloadExtensionTest_Download_AuthBasic) { |
2120 LoadExtension("downloads_split"); | 2120 LoadExtension("downloads_split"); |
2121 ASSERT_TRUE(StartEmbeddedTestServer()); | 2121 ASSERT_TRUE(StartEmbeddedTestServer()); |
2122 ASSERT_TRUE(test_server()->Start()); | 2122 ASSERT_TRUE(test_server()->Start()); |
2123 std::string download_url = test_server()->GetURL("auth-basic").spec(); | 2123 std::string download_url = test_server()->GetURL("auth-basic").spec(); |
2124 // This is just base64 of 'username:secret'. | 2124 // This is just base64 of 'username:secret'. |
2125 static const char* kAuthorization = "dXNlcm5hbWU6c2VjcmV0"; | 2125 static const char kAuthorization[] = "dXNlcm5hbWU6c2VjcmV0"; |
2126 GoOnTheRecord(); | 2126 GoOnTheRecord(); |
2127 | 2127 |
2128 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 2128 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
2129 new DownloadsDownloadFunction(), base::StringPrintf( | 2129 new DownloadsDownloadFunction(), base::StringPrintf( |
2130 "[{\"url\": \"%s\"," | 2130 "[{\"url\": \"%s\"," |
2131 " \"filename\": \"auth-basic-succeed.txt\"," | 2131 " \"filename\": \"auth-basic-succeed.txt\"," |
2132 " \"headers\": [{" | 2132 " \"headers\": [{" |
2133 " \"name\": \"Authorization\"," | 2133 " \"name\": \"Authorization\"," |
2134 " \"value\": \"Basic %s\"}]}]", | 2134 " \"value\": \"Basic %s\"}]}]", |
2135 download_url.c_str(), kAuthorization))); | 2135 download_url.c_str(), kAuthorization))); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 DISABLED_DownloadExtensionTest_Download_FileSystemURL | 2344 DISABLED_DownloadExtensionTest_Download_FileSystemURL |
2345 #else | 2345 #else |
2346 #define MAYBE_DownloadExtensionTest_Download_FileSystemURL \ | 2346 #define MAYBE_DownloadExtensionTest_Download_FileSystemURL \ |
2347 DownloadExtensionTest_Download_FileSystemURL | 2347 DownloadExtensionTest_Download_FileSystemURL |
2348 #endif | 2348 #endif |
2349 | 2349 |
2350 // Test downloading filesystem: URLs. | 2350 // Test downloading filesystem: URLs. |
2351 // NOTE: chrome disallows creating HTML5 FileSystem Files in incognito. | 2351 // NOTE: chrome disallows creating HTML5 FileSystem Files in incognito. |
2352 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2352 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2353 MAYBE_DownloadExtensionTest_Download_FileSystemURL) { | 2353 MAYBE_DownloadExtensionTest_Download_FileSystemURL) { |
2354 static const char* kPayloadData = "on the record\ndata"; | 2354 static const char kPayloadData[] = "on the record\ndata"; |
2355 GoOnTheRecord(); | 2355 GoOnTheRecord(); |
2356 LoadExtension("downloads_split"); | 2356 LoadExtension("downloads_split"); |
2357 | 2357 |
2358 const std::string download_url = "filesystem:" + GetExtensionURL() + | 2358 const std::string download_url = "filesystem:" + GetExtensionURL() + |
2359 "temporary/on_record.txt"; | 2359 "temporary/on_record.txt"; |
2360 | 2360 |
2361 // Setup a file in the filesystem which we can download. | 2361 // Setup a file in the filesystem which we can download. |
2362 ASSERT_TRUE(HTML5FileWriter::CreateFileForTesting( | 2362 ASSERT_TRUE(HTML5FileWriter::CreateFileForTesting( |
2363 BrowserContext::GetDefaultStoragePartition(browser()->profile()) | 2363 BrowserContext::GetDefaultStoragePartition(browser()->profile()) |
2364 ->GetFileSystemContext(), | 2364 ->GetFileSystemContext(), |
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4080 | 4080 |
4081 TEST(DownloadInterruptReasonEnumsSynced, | 4081 TEST(DownloadInterruptReasonEnumsSynced, |
4082 DownloadInterruptReasonEnumsSynced) { | 4082 DownloadInterruptReasonEnumsSynced) { |
4083 #define INTERRUPT_REASON(name, value) \ | 4083 #define INTERRUPT_REASON(name, value) \ |
4084 EXPECT_EQ(InterruptReasonContentToExtension( \ | 4084 EXPECT_EQ(InterruptReasonContentToExtension( \ |
4085 content::DOWNLOAD_INTERRUPT_REASON_##name), \ | 4085 content::DOWNLOAD_INTERRUPT_REASON_##name), \ |
4086 downloads::INTERRUPT_REASON_##name); \ | 4086 downloads::INTERRUPT_REASON_##name); \ |
4087 EXPECT_EQ( \ | 4087 EXPECT_EQ( \ |
4088 InterruptReasonExtensionToContent(downloads::INTERRUPT_REASON_##name), \ | 4088 InterruptReasonExtensionToContent(downloads::INTERRUPT_REASON_##name), \ |
4089 content::DOWNLOAD_INTERRUPT_REASON_##name); | 4089 content::DOWNLOAD_INTERRUPT_REASON_##name); |
4090 #include "content/public/browser/download_interrupt_reason_values.h" | 4090 #include "content/public/browser/download_interrupt_reason_values.h" // NOLINT |
4091 #undef INTERRUPT_REASON | 4091 #undef INTERRUPT_REASON |
4092 } | 4092 } |
4093 | 4093 |
4094 TEST(ExtensionDetermineDownloadFilenameInternal, | 4094 TEST(ExtensionDetermineDownloadFilenameInternal, |
4095 ExtensionDetermineDownloadFilenameInternal) { | 4095 ExtensionDetermineDownloadFilenameInternal) { |
4096 std::string winner_id; | 4096 std::string winner_id; |
4097 base::FilePath filename; | 4097 base::FilePath filename; |
4098 downloads::FilenameConflictAction conflict_action = | 4098 downloads::FilenameConflictAction conflict_action = |
4099 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY; | 4099 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY; |
4100 WarningSet warnings; | 4100 WarningSet warnings; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4156 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 4156 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
4157 EXPECT_FALSE(warnings.empty()); | 4157 EXPECT_FALSE(warnings.empty()); |
4158 EXPECT_EQ(Warning::kDownloadFilenameConflict, | 4158 EXPECT_EQ(Warning::kDownloadFilenameConflict, |
4159 warnings.begin()->warning_type()); | 4159 warnings.begin()->warning_type()); |
4160 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 4160 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
4161 } | 4161 } |
4162 | 4162 |
4163 } // namespace extensions | 4163 } // namespace extensions |
4164 | 4164 |
4165 #endif // http://crbug.com/3061144 | 4165 #endif // http://crbug.com/3061144 |
OLD | NEW |