Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_blob_channelname.js
blobc1a09272da2ef5fe0eb7dd1d0dae979ec0c1e256
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 add_task(async function channelname() {
5 var file = new File(
6 [new Blob(["test"], { type: "text/plain" })],
7 "test-name"
8 );
9 var url = URL.createObjectURL(file);
10 var channel = NetUtil.newChannel({
11 uri: url,
12 loadUsingSystemPrincipal: true,
13 });
15 let inputStream = channel.open();
16 ok(inputStream, "Should be able to open channel");
17 ok(
18 inputStream.QueryInterface(Ci.nsIAsyncInputStream),
19 "Stream should support async operations"
22 await new Promise(resolve => {
23 inputStream.asyncWait(
24 () => {
25 let available = inputStream.available();
26 ok(available, "There should be data to read");
27 Assert.equal(
28 channel.contentDispositionFilename,
29 "test-name",
30 "filename matches"
32 resolve();
36 Services.tm.mainThread
38 });
40 inputStream.close();
41 channel.cancel(Cr.NS_ERROR_FAILURE);
42 });