netwerk/test/unit/test_bug263127.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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.)

     1 Cu.import("resource://testing-common/httpd.js");
     3 var server;
     4 const BUGID = "263127";
     6 var listener = {
     7   QueryInterface: function(iid) {
     8     if (!iid.equals(nsIDownloadObserver) &&
     9         !iid.equals(nsISupports))
    10       throw Components.results.NS_ERROR_NO_INTERFACE;
    12     return this;
    13   },
    15   onDownloadComplete: function(downloader, request, ctxt, status, file) {
    16     do_test_pending();
    17     server.stop(do_test_finished);
    19     if (!file)
    20       do_throw("Download failed");
    22     try {
    23       file.remove(false);
    24     }
    25     catch (e) {
    26       do_throw(e);
    27     }
    29     do_check_false(file.exists());
    31     do_test_finished();
    32   }
    33 }
    35 function run_test() {
    36   // start server
    37   server = new HttpServer();
    38   server.start(-1);
    40   // Initialize downloader
    41   var channel = Cc["@mozilla.org/network/io-service;1"]
    42                   .getService(Ci.nsIIOService)
    43                   .newChannel("http://localhost:" +
    44                               server.identity.primaryPort + "/", null, null);
    46   var targetFile = Cc["@mozilla.org/file/directory_service;1"]
    47                      .getService(Ci.nsIProperties)
    48                      .get("TmpD", Ci.nsIFile);
    49   targetFile.append("bug" + BUGID + ".test");
    50   if (targetFile.exists())
    51     targetFile.remove(false);
    53   var downloader = Cc["@mozilla.org/network/downloader;1"]
    54                      .createInstance(Ci.nsIDownloader);
    55   downloader.init(listener, targetFile);
    57   // Start download
    58   channel.asyncOpen(downloader, null);
    60   do_test_pending();
    61 }

mercurial