| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 ASSERT_TRUE(item); | 1691 ASSERT_TRUE(item); |
| 1692 ScopedCancellingItem canceller(item); | 1692 ScopedCancellingItem canceller(item); |
| 1693 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1693 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1694 | 1694 |
| 1695 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1695 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1696 base::StringPrintf( | 1696 base::StringPrintf( |
| 1697 "[{\"danger\": \"safe\"," | 1697 "[{\"danger\": \"safe\"," |
| 1698 " \"incognito\": false," | 1698 " \"incognito\": false," |
| 1699 " \"mime\": \"text/plain\"," | 1699 " \"mime\": \"text/plain\"," |
| 1700 " \"paused\": false," | 1700 " \"paused\": false," |
| 1701 " \"finalUrl\": \"%s\"," |
| 1701 " \"url\": \"%s\"}]", | 1702 " \"url\": \"%s\"}]", |
| 1703 download_url.c_str(), |
| 1702 download_url.c_str()))); | 1704 download_url.c_str()))); |
| 1703 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1705 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1704 base::StringPrintf( | 1706 base::StringPrintf( |
| 1705 "[{\"id\": %d," | 1707 "[{\"id\": %d," |
| 1706 " \"filename\": {" | 1708 " \"filename\": {" |
| 1707 " \"previous\": \"\"," | 1709 " \"previous\": \"\"," |
| 1708 " \"current\": \"%s\"}}]", | 1710 " \"current\": \"%s\"}}]", |
| 1709 result_id, | 1711 result_id, |
| 1710 GetFilename("sub/dir/ect/ory.txt").c_str()))); | 1712 GetFilename("sub/dir/ect/ory.txt").c_str()))); |
| 1711 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1713 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 ASSERT_TRUE(item); | 1801 ASSERT_TRUE(item); |
| 1800 ScopedCancellingItem canceller(item); | 1802 ScopedCancellingItem canceller(item); |
| 1801 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1803 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1802 | 1804 |
| 1803 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1805 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1804 base::StringPrintf( | 1806 base::StringPrintf( |
| 1805 "[{\"danger\": \"safe\"," | 1807 "[{\"danger\": \"safe\"," |
| 1806 " \"incognito\": false," | 1808 " \"incognito\": false," |
| 1807 " \"mime\": \"text/plain\"," | 1809 " \"mime\": \"text/plain\"," |
| 1808 " \"paused\": false," | 1810 " \"paused\": false," |
| 1811 " \"finalUrl\": \"%s\"," |
| 1809 " \"url\": \"%s\"}]", | 1812 " \"url\": \"%s\"}]", |
| 1813 download_url.c_str(), |
| 1810 download_url.c_str()))); | 1814 download_url.c_str()))); |
| 1811 ASSERT_TRUE( | 1815 ASSERT_TRUE( |
| 1812 WaitFor(downloads::OnChanged::kEventName, | 1816 WaitFor(downloads::OnChanged::kEventName, |
| 1813 base::StringPrintf("[{\"id\": %d," | 1817 base::StringPrintf("[{\"id\": %d," |
| 1814 " \"filename\": {" | 1818 " \"filename\": {" |
| 1815 " \"previous\": \"\"," | 1819 " \"previous\": \"\"," |
| 1816 " \"current\": \"%s\"}}]", | 1820 " \"current\": \"%s\"}}]", |
| 1817 result_id, GetFilename("slow.txt").c_str()))); | 1821 result_id, GetFilename("slow.txt").c_str()))); |
| 1818 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1822 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1819 base::StringPrintf( | 1823 base::StringPrintf( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1842 ASSERT_TRUE(item); | 1846 ASSERT_TRUE(item); |
| 1843 ScopedCancellingItem canceller(item); | 1847 ScopedCancellingItem canceller(item); |
| 1844 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1848 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1845 | 1849 |
| 1846 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1850 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1847 base::StringPrintf( | 1851 base::StringPrintf( |
| 1848 "[{\"danger\": \"safe\"," | 1852 "[{\"danger\": \"safe\"," |
| 1849 " \"incognito\": false," | 1853 " \"incognito\": false," |
| 1850 " \"mime\": \"text/plain\"," | 1854 " \"mime\": \"text/plain\"," |
| 1851 " \"paused\": false," | 1855 " \"paused\": false," |
| 1856 " \"finalUrl\": \"%s\"," |
| 1852 " \"url\": \"%s\"}]", | 1857 " \"url\": \"%s\"}]", |
| 1858 download_url.c_str(), |
| 1853 download_url.c_str()))); | 1859 download_url.c_str()))); |
| 1854 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1860 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1855 base::StringPrintf( | 1861 base::StringPrintf( |
| 1856 "[{\"id\": %d," | 1862 "[{\"id\": %d," |
| 1857 " \"filename\": {" | 1863 " \"filename\": {" |
| 1858 " \"previous\": \"\"," | 1864 " \"previous\": \"\"," |
| 1859 " \"current\": \"%s\"}}]", | 1865 " \"current\": \"%s\"}}]", |
| 1860 result_id, | 1866 result_id, |
| 1861 GetFilename(kFilename).c_str()))); | 1867 GetFilename(kFilename).c_str()))); |
| 1862 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1868 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1878 ASSERT_TRUE(item); | 1884 ASSERT_TRUE(item); |
| 1879 ScopedCancellingItem canceller2(item); | 1885 ScopedCancellingItem canceller2(item); |
| 1880 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1886 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1881 | 1887 |
| 1882 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1888 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1883 base::StringPrintf( | 1889 base::StringPrintf( |
| 1884 "[{\"danger\": \"safe\"," | 1890 "[{\"danger\": \"safe\"," |
| 1885 " \"incognito\": false," | 1891 " \"incognito\": false," |
| 1886 " \"mime\": \"text/plain\"," | 1892 " \"mime\": \"text/plain\"," |
| 1887 " \"paused\": false," | 1893 " \"paused\": false," |
| 1894 " \"finalUrl\": \"%s\"," |
| 1888 " \"url\": \"%s\"}]", | 1895 " \"url\": \"%s\"}]", |
| 1896 download_url.c_str(), |
| 1889 download_url.c_str()))); | 1897 download_url.c_str()))); |
| 1890 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1898 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1891 base::StringPrintf( | 1899 base::StringPrintf( |
| 1892 "[{\"id\": %d," | 1900 "[{\"id\": %d," |
| 1893 " \"filename\": {" | 1901 " \"filename\": {" |
| 1894 " \"previous\": \"\"," | 1902 " \"previous\": \"\"," |
| 1895 " \"current\": \"%s\"}}]", | 1903 " \"current\": \"%s\"}}]", |
| 1896 result_id, | 1904 result_id, |
| 1897 GetFilename(kFilename).c_str()))); | 1905 GetFilename(kFilename).c_str()))); |
| 1898 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1906 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1922 ASSERT_TRUE(item); | 1930 ASSERT_TRUE(item); |
| 1923 ScopedCancellingItem canceller(item); | 1931 ScopedCancellingItem canceller(item); |
| 1924 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1932 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1925 | 1933 |
| 1926 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1934 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1927 base::StringPrintf( | 1935 base::StringPrintf( |
| 1928 "[{\"danger\": \"safe\"," | 1936 "[{\"danger\": \"safe\"," |
| 1929 " \"incognito\": false," | 1937 " \"incognito\": false," |
| 1930 " \"mime\": \"text/plain\"," | 1938 " \"mime\": \"text/plain\"," |
| 1931 " \"paused\": false," | 1939 " \"paused\": false," |
| 1940 " \"finalUrl\": \"%s\"," |
| 1932 " \"url\": \"%s\"}]", | 1941 " \"url\": \"%s\"}]", |
| 1942 download_url.c_str(), |
| 1933 download_url.c_str()))); | 1943 download_url.c_str()))); |
| 1934 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1944 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1935 base::StringPrintf( | 1945 base::StringPrintf( |
| 1936 "[{\"id\": %d," | 1946 "[{\"id\": %d," |
| 1937 " \"filename\": {" | 1947 " \"filename\": {" |
| 1938 " \"previous\": \"\"," | 1948 " \"previous\": \"\"," |
| 1939 " \"current\": \"%s\"}}]", | 1949 " \"current\": \"%s\"}}]", |
| 1940 result_id, | 1950 result_id, |
| 1941 GetFilename("data.txt").c_str()))); | 1951 GetFilename("data.txt").c_str()))); |
| 1942 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1952 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 ASSERT_TRUE(item); | 1987 ASSERT_TRUE(item); |
| 1978 ScopedCancellingItem canceller(item); | 1988 ScopedCancellingItem canceller(item); |
| 1979 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1989 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1980 | 1990 |
| 1981 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1991 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 1982 base::StringPrintf( | 1992 base::StringPrintf( |
| 1983 "[{\"danger\": \"safe\"," | 1993 "[{\"danger\": \"safe\"," |
| 1984 " \"incognito\": false," | 1994 " \"incognito\": false," |
| 1985 " \"mime\": \"text/html\"," | 1995 " \"mime\": \"text/html\"," |
| 1986 " \"paused\": false," | 1996 " \"paused\": false," |
| 1997 " \"finalUrl\": \"%s\"," |
| 1987 " \"url\": \"%s\"}]", | 1998 " \"url\": \"%s\"}]", |
| 1999 download_url.c_str(), |
| 1988 download_url.c_str()))); | 2000 download_url.c_str()))); |
| 1989 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2001 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 1990 base::StringPrintf( | 2002 base::StringPrintf( |
| 1991 "[{\"id\": %d," | 2003 "[{\"id\": %d," |
| 1992 " \"filename\": {" | 2004 " \"filename\": {" |
| 1993 " \"previous\": \"\"," | 2005 " \"previous\": \"\"," |
| 1994 " \"current\": \"%s\"}}]", | 2006 " \"current\": \"%s\"}}]", |
| 1995 result_id, | 2007 result_id, |
| 1996 GetFilename("file.txt").c_str()))); | 2008 GetFilename("file.txt").c_str()))); |
| 1997 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2009 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2028 ScopedCancellingItem canceller(item); | 2040 ScopedCancellingItem canceller(item); |
| 2029 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2041 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2030 | 2042 |
| 2031 ASSERT_TRUE(WaitForInterruption( | 2043 ASSERT_TRUE(WaitForInterruption( |
| 2032 item, | 2044 item, |
| 2033 content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, | 2045 content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, |
| 2034 base::StringPrintf("[{\"danger\": \"safe\"," | 2046 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2035 " \"incognito\": false," | 2047 " \"incognito\": false," |
| 2036 " \"mime\": \"text/html\"," | 2048 " \"mime\": \"text/html\"," |
| 2037 " \"paused\": false," | 2049 " \"paused\": false," |
| 2050 " \"finalUrl\": \"%s\"," |
| 2038 " \"url\": \"%s\"}]", | 2051 " \"url\": \"%s\"}]", |
| 2052 download_url.c_str(), |
| 2039 download_url.c_str()))); | 2053 download_url.c_str()))); |
| 2040 } | 2054 } |
| 2041 | 2055 |
| 2042 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. | 2056 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. |
| 2043 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2057 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
| 2044 DownloadExtensionTest_Download_Headers) { | 2058 DownloadExtensionTest_Download_Headers) { |
| 2045 LoadExtension("downloads_split"); | 2059 LoadExtension("downloads_split"); |
| 2046 ASSERT_TRUE(StartEmbeddedTestServer()); | 2060 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 2047 std::string download_url = | 2061 std::string download_url = |
| 2048 embedded_test_server() | 2062 embedded_test_server() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2067 ASSERT_TRUE(item); | 2081 ASSERT_TRUE(item); |
| 2068 ScopedCancellingItem canceller(item); | 2082 ScopedCancellingItem canceller(item); |
| 2069 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2083 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2070 | 2084 |
| 2071 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2085 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2072 base::StringPrintf( | 2086 base::StringPrintf( |
| 2073 "[{\"danger\": \"safe\"," | 2087 "[{\"danger\": \"safe\"," |
| 2074 " \"incognito\": false," | 2088 " \"incognito\": false," |
| 2075 " \"mime\": \"application/octet-stream\"," | 2089 " \"mime\": \"application/octet-stream\"," |
| 2076 " \"paused\": false," | 2090 " \"paused\": false," |
| 2091 " \"finalUrl\": \"%s\"," |
| 2077 " \"url\": \"%s\"}]", | 2092 " \"url\": \"%s\"}]", |
| 2093 download_url.c_str(), |
| 2078 download_url.c_str()))); | 2094 download_url.c_str()))); |
| 2079 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2095 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 2080 base::StringPrintf( | 2096 base::StringPrintf( |
| 2081 "[{\"id\": %d," | 2097 "[{\"id\": %d," |
| 2082 " \"filename\": {" | 2098 " \"filename\": {" |
| 2083 " \"previous\": \"\"," | 2099 " \"previous\": \"\"," |
| 2084 " \"current\": \"%s\"}}]", | 2100 " \"current\": \"%s\"}}]", |
| 2085 result_id, | 2101 result_id, |
| 2086 GetFilename("headers-succeed.txt").c_str()))); | 2102 GetFilename("headers-succeed.txt").c_str()))); |
| 2087 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2103 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 | 2140 |
| 2125 ASSERT_TRUE(WaitForInterruption( | 2141 ASSERT_TRUE(WaitForInterruption( |
| 2126 item, | 2142 item, |
| 2127 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2143 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
| 2128 base::StringPrintf("[{\"danger\": \"safe\"," | 2144 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2129 " \"incognito\": false," | 2145 " \"incognito\": false," |
| 2130 " \"bytesReceived\": 0.0," | 2146 " \"bytesReceived\": 0.0," |
| 2131 " \"fileSize\": 0.0," | 2147 " \"fileSize\": 0.0," |
| 2132 " \"mime\": \"\"," | 2148 " \"mime\": \"\"," |
| 2133 " \"paused\": false," | 2149 " \"paused\": false," |
| 2150 " \"finalUrl\": \"%s\"," |
| 2134 " \"url\": \"%s\"}]", | 2151 " \"url\": \"%s\"}]", |
| 2152 download_url.c_str(), |
| 2135 download_url.c_str()))); | 2153 download_url.c_str()))); |
| 2136 } | 2154 } |
| 2137 | 2155 |
| 2138 // Test that DownloadsDownloadFunction propagates the Authorization header | 2156 // Test that DownloadsDownloadFunction propagates the Authorization header |
| 2139 // correctly. | 2157 // correctly. |
| 2140 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2158 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
| 2141 DownloadExtensionTest_Download_AuthBasic) { | 2159 DownloadExtensionTest_Download_AuthBasic) { |
| 2142 LoadExtension("downloads_split"); | 2160 LoadExtension("downloads_split"); |
| 2143 ASSERT_TRUE(StartEmbeddedTestServer()); | 2161 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 2144 std::string download_url = | 2162 std::string download_url = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2163 ScopedCancellingItem canceller(item); | 2181 ScopedCancellingItem canceller(item); |
| 2164 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2182 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2165 | 2183 |
| 2166 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2184 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2167 base::StringPrintf( | 2185 base::StringPrintf( |
| 2168 "[{\"danger\": \"safe\"," | 2186 "[{\"danger\": \"safe\"," |
| 2169 " \"incognito\": false," | 2187 " \"incognito\": false," |
| 2170 " \"bytesReceived\": 0.0," | 2188 " \"bytesReceived\": 0.0," |
| 2171 " \"mime\": \"text/html\"," | 2189 " \"mime\": \"text/html\"," |
| 2172 " \"paused\": false," | 2190 " \"paused\": false," |
| 2191 " \"finalUrl\": \"%s\"," |
| 2173 " \"url\": \"%s\"}]", | 2192 " \"url\": \"%s\"}]", |
| 2193 download_url.c_str(), |
| 2174 download_url.c_str()))); | 2194 download_url.c_str()))); |
| 2175 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2195 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 2176 base::StringPrintf( | 2196 base::StringPrintf( |
| 2177 "[{\"id\": %d," | 2197 "[{\"id\": %d," |
| 2178 " \"state\": {" | 2198 " \"state\": {" |
| 2179 " \"previous\": \"in_progress\"," | 2199 " \"previous\": \"in_progress\"," |
| 2180 " \"current\": \"complete\"}}]", | 2200 " \"current\": \"complete\"}}]", |
| 2181 result_id))); | 2201 result_id))); |
| 2182 } | 2202 } |
| 2183 | 2203 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2208 ASSERT_TRUE(item); | 2228 ASSERT_TRUE(item); |
| 2209 ScopedCancellingItem canceller(item); | 2229 ScopedCancellingItem canceller(item); |
| 2210 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2230 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2211 | 2231 |
| 2212 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2232 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2213 base::StringPrintf( | 2233 base::StringPrintf( |
| 2214 "[{\"danger\": \"safe\"," | 2234 "[{\"danger\": \"safe\"," |
| 2215 " \"incognito\": false," | 2235 " \"incognito\": false," |
| 2216 " \"mime\": \"application/octet-stream\"," | 2236 " \"mime\": \"application/octet-stream\"," |
| 2217 " \"paused\": false," | 2237 " \"paused\": false," |
| 2238 " \"finalUrl\": \"%s\"," |
| 2218 " \"url\": \"%s\"}]", | 2239 " \"url\": \"%s\"}]", |
| 2240 download_url.c_str(), |
| 2219 download_url.c_str()))); | 2241 download_url.c_str()))); |
| 2220 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2242 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 2221 base::StringPrintf( | 2243 base::StringPrintf( |
| 2222 "[{\"id\": %d," | 2244 "[{\"id\": %d," |
| 2223 " \"filename\": {" | 2245 " \"filename\": {" |
| 2224 " \"previous\": \"\"," | 2246 " \"previous\": \"\"," |
| 2225 " \"current\": \"%s\"}}]", | 2247 " \"current\": \"%s\"}}]", |
| 2226 result_id, | 2248 result_id, |
| 2227 GetFilename("post-succeed.txt").c_str()))); | 2249 GetFilename("post-succeed.txt").c_str()))); |
| 2228 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2250 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2287 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2266 | 2288 |
| 2267 ASSERT_TRUE(WaitForInterruption( | 2289 ASSERT_TRUE(WaitForInterruption( |
| 2268 item, | 2290 item, |
| 2269 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2291 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
| 2270 base::StringPrintf("[{\"danger\": \"safe\"," | 2292 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2271 " \"incognito\": false," | 2293 " \"incognito\": false," |
| 2272 " \"mime\": \"\"," | 2294 " \"mime\": \"\"," |
| 2273 " \"paused\": false," | 2295 " \"paused\": false," |
| 2274 " \"id\": %d," | 2296 " \"id\": %d," |
| 2297 " \"finalUrl\": \"%s\"," |
| 2275 " \"url\": \"%s\"}]", | 2298 " \"url\": \"%s\"}]", |
| 2276 result_id, | 2299 result_id, |
| 2300 download_url.c_str(), |
| 2277 download_url.c_str()))); | 2301 download_url.c_str()))); |
| 2278 } | 2302 } |
| 2279 | 2303 |
| 2280 // Test that downloadPostSuccess would fail if the resource requires the POST | 2304 // Test that downloadPostSuccess would fail if the resource requires the POST |
| 2281 // method, and chrome fails to propagate the |body| parameter back to the | 2305 // method, and chrome fails to propagate the |body| parameter back to the |
| 2282 // server. This tests both that testserver.py does not succeed when it should | 2306 // server. This tests both that testserver.py does not succeed when it should |
| 2283 // fail, and this tests how the downloads extension api exposes the failure to | 2307 // fail, and this tests how the downloads extension api exposes the failure to |
| 2284 // extensions. | 2308 // extensions. |
| 2285 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2309 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
| 2286 DownloadExtensionTest_Download_Post_NoBody) { | 2310 DownloadExtensionTest_Download_Post_NoBody) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2308 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2332 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2309 | 2333 |
| 2310 ASSERT_TRUE(WaitForInterruption( | 2334 ASSERT_TRUE(WaitForInterruption( |
| 2311 item, | 2335 item, |
| 2312 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2336 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
| 2313 base::StringPrintf("[{\"danger\": \"safe\"," | 2337 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2314 " \"incognito\": false," | 2338 " \"incognito\": false," |
| 2315 " \"mime\": \"\"," | 2339 " \"mime\": \"\"," |
| 2316 " \"paused\": false," | 2340 " \"paused\": false," |
| 2317 " \"id\": %d," | 2341 " \"id\": %d," |
| 2342 " \"finalUrl\": \"%s\"," |
| 2318 " \"url\": \"%s\"}]", | 2343 " \"url\": \"%s\"}]", |
| 2319 result_id, | 2344 result_id, |
| 2345 download_url.c_str(), |
| 2320 download_url.c_str()))); | 2346 download_url.c_str()))); |
| 2321 } | 2347 } |
| 2322 | 2348 |
| 2323 // Test that cancel()ing an in-progress download causes its state to transition | 2349 // Test that cancel()ing an in-progress download causes its state to transition |
| 2324 // to interrupted, and test that that state transition is detectable by an | 2350 // to interrupted, and test that that state transition is detectable by an |
| 2325 // onChanged event listener. TODO(benjhayden): Test other sources of | 2351 // onChanged event listener. TODO(benjhayden): Test other sources of |
| 2326 // interruptions such as server death. | 2352 // interruptions such as server death. |
| 2327 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2353 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
| 2328 DownloadExtensionTest_Download_Cancel) { | 2354 DownloadExtensionTest_Download_Cancel) { |
| 2329 LoadExtension("downloads_split"); | 2355 LoadExtension("downloads_split"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2344 ScopedCancellingItem canceller(item); | 2370 ScopedCancellingItem canceller(item); |
| 2345 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2371 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2346 | 2372 |
| 2347 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2373 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2348 base::StringPrintf( | 2374 base::StringPrintf( |
| 2349 "[{\"danger\": \"safe\"," | 2375 "[{\"danger\": \"safe\"," |
| 2350 " \"incognito\": false," | 2376 " \"incognito\": false," |
| 2351 " \"mime\": \"application/octet-stream\"," | 2377 " \"mime\": \"application/octet-stream\"," |
| 2352 " \"paused\": false," | 2378 " \"paused\": false," |
| 2353 " \"id\": %d," | 2379 " \"id\": %d," |
| 2380 " \"finalUrl\": \"%s\"," |
| 2354 " \"url\": \"%s\"}]", | 2381 " \"url\": \"%s\"}]", |
| 2355 result_id, | 2382 result_id, |
| 2383 download_url.c_str(), |
| 2356 download_url.c_str()))); | 2384 download_url.c_str()))); |
| 2357 item->Cancel(true); | 2385 item->Cancel(true); |
| 2358 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2386 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 2359 base::StringPrintf( | 2387 base::StringPrintf( |
| 2360 "[{\"id\": %d," | 2388 "[{\"id\": %d," |
| 2361 " \"error\": {\"current\":\"USER_CANCELED\"}," | 2389 " \"error\": {\"current\":\"USER_CANCELED\"}," |
| 2362 " \"state\": {" | 2390 " \"state\": {" |
| 2363 " \"previous\": \"in_progress\"," | 2391 " \"previous\": \"in_progress\"," |
| 2364 " \"current\": \"interrupted\"}}]", | 2392 " \"current\": \"interrupted\"}}]", |
| 2365 result_id))); | 2393 result_id))); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 ASSERT_TRUE(item); | 2433 ASSERT_TRUE(item); |
| 2406 ScopedCancellingItem canceller(item); | 2434 ScopedCancellingItem canceller(item); |
| 2407 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2435 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2408 | 2436 |
| 2409 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2437 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2410 base::StringPrintf( | 2438 base::StringPrintf( |
| 2411 "[{\"danger\": \"safe\"," | 2439 "[{\"danger\": \"safe\"," |
| 2412 " \"incognito\": false," | 2440 " \"incognito\": false," |
| 2413 " \"mime\": \"text/plain\"," | 2441 " \"mime\": \"text/plain\"," |
| 2414 " \"paused\": false," | 2442 " \"paused\": false," |
| 2443 " \"finalUrl\": \"%s\"," |
| 2415 " \"url\": \"%s\"}]", | 2444 " \"url\": \"%s\"}]", |
| 2445 download_url.c_str(), |
| 2416 download_url.c_str()))); | 2446 download_url.c_str()))); |
| 2417 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2447 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| 2418 base::StringPrintf( | 2448 base::StringPrintf( |
| 2419 "[{\"id\": %d," | 2449 "[{\"id\": %d," |
| 2420 " \"filename\": {" | 2450 " \"filename\": {" |
| 2421 " \"previous\": \"\"," | 2451 " \"previous\": \"\"," |
| 2422 " \"current\": \"%s\"}}]", | 2452 " \"current\": \"%s\"}}]", |
| 2423 result_id, | 2453 result_id, |
| 2424 GetFilename("on_record.txt").c_str()))); | 2454 GetFilename("on_record.txt").c_str()))); |
| 2425 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2455 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2455 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2485 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2456 | 2486 |
| 2457 // Wait for the onCreated and onDeterminingFilename events. | 2487 // Wait for the onCreated and onDeterminingFilename events. |
| 2458 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2488 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2459 base::StringPrintf( | 2489 base::StringPrintf( |
| 2460 "[{\"danger\": \"safe\"," | 2490 "[{\"danger\": \"safe\"," |
| 2461 " \"incognito\": false," | 2491 " \"incognito\": false," |
| 2462 " \"id\": %d," | 2492 " \"id\": %d," |
| 2463 " \"mime\": \"text/plain\"," | 2493 " \"mime\": \"text/plain\"," |
| 2464 " \"paused\": false," | 2494 " \"paused\": false," |
| 2495 " \"finalUrl\": \"%s\"," |
| 2465 " \"url\": \"%s\"}]", | 2496 " \"url\": \"%s\"}]", |
| 2466 result_id, | 2497 result_id, |
| 2498 download_url.c_str(), |
| 2467 download_url.c_str()))); | 2499 download_url.c_str()))); |
| 2468 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2500 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2469 base::StringPrintf( | 2501 base::StringPrintf( |
| 2470 "[{\"id\": %d," | 2502 "[{\"id\": %d," |
| 2471 " \"filename\":\"slow.txt\"}]", | 2503 " \"filename\":\"slow.txt\"}]", |
| 2472 result_id))); | 2504 result_id))); |
| 2473 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2505 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2474 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2506 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2475 | 2507 |
| 2476 // Respond to the onDeterminingFilename. | 2508 // Respond to the onDeterminingFilename. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 ScopedCancellingItem canceller(item); | 2559 ScopedCancellingItem canceller(item); |
| 2528 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2560 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2529 | 2561 |
| 2530 // Wait for the onCreated and onDeterminingFilename events. | 2562 // Wait for the onCreated and onDeterminingFilename events. |
| 2531 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2563 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2532 base::StringPrintf("[{\"danger\": \"safe\"," | 2564 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2533 " \"incognito\": false," | 2565 " \"incognito\": false," |
| 2534 " \"id\": %d," | 2566 " \"id\": %d," |
| 2535 " \"mime\": \"text/plain\"," | 2567 " \"mime\": \"text/plain\"," |
| 2536 " \"paused\": false," | 2568 " \"paused\": false," |
| 2569 " \"finalUrl\": \"%s\"," |
| 2537 " \"url\": \"%s\"}]", | 2570 " \"url\": \"%s\"}]", |
| 2538 result_id, | 2571 result_id, |
| 2572 download_url.c_str(), |
| 2539 download_url.c_str()))); | 2573 download_url.c_str()))); |
| 2540 ASSERT_TRUE(WaitFor( | 2574 ASSERT_TRUE(WaitFor( |
| 2541 downloads::OnDeterminingFilename::kEventName, | 2575 downloads::OnDeterminingFilename::kEventName, |
| 2542 base::StringPrintf("[{\"id\": %d," | 2576 base::StringPrintf("[{\"id\": %d," |
| 2543 " \"filename\":\"slow.txt\"}]", | 2577 " \"filename\":\"slow.txt\"}]", |
| 2544 result_id))); | 2578 result_id))); |
| 2545 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2579 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2546 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2580 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2547 | 2581 |
| 2548 // Do not respond to the onDeterminingFilename. | 2582 // Do not respond to the onDeterminingFilename. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 ScopedCancellingItem canceller(item); | 2617 ScopedCancellingItem canceller(item); |
| 2584 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2618 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2585 | 2619 |
| 2586 // Wait for the onCreated and onDeterminingFilename events. | 2620 // Wait for the onCreated and onDeterminingFilename events. |
| 2587 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2621 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2588 base::StringPrintf("[{\"danger\": \"safe\"," | 2622 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2589 " \"incognito\": false," | 2623 " \"incognito\": false," |
| 2590 " \"id\": %d," | 2624 " \"id\": %d," |
| 2591 " \"mime\": \"text/plain\"," | 2625 " \"mime\": \"text/plain\"," |
| 2592 " \"paused\": false," | 2626 " \"paused\": false," |
| 2627 " \"finalUrl\": \"%s\"," |
| 2593 " \"url\": \"%s\"}]", | 2628 " \"url\": \"%s\"}]", |
| 2594 result_id, | 2629 result_id, |
| 2630 download_url.c_str(), |
| 2595 download_url.c_str()))); | 2631 download_url.c_str()))); |
| 2596 ASSERT_TRUE(WaitFor( | 2632 ASSERT_TRUE(WaitFor( |
| 2597 downloads::OnDeterminingFilename::kEventName, | 2633 downloads::OnDeterminingFilename::kEventName, |
| 2598 base::StringPrintf("[{\"id\": %d," | 2634 base::StringPrintf("[{\"id\": %d," |
| 2599 " \"filename\":\"slow.txt\"}]", | 2635 " \"filename\":\"slow.txt\"}]", |
| 2600 result_id))); | 2636 result_id))); |
| 2601 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2637 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2602 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2638 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2603 | 2639 |
| 2604 // Respond to the onDeterminingFilename. | 2640 // Respond to the onDeterminingFilename. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2662 ScopedCancellingItem canceller(item); | 2698 ScopedCancellingItem canceller(item); |
| 2663 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2699 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2664 | 2700 |
| 2665 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2701 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2666 base::StringPrintf( | 2702 base::StringPrintf( |
| 2667 "[{\"danger\": \"safe\"," | 2703 "[{\"danger\": \"safe\"," |
| 2668 " \"incognito\": false," | 2704 " \"incognito\": false," |
| 2669 " \"id\": %d," | 2705 " \"id\": %d," |
| 2670 " \"mime\": \"text/plain\"," | 2706 " \"mime\": \"text/plain\"," |
| 2671 " \"paused\": false," | 2707 " \"paused\": false," |
| 2708 " \"finalUrl\": \"%s\"," |
| 2672 " \"url\": \"%s\"}]", | 2709 " \"url\": \"%s\"}]", |
| 2673 result_id, | 2710 result_id, |
| 2711 download_url.c_str(), |
| 2674 download_url.c_str()))); | 2712 download_url.c_str()))); |
| 2675 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2713 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2676 base::StringPrintf( | 2714 base::StringPrintf( |
| 2677 "[{\"id\": %d," | 2715 "[{\"id\": %d," |
| 2678 " \"filename\":\"slow.txt\"}]", | 2716 " \"filename\":\"slow.txt\"}]", |
| 2679 result_id))); | 2717 result_id))); |
| 2680 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2718 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2681 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2719 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2682 | 2720 |
| 2683 // Respond to the onDeterminingFilename. | 2721 // Respond to the onDeterminingFilename. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2740 ScopedCancellingItem canceller(item); | 2778 ScopedCancellingItem canceller(item); |
| 2741 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2779 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2742 | 2780 |
| 2743 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2781 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2744 base::StringPrintf( | 2782 base::StringPrintf( |
| 2745 "[{\"danger\": \"safe\"," | 2783 "[{\"danger\": \"safe\"," |
| 2746 " \"incognito\": false," | 2784 " \"incognito\": false," |
| 2747 " \"id\": %d," | 2785 " \"id\": %d," |
| 2748 " \"mime\": \"text/plain\"," | 2786 " \"mime\": \"text/plain\"," |
| 2749 " \"paused\": false," | 2787 " \"paused\": false," |
| 2788 " \"finalUrl\": \"%s\"," |
| 2750 " \"url\": \"%s\"}]", | 2789 " \"url\": \"%s\"}]", |
| 2751 result_id, | 2790 result_id, |
| 2791 download_url.c_str(), |
| 2752 download_url.c_str()))); | 2792 download_url.c_str()))); |
| 2753 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2793 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2754 base::StringPrintf( | 2794 base::StringPrintf( |
| 2755 "[{\"id\": %d," | 2795 "[{\"id\": %d," |
| 2756 " \"filename\":\"slow.txt\"}]", | 2796 " \"filename\":\"slow.txt\"}]", |
| 2757 result_id))); | 2797 result_id))); |
| 2758 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2798 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2759 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2799 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2760 | 2800 |
| 2761 // Respond to the onDeterminingFilename. | 2801 // Respond to the onDeterminingFilename. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2806 ScopedCancellingItem canceller(item); | 2846 ScopedCancellingItem canceller(item); |
| 2807 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2847 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2808 | 2848 |
| 2809 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2849 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2810 base::StringPrintf( | 2850 base::StringPrintf( |
| 2811 "[{\"danger\": \"safe\"," | 2851 "[{\"danger\": \"safe\"," |
| 2812 " \"incognito\": false," | 2852 " \"incognito\": false," |
| 2813 " \"id\": %d," | 2853 " \"id\": %d," |
| 2814 " \"mime\": \"text/plain\"," | 2854 " \"mime\": \"text/plain\"," |
| 2815 " \"paused\": false," | 2855 " \"paused\": false," |
| 2856 " \"finalUrl\": \"%s\"," |
| 2816 " \"url\": \"%s\"}]", | 2857 " \"url\": \"%s\"}]", |
| 2817 result_id, | 2858 result_id, |
| 2859 download_url.c_str(), |
| 2818 download_url.c_str()))); | 2860 download_url.c_str()))); |
| 2819 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2861 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2820 base::StringPrintf( | 2862 base::StringPrintf( |
| 2821 "[{\"id\": %d," | 2863 "[{\"id\": %d," |
| 2822 " \"filename\":\"slow.txt\"}]", | 2864 " \"filename\":\"slow.txt\"}]", |
| 2823 result_id))); | 2865 result_id))); |
| 2824 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2866 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2825 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2867 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2826 | 2868 |
| 2827 // Respond to the onDeterminingFilename. | 2869 // Respond to the onDeterminingFilename. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 ScopedCancellingItem canceller(item); | 2914 ScopedCancellingItem canceller(item); |
| 2873 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2915 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2874 | 2916 |
| 2875 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2917 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2876 base::StringPrintf( | 2918 base::StringPrintf( |
| 2877 "[{\"danger\": \"safe\"," | 2919 "[{\"danger\": \"safe\"," |
| 2878 " \"incognito\": false," | 2920 " \"incognito\": false," |
| 2879 " \"id\": %d," | 2921 " \"id\": %d," |
| 2880 " \"mime\": \"text/plain\"," | 2922 " \"mime\": \"text/plain\"," |
| 2881 " \"paused\": false," | 2923 " \"paused\": false," |
| 2924 " \"finalUrl\": \"%s\"," |
| 2882 " \"url\": \"%s\"}]", | 2925 " \"url\": \"%s\"}]", |
| 2883 result_id, | 2926 result_id, |
| 2927 download_url.c_str(), |
| 2884 download_url.c_str()))); | 2928 download_url.c_str()))); |
| 2885 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2929 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2886 base::StringPrintf( | 2930 base::StringPrintf( |
| 2887 "[{\"id\": %d," | 2931 "[{\"id\": %d," |
| 2888 " \"filename\":\"slow.txt\"}]", | 2932 " \"filename\":\"slow.txt\"}]", |
| 2889 result_id))); | 2933 result_id))); |
| 2890 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2934 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2891 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2935 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2892 | 2936 |
| 2893 // Respond to the onDeterminingFilename. | 2937 // Respond to the onDeterminingFilename. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 ScopedCancellingItem canceller(item); | 2989 ScopedCancellingItem canceller(item); |
| 2946 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2990 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2947 | 2991 |
| 2948 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2992 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 2949 base::StringPrintf( | 2993 base::StringPrintf( |
| 2950 "[{\"danger\": \"safe\"," | 2994 "[{\"danger\": \"safe\"," |
| 2951 " \"incognito\": false," | 2995 " \"incognito\": false," |
| 2952 " \"id\": %d," | 2996 " \"id\": %d," |
| 2953 " \"mime\": \"text/plain\"," | 2997 " \"mime\": \"text/plain\"," |
| 2954 " \"paused\": false," | 2998 " \"paused\": false," |
| 2999 " \"finalUrl\": \"%s\"," |
| 2955 " \"url\": \"%s\"}]", | 3000 " \"url\": \"%s\"}]", |
| 2956 result_id, | 3001 result_id, |
| 3002 download_url.c_str(), |
| 2957 download_url.c_str()))); | 3003 download_url.c_str()))); |
| 2958 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3004 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 2959 base::StringPrintf( | 3005 base::StringPrintf( |
| 2960 "[{\"id\": %d," | 3006 "[{\"id\": %d," |
| 2961 " \"filename\":\"slow.txt\"}]", | 3007 " \"filename\":\"slow.txt\"}]", |
| 2962 result_id))); | 3008 result_id))); |
| 2963 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3009 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 2964 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3010 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 2965 | 3011 |
| 2966 // Respond to the onDeterminingFilename. | 3012 // Respond to the onDeterminingFilename. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3011 ScopedCancellingItem canceller(item); | 3057 ScopedCancellingItem canceller(item); |
| 3012 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3058 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3013 | 3059 |
| 3014 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3060 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3015 base::StringPrintf( | 3061 base::StringPrintf( |
| 3016 "[{\"danger\": \"safe\"," | 3062 "[{\"danger\": \"safe\"," |
| 3017 " \"incognito\": false," | 3063 " \"incognito\": false," |
| 3018 " \"id\": %d," | 3064 " \"id\": %d," |
| 3019 " \"mime\": \"text/plain\"," | 3065 " \"mime\": \"text/plain\"," |
| 3020 " \"paused\": false," | 3066 " \"paused\": false," |
| 3067 " \"finalUrl\": \"%s\"," |
| 3021 " \"url\": \"%s\"}]", | 3068 " \"url\": \"%s\"}]", |
| 3022 result_id, | 3069 result_id, |
| 3070 download_url.c_str(), |
| 3023 download_url.c_str()))); | 3071 download_url.c_str()))); |
| 3024 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3072 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3025 base::StringPrintf( | 3073 base::StringPrintf( |
| 3026 "[{\"id\": %d," | 3074 "[{\"id\": %d," |
| 3027 " \"filename\":\"slow.txt\"}]", | 3075 " \"filename\":\"slow.txt\"}]", |
| 3028 result_id))); | 3076 result_id))); |
| 3029 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3077 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3030 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3078 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3031 | 3079 |
| 3032 // Respond to the onDeterminingFilename. | 3080 // Respond to the onDeterminingFilename. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 ScopedCancellingItem canceller(item); | 3125 ScopedCancellingItem canceller(item); |
| 3078 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3126 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3079 | 3127 |
| 3080 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3128 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3081 base::StringPrintf( | 3129 base::StringPrintf( |
| 3082 "[{\"danger\": \"safe\"," | 3130 "[{\"danger\": \"safe\"," |
| 3083 " \"incognito\": false," | 3131 " \"incognito\": false," |
| 3084 " \"id\": %d," | 3132 " \"id\": %d," |
| 3085 " \"mime\": \"text/plain\"," | 3133 " \"mime\": \"text/plain\"," |
| 3086 " \"paused\": false," | 3134 " \"paused\": false," |
| 3135 " \"finalUrl\": \"%s\"," |
| 3087 " \"url\": \"%s\"}]", | 3136 " \"url\": \"%s\"}]", |
| 3088 result_id, | 3137 result_id, |
| 3138 download_url.c_str(), |
| 3089 download_url.c_str()))); | 3139 download_url.c_str()))); |
| 3090 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3140 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3091 base::StringPrintf( | 3141 base::StringPrintf( |
| 3092 "[{\"id\": %d," | 3142 "[{\"id\": %d," |
| 3093 " \"filename\":\"slow.txt\"}]", | 3143 " \"filename\":\"slow.txt\"}]", |
| 3094 result_id))); | 3144 result_id))); |
| 3095 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3145 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3096 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3146 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3097 | 3147 |
| 3098 // Respond to the onDeterminingFilename. | 3148 // Respond to the onDeterminingFilename. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3143 ScopedCancellingItem canceller(item); | 3193 ScopedCancellingItem canceller(item); |
| 3144 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3194 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3145 | 3195 |
| 3146 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3196 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3147 base::StringPrintf( | 3197 base::StringPrintf( |
| 3148 "[{\"danger\": \"safe\"," | 3198 "[{\"danger\": \"safe\"," |
| 3149 " \"incognito\": false," | 3199 " \"incognito\": false," |
| 3150 " \"id\": %d," | 3200 " \"id\": %d," |
| 3151 " \"mime\": \"text/plain\"," | 3201 " \"mime\": \"text/plain\"," |
| 3152 " \"paused\": false," | 3202 " \"paused\": false," |
| 3203 " \"finalUrl\": \"%s\"," |
| 3153 " \"url\": \"%s\"}]", | 3204 " \"url\": \"%s\"}]", |
| 3154 result_id, | 3205 result_id, |
| 3206 download_url.c_str(), |
| 3155 download_url.c_str()))); | 3207 download_url.c_str()))); |
| 3156 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3208 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3157 base::StringPrintf( | 3209 base::StringPrintf( |
| 3158 "[{\"id\": %d," | 3210 "[{\"id\": %d," |
| 3159 " \"filename\":\"slow.txt\"}]", | 3211 " \"filename\":\"slow.txt\"}]", |
| 3160 result_id))); | 3212 result_id))); |
| 3161 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3213 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3162 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3214 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3163 | 3215 |
| 3164 // Respond to the onDeterminingFilename. Absolute paths should be rejected. | 3216 // Respond to the onDeterminingFilename. Absolute paths should be rejected. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 ScopedCancellingItem canceller(item); | 3262 ScopedCancellingItem canceller(item); |
| 3211 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3263 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3212 | 3264 |
| 3213 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3265 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3214 base::StringPrintf( | 3266 base::StringPrintf( |
| 3215 "[{\"danger\": \"safe\"," | 3267 "[{\"danger\": \"safe\"," |
| 3216 " \"incognito\": false," | 3268 " \"incognito\": false," |
| 3217 " \"id\": %d," | 3269 " \"id\": %d," |
| 3218 " \"mime\": \"text/plain\"," | 3270 " \"mime\": \"text/plain\"," |
| 3219 " \"paused\": false," | 3271 " \"paused\": false," |
| 3272 " \"finalUrl\": \"%s\"," |
| 3220 " \"url\": \"%s\"}]", | 3273 " \"url\": \"%s\"}]", |
| 3221 result_id, | 3274 result_id, |
| 3275 download_url.c_str(), |
| 3222 download_url.c_str()))); | 3276 download_url.c_str()))); |
| 3223 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3277 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3224 base::StringPrintf( | 3278 base::StringPrintf( |
| 3225 "[{\"id\": %d," | 3279 "[{\"id\": %d," |
| 3226 " \"filename\":\"slow.txt\"}]", | 3280 " \"filename\":\"slow.txt\"}]", |
| 3227 result_id))); | 3281 result_id))); |
| 3228 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3282 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3229 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3283 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3230 | 3284 |
| 3231 // Respond to the onDeterminingFilename. Empty basenames should be rejected. | 3285 // Respond to the onDeterminingFilename. Empty basenames should be rejected. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 ASSERT_TRUE(item); | 3331 ASSERT_TRUE(item); |
| 3278 ScopedCancellingItem canceller(item); | 3332 ScopedCancellingItem canceller(item); |
| 3279 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3333 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3280 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3334 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3281 base::StringPrintf( | 3335 base::StringPrintf( |
| 3282 "[{\"danger\": \"safe\"," | 3336 "[{\"danger\": \"safe\"," |
| 3283 " \"incognito\": false," | 3337 " \"incognito\": false," |
| 3284 " \"id\": %d," | 3338 " \"id\": %d," |
| 3285 " \"mime\": \"text/plain\"," | 3339 " \"mime\": \"text/plain\"," |
| 3286 " \"paused\": false," | 3340 " \"paused\": false," |
| 3341 " \"finalUrl\": \"%s\"," |
| 3287 " \"url\": \"%s\"}]", | 3342 " \"url\": \"%s\"}]", |
| 3288 result_id, | 3343 result_id, |
| 3344 download_url.c_str(), |
| 3289 download_url.c_str()))); | 3345 download_url.c_str()))); |
| 3290 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3346 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3291 base::StringPrintf( | 3347 base::StringPrintf( |
| 3292 "[{\"id\": %d," | 3348 "[{\"id\": %d," |
| 3293 " \"filename\":\"slow.txt\"}]", | 3349 " \"filename\":\"slow.txt\"}]", |
| 3294 result_id))); | 3350 result_id))); |
| 3295 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3351 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3296 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3352 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3297 | 3353 |
| 3298 // Respond to the onDeterminingFilename. | 3354 // Respond to the onDeterminingFilename. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3334 ScopedCancellingItem canceller2(item); | 3390 ScopedCancellingItem canceller2(item); |
| 3335 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3391 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3336 | 3392 |
| 3337 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3393 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3338 base::StringPrintf( | 3394 base::StringPrintf( |
| 3339 "[{\"danger\": \"safe\"," | 3395 "[{\"danger\": \"safe\"," |
| 3340 " \"incognito\": false," | 3396 " \"incognito\": false," |
| 3341 " \"id\": %d," | 3397 " \"id\": %d," |
| 3342 " \"mime\": \"text/plain\"," | 3398 " \"mime\": \"text/plain\"," |
| 3343 " \"paused\": false," | 3399 " \"paused\": false," |
| 3400 " \"finalUrl\": \"%s\"," |
| 3344 " \"url\": \"%s\"}]", | 3401 " \"url\": \"%s\"}]", |
| 3345 result_id, | 3402 result_id, |
| 3403 download_url.c_str(), |
| 3346 download_url.c_str()))); | 3404 download_url.c_str()))); |
| 3347 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3405 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3348 base::StringPrintf( | 3406 base::StringPrintf( |
| 3349 "[{\"id\": %d," | 3407 "[{\"id\": %d," |
| 3350 " \"filename\":\"slow.txt\"}]", | 3408 " \"filename\":\"slow.txt\"}]", |
| 3351 result_id))); | 3409 result_id))); |
| 3352 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3410 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3353 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3411 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3354 | 3412 |
| 3355 // Respond to the onDeterminingFilename. | 3413 // Respond to the onDeterminingFilename. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3403 ASSERT_TRUE(item); | 3461 ASSERT_TRUE(item); |
| 3404 ScopedCancellingItem canceller(item); | 3462 ScopedCancellingItem canceller(item); |
| 3405 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3463 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3406 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3464 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3407 base::StringPrintf( | 3465 base::StringPrintf( |
| 3408 "[{\"danger\": \"safe\"," | 3466 "[{\"danger\": \"safe\"," |
| 3409 " \"incognito\": false," | 3467 " \"incognito\": false," |
| 3410 " \"id\": %d," | 3468 " \"id\": %d," |
| 3411 " \"mime\": \"text/plain\"," | 3469 " \"mime\": \"text/plain\"," |
| 3412 " \"paused\": false," | 3470 " \"paused\": false," |
| 3471 " \"finalUrl\": \"%s\"," |
| 3413 " \"url\": \"%s\"}]", | 3472 " \"url\": \"%s\"}]", |
| 3414 result_id, | 3473 result_id, |
| 3474 download_url.c_str(), |
| 3415 download_url.c_str()))); | 3475 download_url.c_str()))); |
| 3416 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3476 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3417 base::StringPrintf( | 3477 base::StringPrintf( |
| 3418 "[{\"id\": %d," | 3478 "[{\"id\": %d," |
| 3419 " \"filename\":\"slow.txt\"}]", | 3479 " \"filename\":\"slow.txt\"}]", |
| 3420 result_id))); | 3480 result_id))); |
| 3421 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3481 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3422 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3482 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3423 | 3483 |
| 3424 // Respond to the onDeterminingFilename. | 3484 // Respond to the onDeterminingFilename. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3460 ScopedCancellingItem canceller2(item); | 3520 ScopedCancellingItem canceller2(item); |
| 3461 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3521 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3462 | 3522 |
| 3463 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3523 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3464 base::StringPrintf( | 3524 base::StringPrintf( |
| 3465 "[{\"danger\": \"safe\"," | 3525 "[{\"danger\": \"safe\"," |
| 3466 " \"incognito\": false," | 3526 " \"incognito\": false," |
| 3467 " \"id\": %d," | 3527 " \"id\": %d," |
| 3468 " \"mime\": \"text/plain\"," | 3528 " \"mime\": \"text/plain\"," |
| 3469 " \"paused\": false," | 3529 " \"paused\": false," |
| 3530 " \"finalUrl\": \"%s\"," |
| 3470 " \"url\": \"%s\"}]", | 3531 " \"url\": \"%s\"}]", |
| 3471 result_id, | 3532 result_id, |
| 3533 download_url.c_str(), |
| 3472 download_url.c_str()))); | 3534 download_url.c_str()))); |
| 3473 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3535 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3474 base::StringPrintf( | 3536 base::StringPrintf( |
| 3475 "[{\"id\": %d," | 3537 "[{\"id\": %d," |
| 3476 " \"filename\":\"slow.txt\"}]", | 3538 " \"filename\":\"slow.txt\"}]", |
| 3477 result_id))); | 3539 result_id))); |
| 3478 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3540 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3479 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3541 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3480 | 3542 |
| 3481 // Respond to the onDeterminingFilename. | 3543 // Respond to the onDeterminingFilename. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3540 ScopedCancellingItem canceller(item); | 3602 ScopedCancellingItem canceller(item); |
| 3541 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3603 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3542 | 3604 |
| 3543 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3605 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3544 base::StringPrintf( | 3606 base::StringPrintf( |
| 3545 "[{\"danger\": \"safe\"," | 3607 "[{\"danger\": \"safe\"," |
| 3546 " \"incognito\": false," | 3608 " \"incognito\": false," |
| 3547 " \"id\": %d," | 3609 " \"id\": %d," |
| 3548 " \"mime\": \"text/plain\"," | 3610 " \"mime\": \"text/plain\"," |
| 3549 " \"paused\": false," | 3611 " \"paused\": false," |
| 3612 " \"finalUrl\": \"%s\"," |
| 3550 " \"url\": \"%s\"}]", | 3613 " \"url\": \"%s\"}]", |
| 3551 result_id, | 3614 result_id, |
| 3615 download_url.c_str(), |
| 3552 download_url.c_str()))); | 3616 download_url.c_str()))); |
| 3553 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3617 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3554 base::StringPrintf( | 3618 base::StringPrintf( |
| 3555 "[{\"id\": %d," | 3619 "[{\"id\": %d," |
| 3556 " \"filename\":\"slow.txt\"}]", | 3620 " \"filename\":\"slow.txt\"}]", |
| 3557 result_id))); | 3621 result_id))); |
| 3558 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3622 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3559 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3623 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3560 | 3624 |
| 3561 // Remove a determiner while waiting for it. | 3625 // Remove a determiner while waiting for it. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3661 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3598 | 3662 |
| 3599 // Wait for the onCreated and onDeterminingFilename events. | 3663 // Wait for the onCreated and onDeterminingFilename events. |
| 3600 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3664 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3601 base::StringPrintf( | 3665 base::StringPrintf( |
| 3602 "[{\"danger\": \"safe\"," | 3666 "[{\"danger\": \"safe\"," |
| 3603 " \"incognito\": false," | 3667 " \"incognito\": false," |
| 3604 " \"id\": %d," | 3668 " \"id\": %d," |
| 3605 " \"mime\": \"text/plain\"," | 3669 " \"mime\": \"text/plain\"," |
| 3606 " \"paused\": false," | 3670 " \"paused\": false," |
| 3671 " \"finalUrl\": \"%s\"," |
| 3607 " \"url\": \"%s\"}]", | 3672 " \"url\": \"%s\"}]", |
| 3608 result_id, | 3673 result_id, |
| 3674 download_url.c_str(), |
| 3609 download_url.c_str()))); | 3675 download_url.c_str()))); |
| 3610 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3676 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3611 base::StringPrintf( | 3677 base::StringPrintf( |
| 3612 "[{\"id\": %d," | 3678 "[{\"id\": %d," |
| 3613 " \"incognito\": false," | 3679 " \"incognito\": false," |
| 3614 " \"filename\":\"slow.txt\"}]", | 3680 " \"filename\":\"slow.txt\"}]", |
| 3615 result_id))); | 3681 result_id))); |
| 3616 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3682 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3617 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3683 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3618 | 3684 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 ScopedCancellingItem canceller2(item); | 3724 ScopedCancellingItem canceller2(item); |
| 3659 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3725 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3660 | 3726 |
| 3661 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3727 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3662 base::StringPrintf( | 3728 base::StringPrintf( |
| 3663 "[{\"danger\": \"safe\"," | 3729 "[{\"danger\": \"safe\"," |
| 3664 " \"incognito\": true," | 3730 " \"incognito\": true," |
| 3665 " \"id\": %d," | 3731 " \"id\": %d," |
| 3666 " \"mime\": \"text/plain\"," | 3732 " \"mime\": \"text/plain\"," |
| 3667 " \"paused\": false," | 3733 " \"paused\": false," |
| 3734 " \"finalUrl\": \"%s\"," |
| 3668 " \"url\": \"%s\"}]", | 3735 " \"url\": \"%s\"}]", |
| 3669 result_id, | 3736 result_id, |
| 3737 download_url.c_str(), |
| 3670 download_url.c_str()))); | 3738 download_url.c_str()))); |
| 3671 // On-Record renderers should not see events for off-record items. | 3739 // On-Record renderers should not see events for off-record items. |
| 3672 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3740 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3673 base::StringPrintf( | 3741 base::StringPrintf( |
| 3674 "[{\"id\": %d," | 3742 "[{\"id\": %d," |
| 3675 " \"incognito\": true," | 3743 " \"incognito\": true," |
| 3676 " \"filename\":\"slow.txt\"}]", | 3744 " \"filename\":\"slow.txt\"}]", |
| 3677 result_id))); | 3745 result_id))); |
| 3678 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3746 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3679 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3747 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3736 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3804 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3737 | 3805 |
| 3738 // Wait for the onCreated and onDeterminingFilename events. | 3806 // Wait for the onCreated and onDeterminingFilename events. |
| 3739 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3807 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3740 base::StringPrintf( | 3808 base::StringPrintf( |
| 3741 "[{\"danger\": \"safe\"," | 3809 "[{\"danger\": \"safe\"," |
| 3742 " \"incognito\": false," | 3810 " \"incognito\": false," |
| 3743 " \"id\": %d," | 3811 " \"id\": %d," |
| 3744 " \"mime\": \"text/plain\"," | 3812 " \"mime\": \"text/plain\"," |
| 3745 " \"paused\": false," | 3813 " \"paused\": false," |
| 3814 " \"finalUrl\": \"%s\"," |
| 3746 " \"url\": \"%s\"}]", | 3815 " \"url\": \"%s\"}]", |
| 3747 result_id, | 3816 result_id, |
| 3817 download_url.c_str(), |
| 3748 download_url.c_str()))); | 3818 download_url.c_str()))); |
| 3749 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3819 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3750 base::StringPrintf( | 3820 base::StringPrintf( |
| 3751 "[{\"id\": %d," | 3821 "[{\"id\": %d," |
| 3752 " \"incognito\": false," | 3822 " \"incognito\": false," |
| 3753 " \"filename\":\"slow.txt\"}]", | 3823 " \"filename\":\"slow.txt\"}]", |
| 3754 result_id))); | 3824 result_id))); |
| 3755 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3825 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3756 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3826 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3757 | 3827 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3797 ScopedCancellingItem canceller2(item); | 3867 ScopedCancellingItem canceller2(item); |
| 3798 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3868 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 3799 | 3869 |
| 3800 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3870 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
| 3801 base::StringPrintf( | 3871 base::StringPrintf( |
| 3802 "[{\"danger\": \"safe\"," | 3872 "[{\"danger\": \"safe\"," |
| 3803 " \"incognito\": true," | 3873 " \"incognito\": true," |
| 3804 " \"id\": %d," | 3874 " \"id\": %d," |
| 3805 " \"mime\": \"text/plain\"," | 3875 " \"mime\": \"text/plain\"," |
| 3806 " \"paused\": false," | 3876 " \"paused\": false," |
| 3877 " \"finalUrl\": \"%s\"," |
| 3807 " \"url\": \"%s\"}]", | 3878 " \"url\": \"%s\"}]", |
| 3808 result_id, | 3879 result_id, |
| 3880 download_url.c_str(), |
| 3809 download_url.c_str()))); | 3881 download_url.c_str()))); |
| 3810 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3882 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
| 3811 base::StringPrintf( | 3883 base::StringPrintf( |
| 3812 "[{\"id\": %d," | 3884 "[{\"id\": %d," |
| 3813 " \"incognito\": true," | 3885 " \"incognito\": true," |
| 3814 " \"filename\":\"slow.txt\"}]", | 3886 " \"filename\":\"slow.txt\"}]", |
| 3815 result_id))); | 3887 result_id))); |
| 3816 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3888 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
| 3817 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3889 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
| 3818 | 3890 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4151 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 4223 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
| 4152 EXPECT_FALSE(warnings.empty()); | 4224 EXPECT_FALSE(warnings.empty()); |
| 4153 EXPECT_EQ(Warning::kDownloadFilenameConflict, | 4225 EXPECT_EQ(Warning::kDownloadFilenameConflict, |
| 4154 warnings.begin()->warning_type()); | 4226 warnings.begin()->warning_type()); |
| 4155 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 4227 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
| 4156 } | 4228 } |
| 4157 | 4229 |
| 4158 } // namespace extensions | 4230 } // namespace extensions |
| 4159 | 4231 |
| 4160 #endif // http://crbug.com/306144 | 4232 #endif // http://crbug.com/306144 |
| OLD | NEW |