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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 DownloadItem* download_item = CreateSlowTestDownload(); | 822 DownloadItem* download_item = CreateSlowTestDownload(); |
823 ASSERT_TRUE(download_item); | 823 ASSERT_TRUE(download_item); |
824 EXPECT_FALSE(download_item->GetOpened()); | 824 EXPECT_FALSE(download_item->GetOpened()); |
825 EXPECT_FALSE(download_item->GetOpenWhenComplete()); | 825 EXPECT_FALSE(download_item->GetOpenWhenComplete()); |
826 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 826 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
827 base::StringPrintf( | 827 base::StringPrintf( |
828 "[{\"danger\": \"safe\"," | 828 "[{\"danger\": \"safe\"," |
829 " \"incognito\": false," | 829 " \"incognito\": false," |
830 " \"mime\": \"application/octet-stream\"," | 830 " \"mime\": \"application/octet-stream\"," |
831 " \"paused\": false," | 831 " \"paused\": false," |
832 " \"finalUrl\": \"%s\"," | |
832 " \"url\": \"%s\"}]", | 833 " \"url\": \"%s\"}]", |
834 download_item->GetURL().spec().c_str(), | |
833 download_item->GetURL().spec().c_str()))); | 835 download_item->GetURL().spec().c_str()))); |
834 open_function = new DownloadsOpenFunction(); | 836 open_function = new DownloadsOpenFunction(); |
835 open_function->set_user_gesture(true); | 837 open_function->set_user_gesture(true); |
836 EXPECT_STREQ(errors::kNotComplete, | 838 EXPECT_STREQ(errors::kNotComplete, |
837 RunFunctionAndReturnError( | 839 RunFunctionAndReturnError( |
838 open_function, | 840 open_function, |
839 DownloadItemIdAsArgList(download_item)).c_str()); | 841 DownloadItemIdAsArgList(download_item)).c_str()); |
840 | 842 |
841 FinishPendingSlowDownloads(); | 843 FinishPendingSlowDownloads(); |
842 EXPECT_FALSE(download_item->GetOpened()); | 844 EXPECT_FALSE(download_item->GetOpened()); |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1511 ScopedCancellingItem canceller(item); | 1513 ScopedCancellingItem canceller(item); |
1512 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1514 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1513 ASSERT_EQ(GetExtensionURL(), item->GetSiteUrl().spec()); | 1515 ASSERT_EQ(GetExtensionURL(), item->GetSiteUrl().spec()); |
1514 | 1516 |
1515 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1517 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1516 base::StringPrintf( | 1518 base::StringPrintf( |
1517 "[{\"danger\": \"safe\"," | 1519 "[{\"danger\": \"safe\"," |
1518 " \"incognito\": false," | 1520 " \"incognito\": false," |
1519 " \"mime\": \"text/plain\"," | 1521 " \"mime\": \"text/plain\"," |
1520 " \"paused\": false," | 1522 " \"paused\": false," |
1523 " \"finalUrl\": \"%s\"," | |
1521 " \"url\": \"%s\"}]", | 1524 " \"url\": \"%s\"}]", |
1525 download_url.c_str(), | |
1522 download_url.c_str()))); | 1526 download_url.c_str()))); |
1523 ASSERT_TRUE( | 1527 ASSERT_TRUE( |
1524 WaitFor(downloads::OnChanged::kEventName, | 1528 WaitFor(downloads::OnChanged::kEventName, |
1525 base::StringPrintf("[{\"id\": %d," | 1529 base::StringPrintf("[{\"id\": %d," |
1526 " \"filename\": {" | 1530 " \"filename\": {" |
1527 " \"previous\": \"\"," | 1531 " \"previous\": \"\"," |
1528 " \"current\": \"%s\"}}]", | 1532 " \"current\": \"%s\"}}]", |
1529 result_id, GetFilename("slow.txt").c_str()))); | 1533 result_id, GetFilename("slow.txt").c_str()))); |
1530 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1534 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1531 base::StringPrintf( | 1535 base::StringPrintf( |
1532 "[{\"id\": %d," | 1536 "[{\"id\": %d," |
1533 " \"state\": {" | 1537 " \"state\": {" |
1534 " \"previous\": \"in_progress\"," | 1538 " \"previous\": \"in_progress\"," |
1535 " \"current\": \"complete\"}}]", | 1539 " \"current\": \"complete\"}}]", |
1536 result_id))); | 1540 result_id))); |
1537 } | 1541 } |
1538 | 1542 |
1543 // Test that we can start a download that gets redirected and that the correct | |
1544 // sequence of events is fired for it. | |
1545 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | |
1546 DownloadExtensionTest_Download_Redirect) { | |
1547 LoadExtension("downloads_split"); | |
1548 ASSERT_TRUE(StartEmbeddedTestServer()); | |
1549 GURL download_final_url(embedded_test_server()->GetURL("/slow?0")); | |
1550 GURL download_url(embedded_test_server()->GetURL( | |
1551 "/server-redirect?" + download_final_url.spec())); | |
1552 | |
1553 GoOnTheRecord(); | |
1554 | |
1555 // Start downloading a file. | |
1556 std::unique_ptr<base::Value> result(RunFunctionAndReturnResult( | |
1557 new DownloadsDownloadFunction(), | |
1558 base::StringPrintf("[{\"url\": \"%s\"}]", download_url.spec().c_str()))); | |
1559 ASSERT_TRUE(result.get()); | |
1560 int result_id = -1; | |
1561 ASSERT_TRUE(result->GetAsInteger(&result_id)); | |
1562 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); | |
1563 ASSERT_TRUE(item); | |
1564 ScopedCancellingItem canceller(item); | |
1565 ASSERT_EQ(download_url, item->GetOriginalUrl()); | |
1566 ASSERT_EQ(GetExtensionURL(), item->GetSiteUrl().spec()); | |
1567 | |
1568 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | |
1569 base::StringPrintf( | |
1570 "[{\"danger\": \"safe\"," | |
1571 " \"incognito\": false," | |
1572 " \"mime\": \"text/plain\"," | |
1573 " \"paused\": false," | |
1574 " \"finalUrl\": \"%s\"," | |
1575 " \"url\": \"%s\"}]", | |
1576 download_final_url.spec().c_str(), | |
1577 download_url.spec().c_str()))); | |
1578 ASSERT_TRUE( | |
1579 WaitFor(downloads::OnChanged::kEventName, | |
1580 base::StringPrintf("[{\"id\": %d," | |
1581 " \"filename\": {" | |
1582 " \"previous\": \"\"," | |
1583 " \"current\": \"%s\"}}]", | |
1584 result_id, GetFilename("slow.txt").c_str()))); | |
1585 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | |
1586 base::StringPrintf( | |
1587 "[{\"id\": %d," | |
1588 " \"state\": {" | |
1589 " \"previous\": \"in_progress\"," | |
1590 " \"current\": \"complete\"}}]", | |
1591 result_id))); | |
1592 } | |
1593 | |
1539 // Test that we can start a download from an incognito context, and that the | 1594 // Test that we can start a download from an incognito context, and that the |
1540 // download knows that it's incognito. | 1595 // download knows that it's incognito. |
1541 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 1596 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
1542 DownloadExtensionTest_Download_Incognito) { | 1597 DownloadExtensionTest_Download_Incognito) { |
1543 LoadExtension("downloads_split"); | 1598 LoadExtension("downloads_split"); |
1544 ASSERT_TRUE(StartEmbeddedTestServer()); | 1599 ASSERT_TRUE(StartEmbeddedTestServer()); |
1545 GoOffTheRecord(); | 1600 GoOffTheRecord(); |
1546 std::string download_url = embedded_test_server()->GetURL("/slow?0").spec(); | 1601 std::string download_url = embedded_test_server()->GetURL("/slow?0").spec(); |
1547 | 1602 |
1548 // Start downloading a file. | 1603 // Start downloading a file. |
1549 std::unique_ptr<base::Value> result(RunFunctionAndReturnResult( | 1604 std::unique_ptr<base::Value> result(RunFunctionAndReturnResult( |
1550 new DownloadsDownloadFunction(), | 1605 new DownloadsDownloadFunction(), |
1551 base::StringPrintf("[{\"url\": \"%s\"}]", download_url.c_str()))); | 1606 base::StringPrintf("[{\"url\": \"%s\"}]", download_url.c_str()))); |
1552 ASSERT_TRUE(result.get()); | 1607 ASSERT_TRUE(result.get()); |
1553 int result_id = -1; | 1608 int result_id = -1; |
1554 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1609 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
1555 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); | 1610 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
1556 ASSERT_TRUE(item); | 1611 ASSERT_TRUE(item); |
1557 ScopedCancellingItem canceller(item); | 1612 ScopedCancellingItem canceller(item); |
1558 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1613 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1559 | 1614 |
1560 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1615 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1561 base::StringPrintf( | 1616 base::StringPrintf( |
1562 "[{\"danger\": \"safe\"," | 1617 "[{\"danger\": \"safe\"," |
1563 " \"incognito\": true," | 1618 " \"incognito\": true," |
1564 " \"mime\": \"text/plain\"," | 1619 " \"mime\": \"text/plain\"," |
1565 " \"paused\": false," | 1620 " \"paused\": false," |
1621 " \"finalUrl\": \"%s\"," | |
1566 " \"url\": \"%s\"}]", | 1622 " \"url\": \"%s\"}]", |
1623 download_url.c_str(), | |
1567 download_url.c_str()))); | 1624 download_url.c_str()))); |
1568 ASSERT_TRUE( | 1625 ASSERT_TRUE( |
1569 WaitFor(downloads::OnChanged::kEventName, | 1626 WaitFor(downloads::OnChanged::kEventName, |
1570 base::StringPrintf("[{\"id\":%d," | 1627 base::StringPrintf("[{\"id\":%d," |
1571 " \"filename\": {" | 1628 " \"filename\": {" |
1572 " \"previous\": \"\"," | 1629 " \"previous\": \"\"," |
1573 " \"current\": \"%s\"}}]", | 1630 " \"current\": \"%s\"}}]", |
1574 result_id, GetFilename("slow.txt").c_str()))); | 1631 result_id, GetFilename("slow.txt").c_str()))); |
1575 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1632 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1576 base::StringPrintf( | 1633 base::StringPrintf( |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1740 ASSERT_TRUE(item); | 1797 ASSERT_TRUE(item); |
1741 ScopedCancellingItem canceller(item); | 1798 ScopedCancellingItem canceller(item); |
1742 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1799 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1743 | 1800 |
1744 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1801 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1745 base::StringPrintf( | 1802 base::StringPrintf( |
1746 "[{\"danger\": \"safe\"," | 1803 "[{\"danger\": \"safe\"," |
1747 " \"incognito\": false," | 1804 " \"incognito\": false," |
1748 " \"mime\": \"text/plain\"," | 1805 " \"mime\": \"text/plain\"," |
1749 " \"paused\": false," | 1806 " \"paused\": false," |
1807 " \"finalUrl\": \"%s\"," | |
1750 " \"url\": \"%s\"}]", | 1808 " \"url\": \"%s\"}]", |
1809 download_url.c_str(), | |
1751 download_url.c_str()))); | 1810 download_url.c_str()))); |
1752 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1811 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1753 base::StringPrintf( | 1812 base::StringPrintf( |
1754 "[{\"id\": %d," | 1813 "[{\"id\": %d," |
1755 " \"filename\": {" | 1814 " \"filename\": {" |
1756 " \"previous\": \"\"," | 1815 " \"previous\": \"\"," |
1757 " \"current\": \"%s\"}}]", | 1816 " \"current\": \"%s\"}}]", |
1758 result_id, | 1817 result_id, |
1759 GetFilename("sub/dir/ect/ory.txt").c_str()))); | 1818 GetFilename("sub/dir/ect/ory.txt").c_str()))); |
1760 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1819 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1875 ASSERT_TRUE(item); | 1934 ASSERT_TRUE(item); |
1876 ScopedCancellingItem canceller(item); | 1935 ScopedCancellingItem canceller(item); |
1877 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1936 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1878 | 1937 |
1879 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1938 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1880 base::StringPrintf( | 1939 base::StringPrintf( |
1881 "[{\"danger\": \"safe\"," | 1940 "[{\"danger\": \"safe\"," |
1882 " \"incognito\": false," | 1941 " \"incognito\": false," |
1883 " \"mime\": \"text/plain\"," | 1942 " \"mime\": \"text/plain\"," |
1884 " \"paused\": false," | 1943 " \"paused\": false," |
1944 " \"finalUrl\": \"%s\"," | |
1885 " \"url\": \"%s\"}]", | 1945 " \"url\": \"%s\"}]", |
1946 download_url.c_str(), | |
1886 download_url.c_str()))); | 1947 download_url.c_str()))); |
1887 ASSERT_TRUE( | 1948 ASSERT_TRUE( |
1888 WaitFor(downloads::OnChanged::kEventName, | 1949 WaitFor(downloads::OnChanged::kEventName, |
1889 base::StringPrintf("[{\"id\": %d," | 1950 base::StringPrintf("[{\"id\": %d," |
1890 " \"filename\": {" | 1951 " \"filename\": {" |
1891 " \"previous\": \"\"," | 1952 " \"previous\": \"\"," |
1892 " \"current\": \"%s\"}}]", | 1953 " \"current\": \"%s\"}}]", |
1893 result_id, GetFilename("slow.txt").c_str()))); | 1954 result_id, GetFilename("slow.txt").c_str()))); |
1894 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1955 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1895 base::StringPrintf( | 1956 base::StringPrintf( |
(...skipping 22 matching lines...) Expand all Loading... | |
1918 ASSERT_TRUE(item); | 1979 ASSERT_TRUE(item); |
1919 ScopedCancellingItem canceller(item); | 1980 ScopedCancellingItem canceller(item); |
1920 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1981 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1921 | 1982 |
1922 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 1983 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1923 base::StringPrintf( | 1984 base::StringPrintf( |
1924 "[{\"danger\": \"safe\"," | 1985 "[{\"danger\": \"safe\"," |
1925 " \"incognito\": false," | 1986 " \"incognito\": false," |
1926 " \"mime\": \"text/plain\"," | 1987 " \"mime\": \"text/plain\"," |
1927 " \"paused\": false," | 1988 " \"paused\": false," |
1989 " \"finalUrl\": \"%s\"," | |
1928 " \"url\": \"%s\"}]", | 1990 " \"url\": \"%s\"}]", |
1991 download_url.c_str(), | |
1929 download_url.c_str()))); | 1992 download_url.c_str()))); |
1930 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 1993 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1931 base::StringPrintf( | 1994 base::StringPrintf( |
1932 "[{\"id\": %d," | 1995 "[{\"id\": %d," |
1933 " \"filename\": {" | 1996 " \"filename\": {" |
1934 " \"previous\": \"\"," | 1997 " \"previous\": \"\"," |
1935 " \"current\": \"%s\"}}]", | 1998 " \"current\": \"%s\"}}]", |
1936 result_id, | 1999 result_id, |
1937 GetFilename(kFilename).c_str()))); | 2000 GetFilename(kFilename).c_str()))); |
1938 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2001 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 15 matching lines...) Expand all Loading... | |
1954 ASSERT_TRUE(item); | 2017 ASSERT_TRUE(item); |
1955 ScopedCancellingItem canceller2(item); | 2018 ScopedCancellingItem canceller2(item); |
1956 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2019 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
1957 | 2020 |
1958 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2021 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
1959 base::StringPrintf( | 2022 base::StringPrintf( |
1960 "[{\"danger\": \"safe\"," | 2023 "[{\"danger\": \"safe\"," |
1961 " \"incognito\": false," | 2024 " \"incognito\": false," |
1962 " \"mime\": \"text/plain\"," | 2025 " \"mime\": \"text/plain\"," |
1963 " \"paused\": false," | 2026 " \"paused\": false," |
2027 " \"finalUrl\": \"%s\"," | |
1964 " \"url\": \"%s\"}]", | 2028 " \"url\": \"%s\"}]", |
2029 download_url.c_str(), | |
1965 download_url.c_str()))); | 2030 download_url.c_str()))); |
1966 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2031 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
1967 base::StringPrintf( | 2032 base::StringPrintf( |
1968 "[{\"id\": %d," | 2033 "[{\"id\": %d," |
1969 " \"filename\": {" | 2034 " \"filename\": {" |
1970 " \"previous\": \"\"," | 2035 " \"previous\": \"\"," |
1971 " \"current\": \"%s\"}}]", | 2036 " \"current\": \"%s\"}}]", |
1972 result_id, | 2037 result_id, |
1973 GetFilename(kFilename).c_str()))); | 2038 GetFilename(kFilename).c_str()))); |
1974 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2039 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 24 matching lines...) Expand all Loading... | |
1999 ASSERT_TRUE(item); | 2064 ASSERT_TRUE(item); |
2000 ScopedCancellingItem canceller(item); | 2065 ScopedCancellingItem canceller(item); |
2001 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2066 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2002 | 2067 |
2003 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2068 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2004 base::StringPrintf( | 2069 base::StringPrintf( |
2005 "[{\"danger\": \"safe\"," | 2070 "[{\"danger\": \"safe\"," |
2006 " \"incognito\": false," | 2071 " \"incognito\": false," |
2007 " \"mime\": \"text/plain\"," | 2072 " \"mime\": \"text/plain\"," |
2008 " \"paused\": false," | 2073 " \"paused\": false," |
2074 " \"finalUrl\": \"%s\"," | |
2009 " \"url\": \"%s\"}]", | 2075 " \"url\": \"%s\"}]", |
2076 download_url.c_str(), | |
2010 download_url.c_str()))); | 2077 download_url.c_str()))); |
2011 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2078 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2012 base::StringPrintf( | 2079 base::StringPrintf( |
2013 "[{\"id\": %d," | 2080 "[{\"id\": %d," |
2014 " \"filename\": {" | 2081 " \"filename\": {" |
2015 " \"previous\": \"\"," | 2082 " \"previous\": \"\"," |
2016 " \"current\": \"%s\"}}]", | 2083 " \"current\": \"%s\"}}]", |
2017 result_id, | 2084 result_id, |
2018 GetFilename("data.txt").c_str()))); | 2085 GetFilename("data.txt").c_str()))); |
2019 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2086 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2055 ASSERT_TRUE(item); | 2122 ASSERT_TRUE(item); |
2056 ScopedCancellingItem canceller(item); | 2123 ScopedCancellingItem canceller(item); |
2057 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2124 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2058 | 2125 |
2059 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2126 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2060 base::StringPrintf( | 2127 base::StringPrintf( |
2061 "[{\"danger\": \"safe\"," | 2128 "[{\"danger\": \"safe\"," |
2062 " \"incognito\": false," | 2129 " \"incognito\": false," |
2063 " \"mime\": \"text/html\"," | 2130 " \"mime\": \"text/html\"," |
2064 " \"paused\": false," | 2131 " \"paused\": false," |
2132 " \"finalUrl\": \"%s\"," | |
2065 " \"url\": \"%s\"}]", | 2133 " \"url\": \"%s\"}]", |
2134 download_url.c_str(), | |
2066 download_url.c_str()))); | 2135 download_url.c_str()))); |
2067 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2136 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2068 base::StringPrintf( | 2137 base::StringPrintf( |
2069 "[{\"id\": %d," | 2138 "[{\"id\": %d," |
2070 " \"filename\": {" | 2139 " \"filename\": {" |
2071 " \"previous\": \"\"," | 2140 " \"previous\": \"\"," |
2072 " \"current\": \"%s\"}}]", | 2141 " \"current\": \"%s\"}}]", |
2073 result_id, | 2142 result_id, |
2074 GetFilename("file.txt").c_str()))); | 2143 GetFilename("file.txt").c_str()))); |
2075 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2144 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 29 matching lines...) Expand all Loading... | |
2105 ASSERT_TRUE(item); | 2174 ASSERT_TRUE(item); |
2106 ScopedCancellingItem canceller(item); | 2175 ScopedCancellingItem canceller(item); |
2107 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2176 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2108 | 2177 |
2109 ASSERT_TRUE(WaitForInterruption( | 2178 ASSERT_TRUE(WaitForInterruption( |
2110 item, | 2179 item, |
2111 content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, | 2180 content::DOWNLOAD_INTERRUPT_REASON_SERVER_UNAUTHORIZED, |
2112 base::StringPrintf("[{\"danger\": \"safe\"," | 2181 base::StringPrintf("[{\"danger\": \"safe\"," |
2113 " \"incognito\": false," | 2182 " \"incognito\": false," |
2114 " \"paused\": false," | 2183 " \"paused\": false," |
2184 " \"finalUrl\": \"%s\"," | |
2115 " \"url\": \"%s\"}]", | 2185 " \"url\": \"%s\"}]", |
2186 download_url.c_str(), | |
2116 download_url.c_str()))); | 2187 download_url.c_str()))); |
2117 } | 2188 } |
2118 | 2189 |
2119 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. | 2190 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. |
2120 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2191 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2121 DownloadExtensionTest_Download_Headers) { | 2192 DownloadExtensionTest_Download_Headers) { |
2122 LoadExtension("downloads_split"); | 2193 LoadExtension("downloads_split"); |
2123 ASSERT_TRUE(StartEmbeddedTestServer()); | 2194 ASSERT_TRUE(StartEmbeddedTestServer()); |
2124 std::string download_url = | 2195 std::string download_url = |
2125 embedded_test_server() | 2196 embedded_test_server() |
(...skipping 18 matching lines...) Expand all Loading... | |
2144 ASSERT_TRUE(item); | 2215 ASSERT_TRUE(item); |
2145 ScopedCancellingItem canceller(item); | 2216 ScopedCancellingItem canceller(item); |
2146 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2217 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2147 | 2218 |
2148 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2219 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2149 base::StringPrintf( | 2220 base::StringPrintf( |
2150 "[{\"danger\": \"safe\"," | 2221 "[{\"danger\": \"safe\"," |
2151 " \"incognito\": false," | 2222 " \"incognito\": false," |
2152 " \"mime\": \"application/octet-stream\"," | 2223 " \"mime\": \"application/octet-stream\"," |
2153 " \"paused\": false," | 2224 " \"paused\": false," |
2225 " \"finalUrl\": \"%s\"," | |
2154 " \"url\": \"%s\"}]", | 2226 " \"url\": \"%s\"}]", |
2227 download_url.c_str(), | |
2155 download_url.c_str()))); | 2228 download_url.c_str()))); |
2156 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2229 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2157 base::StringPrintf( | 2230 base::StringPrintf( |
2158 "[{\"id\": %d," | 2231 "[{\"id\": %d," |
2159 " \"filename\": {" | 2232 " \"filename\": {" |
2160 " \"previous\": \"\"," | 2233 " \"previous\": \"\"," |
2161 " \"current\": \"%s\"}}]", | 2234 " \"current\": \"%s\"}}]", |
2162 result_id, | 2235 result_id, |
2163 GetFilename("headers-succeed.txt").c_str()))); | 2236 GetFilename("headers-succeed.txt").c_str()))); |
2164 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2237 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2201 | 2274 |
2202 ASSERT_TRUE(WaitForInterruption( | 2275 ASSERT_TRUE(WaitForInterruption( |
2203 item, | 2276 item, |
2204 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2277 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
2205 base::StringPrintf("[{\"danger\": \"safe\"," | 2278 base::StringPrintf("[{\"danger\": \"safe\"," |
2206 " \"incognito\": false," | 2279 " \"incognito\": false," |
2207 " \"bytesReceived\": 0.0," | 2280 " \"bytesReceived\": 0.0," |
2208 " \"fileSize\": 0.0," | 2281 " \"fileSize\": 0.0," |
2209 " \"mime\": \"\"," | 2282 " \"mime\": \"\"," |
2210 " \"paused\": false," | 2283 " \"paused\": false," |
2284 " \"finalUrl\": \"%s\"," | |
2211 " \"url\": \"%s\"}]", | 2285 " \"url\": \"%s\"}]", |
2286 download_url.c_str(), | |
2212 download_url.c_str()))); | 2287 download_url.c_str()))); |
2213 } | 2288 } |
2214 | 2289 |
2215 // Test that DownloadsDownloadFunction propagates the Authorization header | 2290 // Test that DownloadsDownloadFunction propagates the Authorization header |
2216 // correctly. | 2291 // correctly. |
2217 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2292 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2218 DownloadExtensionTest_Download_AuthBasic) { | 2293 DownloadExtensionTest_Download_AuthBasic) { |
2219 LoadExtension("downloads_split"); | 2294 LoadExtension("downloads_split"); |
2220 ASSERT_TRUE(StartEmbeddedTestServer()); | 2295 ASSERT_TRUE(StartEmbeddedTestServer()); |
2221 std::string download_url = | 2296 std::string download_url = |
(...skipping 18 matching lines...) Expand all Loading... | |
2240 ScopedCancellingItem canceller(item); | 2315 ScopedCancellingItem canceller(item); |
2241 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2316 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2242 | 2317 |
2243 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2318 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2244 base::StringPrintf( | 2319 base::StringPrintf( |
2245 "[{\"danger\": \"safe\"," | 2320 "[{\"danger\": \"safe\"," |
2246 " \"incognito\": false," | 2321 " \"incognito\": false," |
2247 " \"bytesReceived\": 0.0," | 2322 " \"bytesReceived\": 0.0," |
2248 " \"mime\": \"text/html\"," | 2323 " \"mime\": \"text/html\"," |
2249 " \"paused\": false," | 2324 " \"paused\": false," |
2325 " \"finalUrl\": \"%s\"," | |
2250 " \"url\": \"%s\"}]", | 2326 " \"url\": \"%s\"}]", |
2327 download_url.c_str(), | |
2251 download_url.c_str()))); | 2328 download_url.c_str()))); |
2252 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2329 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2253 base::StringPrintf( | 2330 base::StringPrintf( |
2254 "[{\"id\": %d," | 2331 "[{\"id\": %d," |
2255 " \"state\": {" | 2332 " \"state\": {" |
2256 " \"previous\": \"in_progress\"," | 2333 " \"previous\": \"in_progress\"," |
2257 " \"current\": \"complete\"}}]", | 2334 " \"current\": \"complete\"}}]", |
2258 result_id))); | 2335 result_id))); |
2259 } | 2336 } |
2260 | 2337 |
(...skipping 24 matching lines...) Expand all Loading... | |
2285 ASSERT_TRUE(item); | 2362 ASSERT_TRUE(item); |
2286 ScopedCancellingItem canceller(item); | 2363 ScopedCancellingItem canceller(item); |
2287 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2364 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2288 | 2365 |
2289 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2366 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2290 base::StringPrintf( | 2367 base::StringPrintf( |
2291 "[{\"danger\": \"safe\"," | 2368 "[{\"danger\": \"safe\"," |
2292 " \"incognito\": false," | 2369 " \"incognito\": false," |
2293 " \"mime\": \"application/octet-stream\"," | 2370 " \"mime\": \"application/octet-stream\"," |
2294 " \"paused\": false," | 2371 " \"paused\": false," |
2372 " \"finalUrl\": \"%s\"," | |
2295 " \"url\": \"%s\"}]", | 2373 " \"url\": \"%s\"}]", |
2374 download_url.c_str(), | |
2296 download_url.c_str()))); | 2375 download_url.c_str()))); |
2297 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2376 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2298 base::StringPrintf( | 2377 base::StringPrintf( |
2299 "[{\"id\": %d," | 2378 "[{\"id\": %d," |
2300 " \"filename\": {" | 2379 " \"filename\": {" |
2301 " \"previous\": \"\"," | 2380 " \"previous\": \"\"," |
2302 " \"current\": \"%s\"}}]", | 2381 " \"current\": \"%s\"}}]", |
2303 result_id, | 2382 result_id, |
2304 GetFilename("post-succeed.txt").c_str()))); | 2383 GetFilename("post-succeed.txt").c_str()))); |
2305 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2384 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2342 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2421 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2343 | 2422 |
2344 ASSERT_TRUE(WaitForInterruption( | 2423 ASSERT_TRUE(WaitForInterruption( |
2345 item, | 2424 item, |
2346 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2425 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
2347 base::StringPrintf("[{\"danger\": \"safe\"," | 2426 base::StringPrintf("[{\"danger\": \"safe\"," |
2348 " \"incognito\": false," | 2427 " \"incognito\": false," |
2349 " \"mime\": \"\"," | 2428 " \"mime\": \"\"," |
2350 " \"paused\": false," | 2429 " \"paused\": false," |
2351 " \"id\": %d," | 2430 " \"id\": %d," |
2431 " \"finalUrl\": \"%s\"," | |
2352 " \"url\": \"%s\"}]", | 2432 " \"url\": \"%s\"}]", |
2353 result_id, | 2433 result_id, |
2434 download_url.c_str(), | |
2354 download_url.c_str()))); | 2435 download_url.c_str()))); |
2355 } | 2436 } |
2356 | 2437 |
2357 // Test that downloadPostSuccess would fail if the resource requires the POST | 2438 // Test that downloadPostSuccess would fail if the resource requires the POST |
2358 // method, and chrome fails to propagate the |body| parameter back to the | 2439 // method, and chrome fails to propagate the |body| parameter back to the |
2359 // server. This tests both that testserver.py does not succeed when it should | 2440 // server. This tests both that testserver.py does not succeed when it should |
2360 // fail, and this tests how the downloads extension api exposes the failure to | 2441 // fail, and this tests how the downloads extension api exposes the failure to |
2361 // extensions. | 2442 // extensions. |
2362 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2443 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2363 DownloadExtensionTest_Download_Post_NoBody) { | 2444 DownloadExtensionTest_Download_Post_NoBody) { |
(...skipping 21 matching lines...) Expand all Loading... | |
2385 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2466 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2386 | 2467 |
2387 ASSERT_TRUE(WaitForInterruption( | 2468 ASSERT_TRUE(WaitForInterruption( |
2388 item, | 2469 item, |
2389 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, | 2470 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
2390 base::StringPrintf("[{\"danger\": \"safe\"," | 2471 base::StringPrintf("[{\"danger\": \"safe\"," |
2391 " \"incognito\": false," | 2472 " \"incognito\": false," |
2392 " \"mime\": \"\"," | 2473 " \"mime\": \"\"," |
2393 " \"paused\": false," | 2474 " \"paused\": false," |
2394 " \"id\": %d," | 2475 " \"id\": %d," |
2476 " \"finalUrl\": \"%s\"," | |
2395 " \"url\": \"%s\"}]", | 2477 " \"url\": \"%s\"}]", |
2396 result_id, | 2478 result_id, |
2479 download_url.c_str(), | |
2397 download_url.c_str()))); | 2480 download_url.c_str()))); |
2398 } | 2481 } |
2399 | 2482 |
2400 // Test that cancel()ing an in-progress download causes its state to transition | 2483 // Test that cancel()ing an in-progress download causes its state to transition |
2401 // to interrupted, and test that that state transition is detectable by an | 2484 // to interrupted, and test that that state transition is detectable by an |
2402 // onChanged event listener. TODO(benjhayden): Test other sources of | 2485 // onChanged event listener. TODO(benjhayden): Test other sources of |
2403 // interruptions such as server death. | 2486 // interruptions such as server death. |
2404 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, | 2487 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
2405 DownloadExtensionTest_Download_Cancel) { | 2488 DownloadExtensionTest_Download_Cancel) { |
2406 LoadExtension("downloads_split"); | 2489 LoadExtension("downloads_split"); |
(...skipping 14 matching lines...) Expand all Loading... | |
2421 ScopedCancellingItem canceller(item); | 2504 ScopedCancellingItem canceller(item); |
2422 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2505 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2423 | 2506 |
2424 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2507 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2425 base::StringPrintf( | 2508 base::StringPrintf( |
2426 "[{\"danger\": \"safe\"," | 2509 "[{\"danger\": \"safe\"," |
2427 " \"incognito\": false," | 2510 " \"incognito\": false," |
2428 " \"mime\": \"application/octet-stream\"," | 2511 " \"mime\": \"application/octet-stream\"," |
2429 " \"paused\": false," | 2512 " \"paused\": false," |
2430 " \"id\": %d," | 2513 " \"id\": %d," |
2514 " \"finalUrl\": \"%s\"," | |
2431 " \"url\": \"%s\"}]", | 2515 " \"url\": \"%s\"}]", |
2432 result_id, | 2516 result_id, |
2517 download_url.c_str(), | |
2433 download_url.c_str()))); | 2518 download_url.c_str()))); |
2434 item->Cancel(true); | 2519 item->Cancel(true); |
2435 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2520 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2436 base::StringPrintf( | 2521 base::StringPrintf( |
2437 "[{\"id\": %d," | 2522 "[{\"id\": %d," |
2438 " \"error\": {\"current\":\"USER_CANCELED\"}," | 2523 " \"error\": {\"current\":\"USER_CANCELED\"}," |
2439 " \"state\": {" | 2524 " \"state\": {" |
2440 " \"previous\": \"in_progress\"," | 2525 " \"previous\": \"in_progress\"," |
2441 " \"current\": \"interrupted\"}}]", | 2526 " \"current\": \"interrupted\"}}]", |
2442 result_id))); | 2527 result_id))); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2482 ASSERT_TRUE(item); | 2567 ASSERT_TRUE(item); |
2483 ScopedCancellingItem canceller(item); | 2568 ScopedCancellingItem canceller(item); |
2484 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2569 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2485 | 2570 |
2486 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2571 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2487 base::StringPrintf( | 2572 base::StringPrintf( |
2488 "[{\"danger\": \"safe\"," | 2573 "[{\"danger\": \"safe\"," |
2489 " \"incognito\": false," | 2574 " \"incognito\": false," |
2490 " \"mime\": \"text/plain\"," | 2575 " \"mime\": \"text/plain\"," |
2491 " \"paused\": false," | 2576 " \"paused\": false," |
2577 " \"finalUrl\": \"%s\"," | |
asanka
2016/07/07 19:28:31
Are all these test changes necessary? I'm inclined
mharanczyk
2016/07/08 10:10:54
I've removed most of additions, left finalUrl chec
| |
2492 " \"url\": \"%s\"}]", | 2578 " \"url\": \"%s\"}]", |
2579 download_url.c_str(), | |
2493 download_url.c_str()))); | 2580 download_url.c_str()))); |
2494 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2581 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
2495 base::StringPrintf( | 2582 base::StringPrintf( |
2496 "[{\"id\": %d," | 2583 "[{\"id\": %d," |
2497 " \"filename\": {" | 2584 " \"filename\": {" |
2498 " \"previous\": \"\"," | 2585 " \"previous\": \"\"," |
2499 " \"current\": \"%s\"}}]", | 2586 " \"current\": \"%s\"}}]", |
2500 result_id, | 2587 result_id, |
2501 GetFilename("on_record.txt").c_str()))); | 2588 GetFilename("on_record.txt").c_str()))); |
2502 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, | 2589 ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName, |
(...skipping 29 matching lines...) Expand all Loading... | |
2532 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2619 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2533 | 2620 |
2534 // Wait for the onCreated and onDeterminingFilename events. | 2621 // Wait for the onCreated and onDeterminingFilename events. |
2535 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2622 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2536 base::StringPrintf( | 2623 base::StringPrintf( |
2537 "[{\"danger\": \"safe\"," | 2624 "[{\"danger\": \"safe\"," |
2538 " \"incognito\": false," | 2625 " \"incognito\": false," |
2539 " \"id\": %d," | 2626 " \"id\": %d," |
2540 " \"mime\": \"text/plain\"," | 2627 " \"mime\": \"text/plain\"," |
2541 " \"paused\": false," | 2628 " \"paused\": false," |
2629 " \"finalUrl\": \"%s\"," | |
2542 " \"url\": \"%s\"}]", | 2630 " \"url\": \"%s\"}]", |
2543 result_id, | 2631 result_id, |
2632 download_url.c_str(), | |
2544 download_url.c_str()))); | 2633 download_url.c_str()))); |
2545 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2634 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
2546 base::StringPrintf( | 2635 base::StringPrintf( |
2547 "[{\"id\": %d," | 2636 "[{\"id\": %d," |
2548 " \"filename\":\"slow.txt\"}]", | 2637 " \"filename\":\"slow.txt\"}]", |
2549 result_id))); | 2638 result_id))); |
2550 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2639 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2551 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2640 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2552 | 2641 |
2553 // Respond to the onDeterminingFilename. | 2642 // Respond to the onDeterminingFilename. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2604 ScopedCancellingItem canceller(item); | 2693 ScopedCancellingItem canceller(item); |
2605 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2694 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2606 | 2695 |
2607 // Wait for the onCreated and onDeterminingFilename events. | 2696 // Wait for the onCreated and onDeterminingFilename events. |
2608 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2697 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2609 base::StringPrintf("[{\"danger\": \"safe\"," | 2698 base::StringPrintf("[{\"danger\": \"safe\"," |
2610 " \"incognito\": false," | 2699 " \"incognito\": false," |
2611 " \"id\": %d," | 2700 " \"id\": %d," |
2612 " \"mime\": \"text/plain\"," | 2701 " \"mime\": \"text/plain\"," |
2613 " \"paused\": false," | 2702 " \"paused\": false," |
2703 " \"finalUrl\": \"%s\"," | |
2614 " \"url\": \"%s\"}]", | 2704 " \"url\": \"%s\"}]", |
2615 result_id, | 2705 result_id, |
2706 download_url.c_str(), | |
2616 download_url.c_str()))); | 2707 download_url.c_str()))); |
2617 ASSERT_TRUE(WaitFor( | 2708 ASSERT_TRUE(WaitFor( |
2618 downloads::OnDeterminingFilename::kEventName, | 2709 downloads::OnDeterminingFilename::kEventName, |
2619 base::StringPrintf("[{\"id\": %d," | 2710 base::StringPrintf("[{\"id\": %d," |
2620 " \"filename\":\"slow.txt\"}]", | 2711 " \"filename\":\"slow.txt\"}]", |
2621 result_id))); | 2712 result_id))); |
2622 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2713 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2623 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2714 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2624 | 2715 |
2625 // Do not respond to the onDeterminingFilename. | 2716 // Do not respond to the onDeterminingFilename. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2660 ScopedCancellingItem canceller(item); | 2751 ScopedCancellingItem canceller(item); |
2661 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2752 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2662 | 2753 |
2663 // Wait for the onCreated and onDeterminingFilename events. | 2754 // Wait for the onCreated and onDeterminingFilename events. |
2664 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2755 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2665 base::StringPrintf("[{\"danger\": \"safe\"," | 2756 base::StringPrintf("[{\"danger\": \"safe\"," |
2666 " \"incognito\": false," | 2757 " \"incognito\": false," |
2667 " \"id\": %d," | 2758 " \"id\": %d," |
2668 " \"mime\": \"text/plain\"," | 2759 " \"mime\": \"text/plain\"," |
2669 " \"paused\": false," | 2760 " \"paused\": false," |
2761 " \"finalUrl\": \"%s\"," | |
2670 " \"url\": \"%s\"}]", | 2762 " \"url\": \"%s\"}]", |
2671 result_id, | 2763 result_id, |
2764 download_url.c_str(), | |
2672 download_url.c_str()))); | 2765 download_url.c_str()))); |
2673 ASSERT_TRUE(WaitFor( | 2766 ASSERT_TRUE(WaitFor( |
2674 downloads::OnDeterminingFilename::kEventName, | 2767 downloads::OnDeterminingFilename::kEventName, |
2675 base::StringPrintf("[{\"id\": %d," | 2768 base::StringPrintf("[{\"id\": %d," |
2676 " \"filename\":\"slow.txt\"}]", | 2769 " \"filename\":\"slow.txt\"}]", |
2677 result_id))); | 2770 result_id))); |
2678 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2771 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2679 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2772 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2680 | 2773 |
2681 // Respond to the onDeterminingFilename. | 2774 // Respond to the onDeterminingFilename. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2739 ScopedCancellingItem canceller(item); | 2832 ScopedCancellingItem canceller(item); |
2740 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2833 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2741 | 2834 |
2742 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2835 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2743 base::StringPrintf( | 2836 base::StringPrintf( |
2744 "[{\"danger\": \"safe\"," | 2837 "[{\"danger\": \"safe\"," |
2745 " \"incognito\": false," | 2838 " \"incognito\": false," |
2746 " \"id\": %d," | 2839 " \"id\": %d," |
2747 " \"mime\": \"text/plain\"," | 2840 " \"mime\": \"text/plain\"," |
2748 " \"paused\": false," | 2841 " \"paused\": false," |
2842 " \"finalUrl\": \"%s\"," | |
2749 " \"url\": \"%s\"}]", | 2843 " \"url\": \"%s\"}]", |
2750 result_id, | 2844 result_id, |
2845 download_url.c_str(), | |
2751 download_url.c_str()))); | 2846 download_url.c_str()))); |
2752 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2847 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
2753 base::StringPrintf( | 2848 base::StringPrintf( |
2754 "[{\"id\": %d," | 2849 "[{\"id\": %d," |
2755 " \"filename\":\"slow.txt\"}]", | 2850 " \"filename\":\"slow.txt\"}]", |
2756 result_id))); | 2851 result_id))); |
2757 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2852 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2758 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2853 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2759 | 2854 |
2760 // Respond to the onDeterminingFilename. | 2855 // Respond to the onDeterminingFilename. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2817 ScopedCancellingItem canceller(item); | 2912 ScopedCancellingItem canceller(item); |
2818 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2913 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2819 | 2914 |
2820 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2915 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2821 base::StringPrintf( | 2916 base::StringPrintf( |
2822 "[{\"danger\": \"safe\"," | 2917 "[{\"danger\": \"safe\"," |
2823 " \"incognito\": false," | 2918 " \"incognito\": false," |
2824 " \"id\": %d," | 2919 " \"id\": %d," |
2825 " \"mime\": \"text/plain\"," | 2920 " \"mime\": \"text/plain\"," |
2826 " \"paused\": false," | 2921 " \"paused\": false," |
2922 " \"finalUrl\": \"%s\"," | |
2827 " \"url\": \"%s\"}]", | 2923 " \"url\": \"%s\"}]", |
2828 result_id, | 2924 result_id, |
2925 download_url.c_str(), | |
2829 download_url.c_str()))); | 2926 download_url.c_str()))); |
2830 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2927 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
2831 base::StringPrintf( | 2928 base::StringPrintf( |
2832 "[{\"id\": %d," | 2929 "[{\"id\": %d," |
2833 " \"filename\":\"slow.txt\"}]", | 2930 " \"filename\":\"slow.txt\"}]", |
2834 result_id))); | 2931 result_id))); |
2835 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 2932 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2836 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 2933 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2837 | 2934 |
2838 // Respond to the onDeterminingFilename. | 2935 // Respond to the onDeterminingFilename. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2883 ScopedCancellingItem canceller(item); | 2980 ScopedCancellingItem canceller(item); |
2884 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2981 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2885 | 2982 |
2886 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 2983 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2887 base::StringPrintf( | 2984 base::StringPrintf( |
2888 "[{\"danger\": \"safe\"," | 2985 "[{\"danger\": \"safe\"," |
2889 " \"incognito\": false," | 2986 " \"incognito\": false," |
2890 " \"id\": %d," | 2987 " \"id\": %d," |
2891 " \"mime\": \"text/plain\"," | 2988 " \"mime\": \"text/plain\"," |
2892 " \"paused\": false," | 2989 " \"paused\": false," |
2990 " \"finalUrl\": \"%s\"," | |
2893 " \"url\": \"%s\"}]", | 2991 " \"url\": \"%s\"}]", |
2894 result_id, | 2992 result_id, |
2993 download_url.c_str(), | |
2895 download_url.c_str()))); | 2994 download_url.c_str()))); |
2896 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 2995 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
2897 base::StringPrintf( | 2996 base::StringPrintf( |
2898 "[{\"id\": %d," | 2997 "[{\"id\": %d," |
2899 " \"filename\":\"slow.txt\"}]", | 2998 " \"filename\":\"slow.txt\"}]", |
2900 result_id))); | 2999 result_id))); |
2901 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3000 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2902 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3001 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2903 | 3002 |
2904 // Respond to the onDeterminingFilename. | 3003 // Respond to the onDeterminingFilename. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2949 ScopedCancellingItem canceller(item); | 3048 ScopedCancellingItem canceller(item); |
2950 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3049 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
2951 | 3050 |
2952 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3051 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
2953 base::StringPrintf( | 3052 base::StringPrintf( |
2954 "[{\"danger\": \"safe\"," | 3053 "[{\"danger\": \"safe\"," |
2955 " \"incognito\": false," | 3054 " \"incognito\": false," |
2956 " \"id\": %d," | 3055 " \"id\": %d," |
2957 " \"mime\": \"text/plain\"," | 3056 " \"mime\": \"text/plain\"," |
2958 " \"paused\": false," | 3057 " \"paused\": false," |
3058 " \"finalUrl\": \"%s\"," | |
2959 " \"url\": \"%s\"}]", | 3059 " \"url\": \"%s\"}]", |
2960 result_id, | 3060 result_id, |
3061 download_url.c_str(), | |
2961 download_url.c_str()))); | 3062 download_url.c_str()))); |
2962 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3063 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
2963 base::StringPrintf( | 3064 base::StringPrintf( |
2964 "[{\"id\": %d," | 3065 "[{\"id\": %d," |
2965 " \"filename\":\"slow.txt\"}]", | 3066 " \"filename\":\"slow.txt\"}]", |
2966 result_id))); | 3067 result_id))); |
2967 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3068 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
2968 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3069 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
2969 | 3070 |
2970 // Respond to the onDeterminingFilename. | 3071 // Respond to the onDeterminingFilename. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3022 ScopedCancellingItem canceller(item); | 3123 ScopedCancellingItem canceller(item); |
3023 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3124 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3024 | 3125 |
3025 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3126 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3026 base::StringPrintf( | 3127 base::StringPrintf( |
3027 "[{\"danger\": \"safe\"," | 3128 "[{\"danger\": \"safe\"," |
3028 " \"incognito\": false," | 3129 " \"incognito\": false," |
3029 " \"id\": %d," | 3130 " \"id\": %d," |
3030 " \"mime\": \"text/plain\"," | 3131 " \"mime\": \"text/plain\"," |
3031 " \"paused\": false," | 3132 " \"paused\": false," |
3133 " \"finalUrl\": \"%s\"," | |
3032 " \"url\": \"%s\"}]", | 3134 " \"url\": \"%s\"}]", |
3033 result_id, | 3135 result_id, |
3136 download_url.c_str(), | |
3034 download_url.c_str()))); | 3137 download_url.c_str()))); |
3035 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3138 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3036 base::StringPrintf( | 3139 base::StringPrintf( |
3037 "[{\"id\": %d," | 3140 "[{\"id\": %d," |
3038 " \"filename\":\"slow.txt\"}]", | 3141 " \"filename\":\"slow.txt\"}]", |
3039 result_id))); | 3142 result_id))); |
3040 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3143 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3041 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3144 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3042 | 3145 |
3043 // Respond to the onDeterminingFilename. | 3146 // Respond to the onDeterminingFilename. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3088 ScopedCancellingItem canceller(item); | 3191 ScopedCancellingItem canceller(item); |
3089 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3192 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3090 | 3193 |
3091 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3194 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3092 base::StringPrintf( | 3195 base::StringPrintf( |
3093 "[{\"danger\": \"safe\"," | 3196 "[{\"danger\": \"safe\"," |
3094 " \"incognito\": false," | 3197 " \"incognito\": false," |
3095 " \"id\": %d," | 3198 " \"id\": %d," |
3096 " \"mime\": \"text/plain\"," | 3199 " \"mime\": \"text/plain\"," |
3097 " \"paused\": false," | 3200 " \"paused\": false," |
3201 " \"finalUrl\": \"%s\"," | |
3098 " \"url\": \"%s\"}]", | 3202 " \"url\": \"%s\"}]", |
3099 result_id, | 3203 result_id, |
3204 download_url.c_str(), | |
3100 download_url.c_str()))); | 3205 download_url.c_str()))); |
3101 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3206 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3102 base::StringPrintf( | 3207 base::StringPrintf( |
3103 "[{\"id\": %d," | 3208 "[{\"id\": %d," |
3104 " \"filename\":\"slow.txt\"}]", | 3209 " \"filename\":\"slow.txt\"}]", |
3105 result_id))); | 3210 result_id))); |
3106 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3211 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3107 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3212 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3108 | 3213 |
3109 // Respond to the onDeterminingFilename. | 3214 // Respond to the onDeterminingFilename. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3154 ScopedCancellingItem canceller(item); | 3259 ScopedCancellingItem canceller(item); |
3155 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3260 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3156 | 3261 |
3157 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3262 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3158 base::StringPrintf( | 3263 base::StringPrintf( |
3159 "[{\"danger\": \"safe\"," | 3264 "[{\"danger\": \"safe\"," |
3160 " \"incognito\": false," | 3265 " \"incognito\": false," |
3161 " \"id\": %d," | 3266 " \"id\": %d," |
3162 " \"mime\": \"text/plain\"," | 3267 " \"mime\": \"text/plain\"," |
3163 " \"paused\": false," | 3268 " \"paused\": false," |
3269 " \"finalUrl\": \"%s\"," | |
3164 " \"url\": \"%s\"}]", | 3270 " \"url\": \"%s\"}]", |
3165 result_id, | 3271 result_id, |
3272 download_url.c_str(), | |
3166 download_url.c_str()))); | 3273 download_url.c_str()))); |
3167 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3274 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3168 base::StringPrintf( | 3275 base::StringPrintf( |
3169 "[{\"id\": %d," | 3276 "[{\"id\": %d," |
3170 " \"filename\":\"slow.txt\"}]", | 3277 " \"filename\":\"slow.txt\"}]", |
3171 result_id))); | 3278 result_id))); |
3172 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3279 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3173 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3280 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3174 | 3281 |
3175 // Respond to the onDeterminingFilename. | 3282 // Respond to the onDeterminingFilename. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3220 ScopedCancellingItem canceller(item); | 3327 ScopedCancellingItem canceller(item); |
3221 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3328 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3222 | 3329 |
3223 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3330 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3224 base::StringPrintf( | 3331 base::StringPrintf( |
3225 "[{\"danger\": \"safe\"," | 3332 "[{\"danger\": \"safe\"," |
3226 " \"incognito\": false," | 3333 " \"incognito\": false," |
3227 " \"id\": %d," | 3334 " \"id\": %d," |
3228 " \"mime\": \"text/plain\"," | 3335 " \"mime\": \"text/plain\"," |
3229 " \"paused\": false," | 3336 " \"paused\": false," |
3337 " \"finalUrl\": \"%s\"," | |
3230 " \"url\": \"%s\"}]", | 3338 " \"url\": \"%s\"}]", |
3231 result_id, | 3339 result_id, |
3340 download_url.c_str(), | |
3232 download_url.c_str()))); | 3341 download_url.c_str()))); |
3233 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3342 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3234 base::StringPrintf( | 3343 base::StringPrintf( |
3235 "[{\"id\": %d," | 3344 "[{\"id\": %d," |
3236 " \"filename\":\"slow.txt\"}]", | 3345 " \"filename\":\"slow.txt\"}]", |
3237 result_id))); | 3346 result_id))); |
3238 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3347 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3239 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3348 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3240 | 3349 |
3241 // Respond to the onDeterminingFilename. Absolute paths should be rejected. | 3350 // Respond to the onDeterminingFilename. Absolute paths should be rejected. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3287 ScopedCancellingItem canceller(item); | 3396 ScopedCancellingItem canceller(item); |
3288 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3397 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3289 | 3398 |
3290 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3399 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3291 base::StringPrintf( | 3400 base::StringPrintf( |
3292 "[{\"danger\": \"safe\"," | 3401 "[{\"danger\": \"safe\"," |
3293 " \"incognito\": false," | 3402 " \"incognito\": false," |
3294 " \"id\": %d," | 3403 " \"id\": %d," |
3295 " \"mime\": \"text/plain\"," | 3404 " \"mime\": \"text/plain\"," |
3296 " \"paused\": false," | 3405 " \"paused\": false," |
3406 " \"finalUrl\": \"%s\"," | |
3297 " \"url\": \"%s\"}]", | 3407 " \"url\": \"%s\"}]", |
3298 result_id, | 3408 result_id, |
3409 download_url.c_str(), | |
3299 download_url.c_str()))); | 3410 download_url.c_str()))); |
3300 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3411 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3301 base::StringPrintf( | 3412 base::StringPrintf( |
3302 "[{\"id\": %d," | 3413 "[{\"id\": %d," |
3303 " \"filename\":\"slow.txt\"}]", | 3414 " \"filename\":\"slow.txt\"}]", |
3304 result_id))); | 3415 result_id))); |
3305 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3416 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3306 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3417 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3307 | 3418 |
3308 // Respond to the onDeterminingFilename. Empty basenames should be rejected. | 3419 // Respond to the onDeterminingFilename. Empty basenames should be rejected. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3354 ASSERT_TRUE(item); | 3465 ASSERT_TRUE(item); |
3355 ScopedCancellingItem canceller(item); | 3466 ScopedCancellingItem canceller(item); |
3356 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3467 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3357 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3468 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3358 base::StringPrintf( | 3469 base::StringPrintf( |
3359 "[{\"danger\": \"safe\"," | 3470 "[{\"danger\": \"safe\"," |
3360 " \"incognito\": false," | 3471 " \"incognito\": false," |
3361 " \"id\": %d," | 3472 " \"id\": %d," |
3362 " \"mime\": \"text/plain\"," | 3473 " \"mime\": \"text/plain\"," |
3363 " \"paused\": false," | 3474 " \"paused\": false," |
3475 " \"finalUrl\": \"%s\"," | |
3364 " \"url\": \"%s\"}]", | 3476 " \"url\": \"%s\"}]", |
3365 result_id, | 3477 result_id, |
3478 download_url.c_str(), | |
3366 download_url.c_str()))); | 3479 download_url.c_str()))); |
3367 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3480 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3368 base::StringPrintf( | 3481 base::StringPrintf( |
3369 "[{\"id\": %d," | 3482 "[{\"id\": %d," |
3370 " \"filename\":\"slow.txt\"}]", | 3483 " \"filename\":\"slow.txt\"}]", |
3371 result_id))); | 3484 result_id))); |
3372 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3485 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3373 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3486 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3374 | 3487 |
3375 // Respond to the onDeterminingFilename. | 3488 // Respond to the onDeterminingFilename. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3411 ScopedCancellingItem canceller2(item); | 3524 ScopedCancellingItem canceller2(item); |
3412 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3525 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3413 | 3526 |
3414 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3527 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3415 base::StringPrintf( | 3528 base::StringPrintf( |
3416 "[{\"danger\": \"safe\"," | 3529 "[{\"danger\": \"safe\"," |
3417 " \"incognito\": false," | 3530 " \"incognito\": false," |
3418 " \"id\": %d," | 3531 " \"id\": %d," |
3419 " \"mime\": \"text/plain\"," | 3532 " \"mime\": \"text/plain\"," |
3420 " \"paused\": false," | 3533 " \"paused\": false," |
3534 " \"finalUrl\": \"%s\"," | |
3421 " \"url\": \"%s\"}]", | 3535 " \"url\": \"%s\"}]", |
3422 result_id, | 3536 result_id, |
3537 download_url.c_str(), | |
3423 download_url.c_str()))); | 3538 download_url.c_str()))); |
3424 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3539 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3425 base::StringPrintf( | 3540 base::StringPrintf( |
3426 "[{\"id\": %d," | 3541 "[{\"id\": %d," |
3427 " \"filename\":\"slow.txt\"}]", | 3542 " \"filename\":\"slow.txt\"}]", |
3428 result_id))); | 3543 result_id))); |
3429 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3544 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3430 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3545 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3431 | 3546 |
3432 // Respond to the onDeterminingFilename. | 3547 // Respond to the onDeterminingFilename. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3480 ASSERT_TRUE(item); | 3595 ASSERT_TRUE(item); |
3481 ScopedCancellingItem canceller(item); | 3596 ScopedCancellingItem canceller(item); |
3482 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3597 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3483 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3598 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3484 base::StringPrintf( | 3599 base::StringPrintf( |
3485 "[{\"danger\": \"safe\"," | 3600 "[{\"danger\": \"safe\"," |
3486 " \"incognito\": false," | 3601 " \"incognito\": false," |
3487 " \"id\": %d," | 3602 " \"id\": %d," |
3488 " \"mime\": \"text/plain\"," | 3603 " \"mime\": \"text/plain\"," |
3489 " \"paused\": false," | 3604 " \"paused\": false," |
3605 " \"finalUrl\": \"%s\"," | |
3490 " \"url\": \"%s\"}]", | 3606 " \"url\": \"%s\"}]", |
3491 result_id, | 3607 result_id, |
3608 download_url.c_str(), | |
3492 download_url.c_str()))); | 3609 download_url.c_str()))); |
3493 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3610 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3494 base::StringPrintf( | 3611 base::StringPrintf( |
3495 "[{\"id\": %d," | 3612 "[{\"id\": %d," |
3496 " \"filename\":\"slow.txt\"}]", | 3613 " \"filename\":\"slow.txt\"}]", |
3497 result_id))); | 3614 result_id))); |
3498 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3615 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3499 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3616 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3500 | 3617 |
3501 // Respond to the onDeterminingFilename. | 3618 // Respond to the onDeterminingFilename. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3537 ScopedCancellingItem canceller2(item); | 3654 ScopedCancellingItem canceller2(item); |
3538 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3655 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3539 | 3656 |
3540 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3657 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3541 base::StringPrintf( | 3658 base::StringPrintf( |
3542 "[{\"danger\": \"safe\"," | 3659 "[{\"danger\": \"safe\"," |
3543 " \"incognito\": false," | 3660 " \"incognito\": false," |
3544 " \"id\": %d," | 3661 " \"id\": %d," |
3545 " \"mime\": \"text/plain\"," | 3662 " \"mime\": \"text/plain\"," |
3546 " \"paused\": false," | 3663 " \"paused\": false," |
3664 " \"finalUrl\": \"%s\"," | |
3547 " \"url\": \"%s\"}]", | 3665 " \"url\": \"%s\"}]", |
3548 result_id, | 3666 result_id, |
3667 download_url.c_str(), | |
3549 download_url.c_str()))); | 3668 download_url.c_str()))); |
3550 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3669 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3551 base::StringPrintf( | 3670 base::StringPrintf( |
3552 "[{\"id\": %d," | 3671 "[{\"id\": %d," |
3553 " \"filename\":\"slow.txt\"}]", | 3672 " \"filename\":\"slow.txt\"}]", |
3554 result_id))); | 3673 result_id))); |
3555 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3674 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3556 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3675 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3557 | 3676 |
3558 // Respond to the onDeterminingFilename. | 3677 // Respond to the onDeterminingFilename. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3617 ScopedCancellingItem canceller(item); | 3736 ScopedCancellingItem canceller(item); |
3618 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3737 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3619 | 3738 |
3620 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3739 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3621 base::StringPrintf( | 3740 base::StringPrintf( |
3622 "[{\"danger\": \"safe\"," | 3741 "[{\"danger\": \"safe\"," |
3623 " \"incognito\": false," | 3742 " \"incognito\": false," |
3624 " \"id\": %d," | 3743 " \"id\": %d," |
3625 " \"mime\": \"text/plain\"," | 3744 " \"mime\": \"text/plain\"," |
3626 " \"paused\": false," | 3745 " \"paused\": false," |
3746 " \"finalUrl\": \"%s\"," | |
3627 " \"url\": \"%s\"}]", | 3747 " \"url\": \"%s\"}]", |
3628 result_id, | 3748 result_id, |
3749 download_url.c_str(), | |
3629 download_url.c_str()))); | 3750 download_url.c_str()))); |
3630 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3751 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3631 base::StringPrintf( | 3752 base::StringPrintf( |
3632 "[{\"id\": %d," | 3753 "[{\"id\": %d," |
3633 " \"filename\":\"slow.txt\"}]", | 3754 " \"filename\":\"slow.txt\"}]", |
3634 result_id))); | 3755 result_id))); |
3635 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3756 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3636 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3757 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3637 | 3758 |
3638 // Remove a determiner while waiting for it. | 3759 // Remove a determiner while waiting for it. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3674 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3795 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3675 | 3796 |
3676 // Wait for the onCreated and onDeterminingFilename events. | 3797 // Wait for the onCreated and onDeterminingFilename events. |
3677 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3798 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3678 base::StringPrintf( | 3799 base::StringPrintf( |
3679 "[{\"danger\": \"safe\"," | 3800 "[{\"danger\": \"safe\"," |
3680 " \"incognito\": false," | 3801 " \"incognito\": false," |
3681 " \"id\": %d," | 3802 " \"id\": %d," |
3682 " \"mime\": \"text/plain\"," | 3803 " \"mime\": \"text/plain\"," |
3683 " \"paused\": false," | 3804 " \"paused\": false," |
3805 " \"finalUrl\": \"%s\"," | |
3684 " \"url\": \"%s\"}]", | 3806 " \"url\": \"%s\"}]", |
3685 result_id, | 3807 result_id, |
3808 download_url.c_str(), | |
3686 download_url.c_str()))); | 3809 download_url.c_str()))); |
3687 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3810 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3688 base::StringPrintf( | 3811 base::StringPrintf( |
3689 "[{\"id\": %d," | 3812 "[{\"id\": %d," |
3690 " \"incognito\": false," | 3813 " \"incognito\": false," |
3691 " \"filename\":\"slow.txt\"}]", | 3814 " \"filename\":\"slow.txt\"}]", |
3692 result_id))); | 3815 result_id))); |
3693 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3816 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3694 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3817 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3695 | 3818 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3735 ScopedCancellingItem canceller2(item); | 3858 ScopedCancellingItem canceller2(item); |
3736 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3859 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3737 | 3860 |
3738 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3861 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3739 base::StringPrintf( | 3862 base::StringPrintf( |
3740 "[{\"danger\": \"safe\"," | 3863 "[{\"danger\": \"safe\"," |
3741 " \"incognito\": true," | 3864 " \"incognito\": true," |
3742 " \"id\": %d," | 3865 " \"id\": %d," |
3743 " \"mime\": \"text/plain\"," | 3866 " \"mime\": \"text/plain\"," |
3744 " \"paused\": false," | 3867 " \"paused\": false," |
3868 " \"finalUrl\": \"%s\"," | |
3745 " \"url\": \"%s\"}]", | 3869 " \"url\": \"%s\"}]", |
3746 result_id, | 3870 result_id, |
3871 download_url.c_str(), | |
3747 download_url.c_str()))); | 3872 download_url.c_str()))); |
3748 // On-Record renderers should not see events for off-record items. | 3873 // On-Record renderers should not see events for off-record items. |
3749 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3874 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3750 base::StringPrintf( | 3875 base::StringPrintf( |
3751 "[{\"id\": %d," | 3876 "[{\"id\": %d," |
3752 " \"incognito\": true," | 3877 " \"incognito\": true," |
3753 " \"filename\":\"slow.txt\"}]", | 3878 " \"filename\":\"slow.txt\"}]", |
3754 result_id))); | 3879 result_id))); |
3755 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3880 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3756 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3881 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3813 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 3938 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3814 | 3939 |
3815 // Wait for the onCreated and onDeterminingFilename events. | 3940 // Wait for the onCreated and onDeterminingFilename events. |
3816 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 3941 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3817 base::StringPrintf( | 3942 base::StringPrintf( |
3818 "[{\"danger\": \"safe\"," | 3943 "[{\"danger\": \"safe\"," |
3819 " \"incognito\": false," | 3944 " \"incognito\": false," |
3820 " \"id\": %d," | 3945 " \"id\": %d," |
3821 " \"mime\": \"text/plain\"," | 3946 " \"mime\": \"text/plain\"," |
3822 " \"paused\": false," | 3947 " \"paused\": false," |
3948 " \"finalUrl\": \"%s\"," | |
3823 " \"url\": \"%s\"}]", | 3949 " \"url\": \"%s\"}]", |
3824 result_id, | 3950 result_id, |
3951 download_url.c_str(), | |
3825 download_url.c_str()))); | 3952 download_url.c_str()))); |
3826 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 3953 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3827 base::StringPrintf( | 3954 base::StringPrintf( |
3828 "[{\"id\": %d," | 3955 "[{\"id\": %d," |
3829 " \"incognito\": false," | 3956 " \"incognito\": false," |
3830 " \"filename\":\"slow.txt\"}]", | 3957 " \"filename\":\"slow.txt\"}]", |
3831 result_id))); | 3958 result_id))); |
3832 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 3959 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3833 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 3960 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3834 | 3961 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3874 ScopedCancellingItem canceller2(item); | 4001 ScopedCancellingItem canceller2(item); |
3875 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 4002 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
3876 | 4003 |
3877 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, | 4004 ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName, |
3878 base::StringPrintf( | 4005 base::StringPrintf( |
3879 "[{\"danger\": \"safe\"," | 4006 "[{\"danger\": \"safe\"," |
3880 " \"incognito\": true," | 4007 " \"incognito\": true," |
3881 " \"id\": %d," | 4008 " \"id\": %d," |
3882 " \"mime\": \"text/plain\"," | 4009 " \"mime\": \"text/plain\"," |
3883 " \"paused\": false," | 4010 " \"paused\": false," |
4011 " \"finalUrl\": \"%s\"," | |
3884 " \"url\": \"%s\"}]", | 4012 " \"url\": \"%s\"}]", |
3885 result_id, | 4013 result_id, |
4014 download_url.c_str(), | |
3886 download_url.c_str()))); | 4015 download_url.c_str()))); |
3887 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, | 4016 ASSERT_TRUE(WaitFor(downloads::OnDeterminingFilename::kEventName, |
3888 base::StringPrintf( | 4017 base::StringPrintf( |
3889 "[{\"id\": %d," | 4018 "[{\"id\": %d," |
3890 " \"incognito\": true," | 4019 " \"incognito\": true," |
3891 " \"filename\":\"slow.txt\"}]", | 4020 " \"filename\":\"slow.txt\"}]", |
3892 result_id))); | 4021 result_id))); |
3893 ASSERT_TRUE(item->GetTargetFilePath().empty()); | 4022 ASSERT_TRUE(item->GetTargetFilePath().empty()); |
3894 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); | 4023 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); |
3895 | 4024 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4228 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 4357 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
4229 EXPECT_FALSE(warnings.empty()); | 4358 EXPECT_FALSE(warnings.empty()); |
4230 EXPECT_EQ(Warning::kDownloadFilenameConflict, | 4359 EXPECT_EQ(Warning::kDownloadFilenameConflict, |
4231 warnings.begin()->warning_type()); | 4360 warnings.begin()->warning_type()); |
4232 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 4361 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
4233 } | 4362 } |
4234 | 4363 |
4235 } // namespace extensions | 4364 } // namespace extensions |
4236 | 4365 |
4237 #endif // http://crbug.com/306144 | 4366 #endif // http://crbug.com/306144 |
OLD | NEW |