modules/libjar/test/unit/test_bug370103.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/test/unit/test_bug370103.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +var Cc = Components.classes;
     1.5 +var Ci = Components.interfaces;
     1.6 +
     1.7 +// Regression test for bug 370103 - crash when passing a null listener to
     1.8 +// nsIChannel.asyncOpen
     1.9 +function run_test() {
    1.10 +  // Compose the jar: url
    1.11 +  var ioService = Cc["@mozilla.org/network/io-service;1"].
    1.12 +                    getService(Ci.nsIIOService);
    1.13 +  var file = do_get_file("data/test_bug370103.jar");
    1.14 +  var url = ioService.newFileURI(file).spec;
    1.15 +  url = "jar:" + url + "!/test_bug370103";
    1.16 +
    1.17 +  // Try opening channel with null listener
    1.18 +  var channel = ioService.newChannel(url, null, null);
    1.19 +
    1.20 +  var exception = false;
    1.21 +  try {
    1.22 +    channel.asyncOpen(null, null);
    1.23 +  }
    1.24 +  catch(e) {
    1.25 +    exception = true;
    1.26 +  }
    1.27 +
    1.28 +  do_check_true(exception); // should throw exception instead of crashing
    1.29 +}

mercurial