Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 2 | |
michael@0 | 3 | var server; |
michael@0 | 4 | const BUGID = "263127"; |
michael@0 | 5 | |
michael@0 | 6 | var listener = { |
michael@0 | 7 | QueryInterface: function(iid) { |
michael@0 | 8 | if (!iid.equals(nsIDownloadObserver) && |
michael@0 | 9 | !iid.equals(nsISupports)) |
michael@0 | 10 | throw Components.results.NS_ERROR_NO_INTERFACE; |
michael@0 | 11 | |
michael@0 | 12 | return this; |
michael@0 | 13 | }, |
michael@0 | 14 | |
michael@0 | 15 | onDownloadComplete: function(downloader, request, ctxt, status, file) { |
michael@0 | 16 | do_test_pending(); |
michael@0 | 17 | server.stop(do_test_finished); |
michael@0 | 18 | |
michael@0 | 19 | if (!file) |
michael@0 | 20 | do_throw("Download failed"); |
michael@0 | 21 | |
michael@0 | 22 | try { |
michael@0 | 23 | file.remove(false); |
michael@0 | 24 | } |
michael@0 | 25 | catch (e) { |
michael@0 | 26 | do_throw(e); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | do_check_false(file.exists()); |
michael@0 | 30 | |
michael@0 | 31 | do_test_finished(); |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function run_test() { |
michael@0 | 36 | // start server |
michael@0 | 37 | server = new HttpServer(); |
michael@0 | 38 | server.start(-1); |
michael@0 | 39 | |
michael@0 | 40 | // Initialize downloader |
michael@0 | 41 | var channel = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 42 | .getService(Ci.nsIIOService) |
michael@0 | 43 | .newChannel("http://localhost:" + |
michael@0 | 44 | server.identity.primaryPort + "/", null, null); |
michael@0 | 45 | |
michael@0 | 46 | var targetFile = Cc["@mozilla.org/file/directory_service;1"] |
michael@0 | 47 | .getService(Ci.nsIProperties) |
michael@0 | 48 | .get("TmpD", Ci.nsIFile); |
michael@0 | 49 | targetFile.append("bug" + BUGID + ".test"); |
michael@0 | 50 | if (targetFile.exists()) |
michael@0 | 51 | targetFile.remove(false); |
michael@0 | 52 | |
michael@0 | 53 | var downloader = Cc["@mozilla.org/network/downloader;1"] |
michael@0 | 54 | .createInstance(Ci.nsIDownloader); |
michael@0 | 55 | downloader.init(listener, targetFile); |
michael@0 | 56 | |
michael@0 | 57 | // Start download |
michael@0 | 58 | channel.asyncOpen(downloader, null); |
michael@0 | 59 | |
michael@0 | 60 | do_test_pending(); |
michael@0 | 61 | } |