From 449e73f1c7ec00731a0847e31fba7a728ad9d4cc Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 9 Sep 2022 18:22:36 +0000 Subject: [PATCH] Bug 1348272 - Mark nsIInputStream and nsIOutputStream as builtinclass, r=xpcom-reviewers,necko-reviewers,barret,valentin Differential Revision: https://phabricator.services.mozilla.com/D156893 --- dom/base/test/chrome/test_domparsing.xhtml | 14 +++++++++----- ...eToStringWithRequiresReinitAfterOutput.html | 18 ++++-------------- image/imgIEncoder.idl | 2 +- netwerk/base/nsIArrayBufferInputStream.idl | 2 +- netwerk/base/nsIBufferedStreams.idl | 4 ++-- netwerk/base/nsIFileStreams.idl | 10 +++++----- netwerk/base/nsIMIMEInputStream.idl | 2 +- .../test/test_async_response_sending.js | 10 ---------- xpcom/io/nsIAsyncInputStream.idl | 2 +- xpcom/io/nsIAsyncOutputStream.idl | 2 +- xpcom/io/nsIBinaryInputStream.idl | 2 +- xpcom/io/nsIConverterOutputStream.idl | 2 +- xpcom/io/nsIIOUtil.idl | 2 +- xpcom/io/nsIInputStream.idl | 2 +- xpcom/io/nsIInputStreamTee.idl | 2 +- xpcom/io/nsIOutputStream.idl | 2 +- 16 files changed, 31 insertions(+), 47 deletions(-) diff --git a/dom/base/test/chrome/test_domparsing.xhtml b/dom/base/test/chrome/test_domparsing.xhtml index 205fa0ab98c9..94d99608ea19 100644 --- a/dom/base/test/chrome/test_domparsing.xhtml +++ b/dom/base/test/chrome/test_domparsing.xhtml @@ -67,13 +67,17 @@ function runTest(parser, serializer) { is(serializer.serializeToString(parser.parseFromString(t.input, t.type)), t.expected, "parseFromString test for " + t.type); - let ostream = { - write: function(buf, count) { this.data += buf; return count; } - }; for (let charset of [null, "UTF-8"]) { - ostream.data = ""; + let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe); + pipe.init(false, false, 0, 0xffffffff, null); + let ostream = pipe.outputStream; serializer.serializeToStream(parser.parseFromString(t.input, t.type), ostream, charset); - is(ostream.data, t.expected, + let istream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance( + Ci.nsIScriptableInputStream + ); + istream.init(pipe.inputStream); + let data = istream.read(0xffffffff); + is(data, t.expected, "serializeToStream test for " + t.type + ", charset=" + charset); } diff --git a/dom/base/test/test_encodeToStringWithRequiresReinitAfterOutput.html b/dom/base/test/test_encodeToStringWithRequiresReinitAfterOutput.html index 793b3f9ca230..a1d2749ef813 100644 --- a/dom/base/test/test_encodeToStringWithRequiresReinitAfterOutput.html +++ b/dom/base/test/test_encodeToStringWithRequiresReinitAfterOutput.html @@ -44,21 +44,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1352882 ok(str, "encodingToStringWithMaxLength should be successful after calling init again"); encoder = getEncoder(); - var stream = { - close() { - }, - flush() { - }, - - write(buffer, length) { - return length; - }, - - writeFrom(buffer, length) { - return length; - }, - }; + const UINT32_MAX = 4294967295; + let pipe = SpecialPowers.Cc["@mozilla.org/pipe;1"].createInstance(SpecialPowers.Ci.nsIPipe); + pipe.init(true, true, 0, UINT32_MAX, null); + let stream = pipe.outputStream; encoder.setCharset("utf-8"); encoder.encodeToStream(stream); diff --git a/image/imgIEncoder.idl b/image/imgIEncoder.idl index 0e38a08bebbc..c458b9cf4c8e 100644 --- a/image/imgIEncoder.idl +++ b/image/imgIEncoder.idl @@ -10,7 +10,7 @@ /** * imgIEncoder interface */ -[scriptable, uuid(4baa2d6e-fee7-42df-ae3f-5fbebc0c267c)] +[scriptable, builtinclass, uuid(4baa2d6e-fee7-42df-ae3f-5fbebc0c267c)] interface imgIEncoder : nsIAsyncInputStream { // Possible values for outputOptions. Multiple values are semicolon-separated. diff --git a/netwerk/base/nsIArrayBufferInputStream.idl b/netwerk/base/nsIArrayBufferInputStream.idl index 4eb0d36f4efc..1bf24d1d4b53 100644 --- a/netwerk/base/nsIArrayBufferInputStream.idl +++ b/netwerk/base/nsIArrayBufferInputStream.idl @@ -11,7 +11,7 @@ * Provides scriptable methods for initializing a nsIInputStream * implementation with an ArrayBuffer. */ -[scriptable, uuid(3014dde6-aa1c-41db-87d0-48764a3710f6)] +[scriptable, builtinclass, uuid(3014dde6-aa1c-41db-87d0-48764a3710f6)] interface nsIArrayBufferInputStream : nsIInputStream { /** diff --git a/netwerk/base/nsIBufferedStreams.idl b/netwerk/base/nsIBufferedStreams.idl index a9876c1d8fdd..46f011290083 100644 --- a/netwerk/base/nsIBufferedStreams.idl +++ b/netwerk/base/nsIBufferedStreams.idl @@ -9,7 +9,7 @@ * An input stream that reads ahead and keeps a buffer coming from another input * stream so that fewer accesses to the underlying stream are necessary. */ -[scriptable, uuid(616f5b48-da09-11d3-8cda-0060b0fc14a3)] +[scriptable, builtinclass, uuid(616f5b48-da09-11d3-8cda-0060b0fc14a3)] interface nsIBufferedInputStream : nsIInputStream { /** @@ -30,7 +30,7 @@ interface nsIBufferedInputStream : nsIInputStream * and does the entire write only when the buffer is full, so that fewer writes * to the underlying output stream are necessary. */ -[scriptable, uuid(6476378a-da09-11d3-8cda-0060b0fc14a3)] +[scriptable, builtinclass, uuid(6476378a-da09-11d3-8cda-0060b0fc14a3)] interface nsIBufferedOutputStream : nsIOutputStream { /** diff --git a/netwerk/base/nsIFileStreams.idl b/netwerk/base/nsIFileStreams.idl index 4b704493ea92..64df87cbf601 100644 --- a/netwerk/base/nsIFileStreams.idl +++ b/netwerk/base/nsIFileStreams.idl @@ -19,7 +19,7 @@ struct PRFileDesc; /** * An input stream that allows you to read from a file. */ -[scriptable, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)] +[scriptable, builtinclass, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)] interface nsIFileInputStream : nsIInputStream { /** @@ -85,7 +85,7 @@ interface nsIFileInputStream : nsIInputStream /** * An output stream that lets you stream to a file. */ -[scriptable, uuid(e734cac9-1295-4e6f-9684-3ac4e1f91063)] +[scriptable, builtinclass, uuid(e734cac9-1295-4e6f-9684-3ac4e1f91063)] interface nsIFileOutputStream : nsIOutputStream { /** @@ -132,7 +132,7 @@ interface nsIFileOutputStream : nsIOutputStream /** * A stream that allows you to read from a file or stream to a file. */ -[scriptable, uuid(82cf605a-8393-4550-83ab-43cd5578e006)] +[scriptable, builtinclass, uuid(82cf605a-8393-4550-83ab-43cd5578e006)] interface nsIFileStream : nsISupports { /** @@ -185,7 +185,7 @@ interface nsIFileStream : nsISupports * happen when using RemoteLazyInputStream with an underlying file stream, for * example. */ -[scriptable, uuid(07f679e4-9601-4bd1-b510-cd3852edb881)] +[scriptable, builtinclass, uuid(07f679e4-9601-4bd1-b510-cd3852edb881)] interface nsIFileMetadata : nsISupports { /** @@ -207,7 +207,7 @@ interface nsIFileMetadata : nsISupports [noscript] PRFileDescPtr getFileDescriptor(); }; -[scriptable, uuid(de15b80b-29ba-4b7f-9220-a3d75b17ae8c)] +[scriptable, builtinclass, uuid(de15b80b-29ba-4b7f-9220-a3d75b17ae8c)] interface nsIAsyncFileMetadata : nsIFileMetadata { /** diff --git a/netwerk/base/nsIMIMEInputStream.idl b/netwerk/base/nsIMIMEInputStream.idl index f3411beb1ac1..1842cdb40ce7 100644 --- a/netwerk/base/nsIMIMEInputStream.idl +++ b/netwerk/base/nsIMIMEInputStream.idl @@ -11,7 +11,7 @@ * automatic creation of the content-length header. */ -[scriptable, uuid(dcbce63c-1dd1-11b2-b94d-91f6d49a3161)] +[scriptable, builtinclass, uuid(dcbce63c-1dd1-11b2-b94d-91f6d49a3161)] interface nsIMIMEInputStream : nsIInputStream { /** diff --git a/netwerk/test/httpserver/test/test_async_response_sending.js b/netwerk/test/httpserver/test/test_async_response_sending.js index 710046a12dd9..b8e381a1a938 100644 --- a/netwerk/test/httpserver/test/test_async_response_sending.js +++ b/netwerk/test/httpserver/test/test_async_response_sending.js @@ -701,11 +701,6 @@ function CustomPipe(name) { waiter.eventTarget.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL); } }, - - QueryInterface: ChromeUtils.generateQI([ - "nsIAsyncInputStream", - "nsIInputStream", - ]), }); /** The output end of this pipe. */ @@ -1050,11 +1045,6 @@ function CustomPipe(name) { waiter.eventTarget.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL); } }, - - QueryInterface: ChromeUtils.generateQI([ - "nsIAsyncOutputStream", - "nsIOutputStream", - ]), }); } diff --git a/xpcom/io/nsIAsyncInputStream.idl b/xpcom/io/nsIAsyncInputStream.idl index 578ed763df33..8dbe44266326 100644 --- a/xpcom/io/nsIAsyncInputStream.idl +++ b/xpcom/io/nsIAsyncInputStream.idl @@ -19,7 +19,7 @@ interface nsIEventTarget; * necessary that a non-blocking nsIInputStream implementation also implement * nsIAsyncInputStream. */ -[scriptable, uuid(a5f255ab-4801-4161-8816-277ac92f6ad1)] +[scriptable, builtinclass, uuid(a5f255ab-4801-4161-8816-277ac92f6ad1)] interface nsIAsyncInputStream : nsIInputStream { /** diff --git a/xpcom/io/nsIAsyncOutputStream.idl b/xpcom/io/nsIAsyncOutputStream.idl index a76200c249ef..88f9d107cf8c 100644 --- a/xpcom/io/nsIAsyncOutputStream.idl +++ b/xpcom/io/nsIAsyncOutputStream.idl @@ -19,7 +19,7 @@ interface nsIEventTarget; * necessary that a non-blocking nsIOutputStream implementation also implement * nsIAsyncOutputStream. */ -[scriptable, uuid(beb632d3-d77a-4e90-9134-f9ece69e8200)] +[scriptable, builtinclass, uuid(beb632d3-d77a-4e90-9134-f9ece69e8200)] interface nsIAsyncOutputStream : nsIOutputStream { /** diff --git a/xpcom/io/nsIBinaryInputStream.idl b/xpcom/io/nsIBinaryInputStream.idl index 5c6678c92e07..698dbae4f8f4 100644 --- a/xpcom/io/nsIBinaryInputStream.idl +++ b/xpcom/io/nsIBinaryInputStream.idl @@ -16,7 +16,7 @@ * @See nsIBinaryOutputStream */ -[scriptable, uuid(899b826b-2eb3-469c-8b31-4c29f5d341a6)] +[scriptable, builtinclass, uuid(899b826b-2eb3-469c-8b31-4c29f5d341a6)] interface nsIBinaryInputStream : nsIInputStream { void setInputStream(in nsIInputStream aInputStream); diff --git a/xpcom/io/nsIConverterOutputStream.idl b/xpcom/io/nsIConverterOutputStream.idl index fe0251438282..41faa5332d52 100644 --- a/xpcom/io/nsIConverterOutputStream.idl +++ b/xpcom/io/nsIConverterOutputStream.idl @@ -11,7 +11,7 @@ interface nsIOutputStream; * This interface allows writing strings to a stream, doing automatic * character encoding conversion. */ -[scriptable, uuid(4b71113a-cb0d-479f-8ed5-01daeba2e8d4)] +[scriptable, builtinclass, uuid(4b71113a-cb0d-479f-8ed5-01daeba2e8d4)] interface nsIConverterOutputStream : nsIUnicharOutputStream { /** diff --git a/xpcom/io/nsIIOUtil.idl b/xpcom/io/nsIIOUtil.idl index 577ba4046769..589556b36788 100644 --- a/xpcom/io/nsIIOUtil.idl +++ b/xpcom/io/nsIIOUtil.idl @@ -11,7 +11,7 @@ interface nsIOutputStream; /** * nsIIOUtil provdes various xpcom/io-related utility methods. */ -[scriptable, uuid(e8152f7f-4209-4c63-ad23-c3d2aa0c5a49)] +[scriptable, builtinclass, uuid(e8152f7f-4209-4c63-ad23-c3d2aa0c5a49)] interface nsIIOUtil : nsISupports { /** diff --git a/xpcom/io/nsIInputStream.idl b/xpcom/io/nsIInputStream.idl index 12524a6b6416..91207f731586 100644 --- a/xpcom/io/nsIInputStream.idl +++ b/xpcom/io/nsIInputStream.idl @@ -56,7 +56,7 @@ native nsWriteSegmentFun(nsWriteSegmentFun); * the case that a blocking input stream should be implemented using thread- * safe AddRef and Release. */ -[scriptable, uuid(53cdbc97-c2d7-4e30-b2c3-45b2ee79db18)] +[scriptable, builtinclass, uuid(53cdbc97-c2d7-4e30-b2c3-45b2ee79db18)] interface nsIInputStream : nsISupports { /** diff --git a/xpcom/io/nsIInputStreamTee.idl b/xpcom/io/nsIInputStreamTee.idl index 1846ce8ab26a..60881e0fb851 100644 --- a/xpcom/io/nsIInputStreamTee.idl +++ b/xpcom/io/nsIInputStreamTee.idl @@ -13,7 +13,7 @@ interface nsIEventTarget; * reads the specified amount of data from its |source| and copies that * data to its |sink|. |sink| must be a blocking output stream. */ -[scriptable, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)] +[scriptable, builtinclass, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)] interface nsIInputStreamTee : nsIInputStream { attribute nsIInputStream source; diff --git a/xpcom/io/nsIOutputStream.idl b/xpcom/io/nsIOutputStream.idl index 6f722f57061e..6bb5a55123ad 100644 --- a/xpcom/io/nsIOutputStream.idl +++ b/xpcom/io/nsIOutputStream.idl @@ -50,7 +50,7 @@ native nsReadSegmentFun(nsReadSegmentFun); * generally the case that a blocking output stream should be implemented using * thread- safe AddRef and Release. */ -[scriptable, uuid(0d0acd2a-61b4-11d4-9877-00c04fa0cf4a)] +[scriptable, builtinclass, uuid(0d0acd2a-61b4-11d4-9877-00c04fa0cf4a)] interface nsIOutputStream : nsISupports { /**