From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- netwerk/test/unit/test_bug282432.js | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 netwerk/test/unit/test_bug282432.js (limited to 'netwerk/test/unit/test_bug282432.js') diff --git a/netwerk/test/unit/test_bug282432.js b/netwerk/test/unit/test_bug282432.js new file mode 100644 index 0000000000..7794408523 --- /dev/null +++ b/netwerk/test/unit/test_bug282432.js @@ -0,0 +1,38 @@ +"use strict"; + +function run_test() { + do_test_pending(); + + function StreamListener() {} + + StreamListener.prototype = { + QueryInterface: ChromeUtils.generateQI([ + "nsIStreamListener", + "nsIRequestObserver", + ]), + + onStartRequest(aRequest) {}, + + onStopRequest(aRequest, aStatusCode) { + // Make sure we can catch the error NS_ERROR_FILE_NOT_FOUND here. + Assert.equal(aStatusCode, Cr.NS_ERROR_FILE_NOT_FOUND); + do_test_finished(); + }, + + onDataAvailable(aRequest, aStream, aOffset, aCount) { + do_throw("The channel must not call onDataAvailable()."); + }, + }; + + let listener = new StreamListener(); + let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + + // This file does not exist. + let file = do_get_file("_NOT_EXIST_.txt", true); + Assert.ok(!file.exists()); + let channel = NetUtil.newChannel({ + uri: ios.newFileURI(file), + loadUsingSystemPrincipal: true, + }); + channel.asyncOpen(listener); +} -- cgit v1.2.3