3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
4 <script src=
"../http/tests/inspector/inspector-test.js"></script>
7 function initialize_ChunkedFileReaderTest()
10 InspectorTest
.TestOutputStreamDelegate = function(doneCallback
)
12 this._doneCallback
= doneCallback
;
16 InspectorTest
.TestOutputStreamDelegate
.prototype = {
17 onTransferStarted: function()
19 InspectorTest
.addResult("WebInspector.OutputStreamDelegate.onTransferStarted() called");
22 onTransferFinished: function()
24 InspectorTest
.addResult("Chunks transferred: " + this._chunkCount
);
25 InspectorTest
.addResult("WebInspector.OutputStreamDelegate.onTransferFinished() called");
30 * @param {!WebInspector.ChunkedReader} reader
32 onChunkTransferred: function(reader
)
38 * @param {!WebInspector.ChunkedReader} reader
39 * @param {!Event} event
41 onError: function(reader
, event
)
43 InspectorTest
.addResult("WebInspector.OutputStreamDelegate.onError() called");
52 var text
= ["Латынь из моды вышла ныне:\n",
53 "Так, если правду вам сказать,\n",
54 "Он знал довольно по-латыне,\n",
55 "Чтоб эпиграфы разбирать\n"];
57 var blob
= new Blob(text
);
58 // Most of the characters above will be encoded as 2 bytes, so make sure we use odd
59 // chunk size to cause chunk boundaries sometimes to happen between chaacter bytes.
61 var reader
= new WebInspector
.ChunkedFileReader(blob
, chunkSize
, new InspectorTest
.TestOutputStreamDelegate(onTransferFinished
));
62 var output
= new WebInspector
.StringOutputStream();
64 function onTransferFinished()
66 InspectorTest
.assertEquals(text
.join(""), output
.data(), "Read text is different from written text");
67 InspectorTest
.addResult("DONE");
68 InspectorTest
.completeTest();
75 <body onload=
"runTest()">
77 This tests that ChunkedFileReader properly re-assembles chunks, especially in case these contain multibyte characters.