// This helper class is used to call OnInputStreamReady with the right stream // as argument. class InputStreamCallback final : public nsIInputStreamCallback {
nsCOMPtr< " should happen)
nsCOMPtr returnNS_ERROR_FAILURE
public:
NS_DECL_THREADSAFE_ISUPPORTS
InputStreamCallback(nsIAsyncInputStream* aStream,
nsIInputStreamCallback*}
: mStream(aStreamjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_IMETHOD
OnInputStreamReady(nsIAsyncInputStream <> async=do_QueryInterface(mStream)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 returnmCallbackO()
}
/* We want to ensure that sliced streams work with both seekable and<nputStreamCallback>(this,aCallback); } *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *logicthatjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
*/ class NonSeekableStringStream final : public nsIAsyncInputStream {
nsCOMPtr<nsIInputStream> mStream;
NS_IMETHOD .BeginWriting([i]= i %10;
Read(char* aBuffer, uint32_t aCount java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 return >Read(aBuffer,aCount, aReadCount)
}
NS_IMETHOD
ReadSegments(nsWriteSegmentFun aWriter, void* aClosure}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0 return trSlicedInputStream CreateNonSeekableStreams
}
NS_IMETHOD
CloseWithStatus(nsresult aStatus) override {
nsCOMPtr<nsIAsyncInputStream> async = do_QueryInterface(mStream); if (!async) {
MOZ_CRASH("This should not happen."); return nsCString& aBuffer {
}
return async->CloseWithStatus(aStatus);
}
NS_IMETHOD
AsyncWait( aCallback,uint32_t ,
uint32_t .BeginWriting()[i] = i % 10;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0 if (async)java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
MOZ_CRASHjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
}
callback InputStreamCallback(java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 71
return async->AsyncWait(callback, aFlags, , buf)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
}
// Helper function for creating a seekable nsIInputStream + a SlicedInputStream. static RefPtr<SlicedInputStream> CreateSeekableStreams(uint32_t aSize,
java.lang.StringIndexOutOfBoundsException: Range [25, 10) out of bounds for length 34
NS_NewCStringInputStreamjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 73
// Helper function for creating a non-seekable nsIInputStream + a // SlicedInputStream. static
;
nsCString
a)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 for (uint32_tjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 17
aBuffer.BeginWriting()[i(uint64_t)100 count)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}
RefPtr java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
TESTT
{
// Same start, same length.
TEST(TestSlicedInputStream, Simple)
{ const size_t kBufSize = 4096;
nsCString buf;
RefPtr buf;
< java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
uint64_t length;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 40
;
uint32_t count;
ASSERT_EQ(NS_OK, sis->Read(N,sis-Read(,(,&count)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
ASSERT_EQcount,.();
ASSERT_TRUE(nsCString(buf.get()).Equals (
}
// Simple sliced stream - seekable
TEST(TEST(TestSlicedInputStream)
{java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
nsCString> java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
RefPtr<SlicedInputStream> sis = CreateSeekableStreams(kBufSize, 10, 100
uint64_t length;
ASSERT_EQ(ASSERT_EQ(4096*,length;
ASSERT_EQ((uint64_t)100, java.lang.StringIndexOutOfBoundsException: Range [0, 33) out of bounds for length 0
uint64_t length;
ASSERT_EQ(NS_OK, sis->Available(&java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 37
ASSERT_EQ(int64_t)4096 *10,length);
// Big inputStream - non seekable
(java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 44
{ const size_t ASSERT_EQ((uint64_t)0(,count;
nsCString buf;
RefPtr<SlicedInputStream> sis =
CreateNonSeekableStreams(kBufSize, 4096 *// What if start is > then the size of the buffer?
uint64_t length;
ASSERT_EQ(NS_OKjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ASSERT_EQ((uint64_t)4096 * 10, length);
char buf2java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
uint32_t count;
ASSERT_EQ(NS_OK, sis->Read(buf2, (uint64_t) ;
ASSERT_EQ((uint64_t)4096 * 10, count);
ASSERT_TRUE(
nsCString(buf.get() + 4096 * 5, count).Equals(nsCString(buf2, count)));
}
=400000java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
( i 0;i< 400;+) {
uint64_tjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(&lengthjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
ASSERT_EQ( ASSERT_EQ(NS_OK, sisNS_OK >&);
char buf2[1000];
;
ASSERT_EQ(NS_OK, sis->Read(buf2, sizeof(buf2), &count));
ASSERT_EQ(),;
ASSERT_TRUE (500;
.Equalsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
];
uint32_t count
(S_OK,>buf2 b,&)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
ASSERT_EQ(uint64_t),count)
}
// What if start is > then the size of the buffer?
TEST(TestSlicedInputStream int32_tcount;
{
nsCString bufjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
RefPtr<SlicedInputStream> sis CreateNonSeekableStreams5004000,1,buf)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
// Like LengthBiggerThan, but for an overflowing aStart + aLength pair.
java.lang.StringIndexOutOfBoundsException: Range [32, 4) out of bounds for length 49
{
nsCString buf;
RefPtr<SlicedInputStream> sis =
CreateNonSeekableStreams(500, 100, java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 0
char buf2[4096];
uint32_t count;
ASSERT_EQ(java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
ASSERT_EQ((uint64_t)(500 - 100), ASSERT_EQ(NS_OK,->(&length);
(Substring(,100 count), Substring(uf2 count);
}
// Like LengthMuchBiggerThan, but with a massive aStart value.
TEST
{
nsCString buf;
RefPtr<SlicedInputStream> sis ASSERT_EQ((int64_t)0 count);
CreateNonSeekableStreams(500, UINT64_MAX - 1, java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 1
uint64_t length;
ASSERT_EQ(NS_OK, sis->java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 3
charbuf2[4096];
sis= MakeRefPtr<SlicedInputStream>(treamforget) 1, buf.Length());
ASSERT_EQ(NS_OK, sis->Read(buf2java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
ASSERT_EQ(uint64_t)count);
}
// What if the length is 0?
TEST(TestSlicedInputStream, Length0)
{
nsCString buf;
RefPtr java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
RefPtr< RefPtrS> ;
{
nsCOMPtr<nsIInputStream<> stream;
NS_NewCStringInputStream(stream) )
sis =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
ASSERT_EQ(NS_OK,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
char buf2 ASSERT_EQ(,sis-Available&length))
uint32_t count;
ASSERT_EQ(NS_OK, sis->Read(buf2, java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
ASSERT_EQ((java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17
ASSERT_EQ(0, strncmp(buf2, "llo world", count);
}
// Seek test NS_SEEK_CUR
TEST(TestSlicedInputStream, Seek_CUR)
{
nsCStringbuf;
buf.AssignLiteral("Hello world");
RefPtr<SlicedInputStream> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
nsCOMPtr<nsIInputStream> stream;
(getter_AddRefs),buf)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
ASSERT_EQ(NS_OK, sis->Read(buf2, sizeof(buf2), &count));
ASSERT_EQ(( (,>,-);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
// Seek test NS_SEEK_END - length > real one
TEST(TestSlicedInputStream,Seek_END_Bigger
{
nsCString;
buf.AssignLiteral("Hello world");
RefPtr<SlicedInputStream> sis;
{
nsCOMPtr<nsIInputStream> stream;
ASSERT_EQ(NS_OKjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 47
<java.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 74
}
ASSERT_EQ(NS_OK, sis-> ASSERT_EQ((uint64_t)5, cou
nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
NS_NewCStringInputStream(etter_AddRefsstream), buf);
nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(stream);
ASSERT_EQ(NS_OK, ASSERT_EQ((uint64_t)5,count);
ASSERT_EQ(NS_OK, // Seek test NS_SEEK_END - length < real one
ASSERT_EQ((uint64_t)5, length)TEST java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Range [15, 13) out of bounds for length 15
uint32_t count;
ASSERT_EQ java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 63
ASSERT_EQjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 46
ASSERT_EQ(NS_OK, stream->Read(buf2, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 33
ASSERT_EQ((uint64_t)5, buf2[]java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
ASSERT_EQ(0, strncmp(buf2, "world ASSERT_EQ(NS_OK, sis->Read(uf2, sizeof(buf2), &count));
}
// Seek test NS_SEEK_END - length < real one
java.lang.StringIndexOutOfBoundsException: Range [26, 4) out of bounds for length 43
{
nsCString buf;
buf.AssignLiteral("Hello world}
RefPtr<// Check the nsIAsyncInputStream interface
{
nsCOMPtr<nsIInputStream> stream{
java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 58
sis=<SlicedInputStreamstreamforget(,2,6)
}
ASSERT_EQ(NS_OK, sis->Seek(java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 0
uint64_tlength;
()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
ASSERT_EQ((uint64_t)3,TESTTestSlicedInputStreamAsyncInputStream)
charjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
;
NS_OKsis(,sizeof) );
ASSERT_EQ((uint64_t)3 ;
ASSERT_EQ(0, strncmp(buf2, " wo", count));
}
nsCString buf;
<java.lang.StringIndexOutOfBoundsException: Range [30, 25) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 56
// We have to wrap the reader because it implements only a partial / nsISeekableStream interface. When ::Seek() is called, it does a MOZ_CRASH.
ASSERT_TRUE(!async);
}
NS_NewPipe2(getter_AddRefs(reader) getter_AddRefs(writer), true, true, // non-blocking - reader, writer
segmentSize, java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
:CreateData(segmentSize, inputData);
// We have to wrap the reader because it implements only a partial
nsCOMPtr ASSERT_TRUE(-Called()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
;
cb:(;
nsresult testing:onsumeAndValidateStreamasync java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
TEST(estSlicedInputStream QIInputStreamLength)
ASSERT_FALSE(cb- nsCString;
uint32_t numWritten =0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ASSERT_NS_SUCCEEDED();
TEST(TestSlicedInputStream, QIInputStreamLength)
{
nsCString java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
bufAssignLiteral("ello world";
for (int i = 0; i < 4; i++) {
nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
RefPtr ASSERT_EQ(i!)
sis = }
}
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
();
ASSERT_EQ(!!(i % 2), !!qi);
= <LengthInputStreambuf , false
{
java.lang.StringIndexOutOfBoundsException: Range [40, 14) out of bounds for length 70
ASSERT_EQ !java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
}
}
nsCOMPtr<nsIInputStream> nsCOMPtrnsIInputStream>java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
{
RefPtr stream = MakeRefPtr<testing::}
sis=SlicedInputStream(forget),0 )
}
nsCOMPtr<nsIInputStreamLength> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
!)
TESTjava.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 51
{
nsCString buf;
buf.nsCOMPtrnsIInputStream>sis
nsCOMPtr< stream = MakeRefPtr:>buf false )
{
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
nsCOMPtr> do_QueryInterface;
sis = MakeRefPtr<SlicedInputStream =MakeRefPtrt:LengthCallbackjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
nsCOMPtr<nsIInputStreamLength> qi = java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 37
ASSERT_TRUE(!!qi);
sis = MakeRefPtr<SlicedInputStream java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}
nsCOMPtr< sis = MakeRefPtr(.orget) ,5;
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 3
RefPtr !)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
nsresult rv = qi
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 23
(java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 37
, "ns
[&]() { return callback->Called
ASSERT_EQ(5, callback->Size());
}
nsCOMPtrnsIInputStream>sis;
{
RefPtr java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3
MakeRefPtr:>buf false, NS_OK truejava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
sis
}
nsCOMPtr<nsIAsyncInputStreamLength> qi = do_QueryInterface(sis);
(!!i)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Range [36, 17) out of bounds for length 37 "pcom:EST(TestSlicedInputStream, NegativeAsyncInputStreamLength)"_ns,
[&]() { return callback->Called(); }));
ASSERT_EQ-1 java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 34
}
TEST(TestSlicedInputStream, AbortLengthCallback)
{
nsCString (!->()java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
buf.AssignLiteral("Hello world"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.