| 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 // downloads api test | 5 // downloads api test |
| 6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads | 6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads |
| 7 | 7 |
| 8 // Comment this out to enable debugging. | 8 // Comment this out to enable debugging. |
| 9 console.debug = function() {}; | 9 console.debug = function() {}; |
| 10 | 10 |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 // Valid file URLs are valid URLs. | 715 // Valid file URLs are valid URLs. |
| 716 var downloadId = getNextId(); | 716 var downloadId = getNextId(); |
| 717 console.debug(downloadId); | 717 console.debug(downloadId); |
| 718 downloads.download( | 718 downloads.download( |
| 719 {'url': 'file:///'}, | 719 {'url': 'file:///'}, |
| 720 chrome.test.callback(function(id) { | 720 chrome.test.callback(function(id) { |
| 721 chrome.test.assertEq(downloadId, id); | 721 chrome.test.assertEq(downloadId, id); |
| 722 })); | 722 })); |
| 723 }, | 723 }, |
| 724 | 724 |
| 725 // TODO(benjhayden): Set up a test ftp server. | 725 function downloadInvalidURL7() { |
| 726 // Test that download() rejects javascript urls. |
| 727 downloads.download( |
| 728 {'url': 'javascript:document.write("hello");'}, |
| 729 chrome.test.callbackFail(downloads.ERROR_INVALID_URL)); |
| 730 }, |
| 731 |
| 732 function downloadInvalidURL8() { |
| 733 // Test that download() rejects javascript urls. |
| 734 downloads.download( |
| 735 {'url': 'javascript:return false;'}, |
| 736 chrome.test.callbackFail(downloads.ERROR_INVALID_URL)); |
| 737 }, |
| 738 |
| 739 function downloadInvalidURL9() { |
| 740 // Test that download() rejects otherwise-valid URLs that fail the host |
| 741 // permissions check. |
| 742 downloads.download( |
| 743 {'url': 'ftp://example.com/example.txt'}, |
| 744 chrome.test.callbackFail(downloads.ERROR_INVALID_URL)); |
| 745 }, |
| 746 |
| 747 // TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to |
| 748 // permissions, maybe update downloadInvalidURL9. |
| 726 // function downloadAllowFTPURLs() { | 749 // function downloadAllowFTPURLs() { |
| 727 // // Valid ftp URLs are valid URLs. | 750 // // Valid ftp URLs are valid URLs. |
| 728 // var downloadId = getNextId(); | 751 // var downloadId = getNextId(); |
| 729 // console.debug(downloadId); | 752 // console.debug(downloadId); |
| 730 // downloads.download( | 753 // downloads.download( |
| 731 // {'url': 'ftp://localhost:' + testConfig.testServer.port + '/'}, | 754 // {'url': 'ftp://localhost:' + testConfig.testServer.port + '/'}, |
| 732 // chrome.test.callback(function(id) { | 755 // chrome.test.callback(function(id) { |
| 733 // chrome.test.assertEq(downloadId, id); | 756 // chrome.test.assertEq(downloadId, id); |
| 734 // })); | 757 // })); |
| 735 // }, | 758 // }, |
| 736 | 759 |
| 737 function downloadInvalidURL7() { | |
| 738 // Test that download() rejects javascript urls. | |
| 739 downloads.download( | |
| 740 {'url': 'javascript:document.write("hello");'}, | |
| 741 chrome.test.callbackFail('net::ERR_ACCESS_DENIED')); | |
| 742 }, | |
| 743 | |
| 744 function downloadInvalidURL8() { | |
| 745 // Test that download() rejects javascript urls. | |
| 746 downloads.download( | |
| 747 {'url': 'javascript:return false;'}, | |
| 748 chrome.test.callbackFail('net::ERR_ACCESS_DENIED')); | |
| 749 }, | |
| 750 | |
| 751 function downloadInvalidMethod() { | 760 function downloadInvalidMethod() { |
| 752 assertThrows(('Invalid value for argument 1. Property \'method\': ' + | 761 assertThrows(('Invalid value for argument 1. Property \'method\': ' + |
| 753 'Value must be one of: [GET, POST].'), | 762 'Value must be one of: [GET, POST].'), |
| 754 downloads.download, | 763 downloads.download, |
| 755 {'url': SAFE_FAST_URL, 'method': 'GOAT'}); | 764 {'url': SAFE_FAST_URL, 'method': 'GOAT'}); |
| 756 }, | 765 }, |
| 757 | 766 |
| 758 function downloadInvalidHeader() { | 767 function downloadInvalidHeader() { |
| 759 // Test that download() disallows setting the Cookie header. | 768 // Test that download() disallows setting the Cookie header. |
| 760 downloads.download( | 769 downloads.download( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 }, | 858 }, |
| 850 | 859 |
| 851 function callNotifyPass() { | 860 function callNotifyPass() { |
| 852 chrome.test.notifyPass(); | 861 chrome.test.notifyPass(); |
| 853 setTimeout(chrome.test.callback(function() { | 862 setTimeout(chrome.test.callback(function() { |
| 854 console.debug(''); | 863 console.debug(''); |
| 855 }), 0); | 864 }), 0); |
| 856 } | 865 } |
| 857 ]); | 866 ]); |
| 858 }); | 867 }); |
| OLD | NEW |