|
12 | 12 | <div id="log"></div>
|
13 | 13 |
|
14 | 14 | <script>
|
15 |
| - var blob; |
| 15 | + var blob, blob2; |
16 | 16 | setup(function() {
|
17 | 17 | blob = new Blob(["This test the result attribute"]);
|
| 18 | + blob2 = new Blob(["This is a second blob"]); |
18 | 19 | });
|
19 | 20 |
|
20 | 21 | async_test(function() {
|
|
54 | 55 |
|
55 | 56 | readArrayBuffer.readAsArrayBuffer(blob);
|
56 | 57 | }, "readAsArrayBuffer");
|
| 58 | + |
| 59 | + async_test(function() { |
| 60 | + var readBinaryString = new FileReader(); |
| 61 | + assert_equals(readBinaryString.result, null); |
| 62 | + |
| 63 | + readBinaryString.onloadend = this.step_func(function(evt) { |
| 64 | + assert_equals(typeof readBinaryString.result, "string", "The result type is string"); |
| 65 | + assert_equals(readBinaryString.result, "This test the result attribute", "The result is correct"); |
| 66 | + this.done(); |
| 67 | + }); |
| 68 | + |
| 69 | + readBinaryString.readAsBinaryString(blob); |
| 70 | + }, "readAsBinaryString"); |
| 71 | + |
| 72 | + |
| 73 | + for (let event of ['loadstart', 'progress']) { |
| 74 | + for (let method of ['readAsText', 'readAsDataURL', 'readAsArrayBuffer', 'readAsBinaryString']) { |
| 75 | + promise_test(async function(t) { |
| 76 | + var reader = new FileReader(); |
| 77 | + assert_equals(reader.result, null, 'result is null before read'); |
| 78 | + |
| 79 | + var eventWatcher = new EventWatcher(t, reader, |
| 80 | + [event, 'loadend']); |
| 81 | + |
| 82 | + reader[method](blob); |
| 83 | + assert_equals(reader.result, null, 'result is null after first read call'); |
| 84 | + await eventWatcher.wait_for(event); |
| 85 | + assert_equals(reader.result, null, 'result is null during event'); |
| 86 | + await eventWatcher.wait_for('loadend'); |
| 87 | + assert_not_equals(reader.result, null); |
| 88 | + reader[method](blob); |
| 89 | + assert_equals(reader.result, null, 'result is null after second read call'); |
| 90 | + await eventWatcher.wait_for(event); |
| 91 | + assert_equals(reader.result, null, 'result is null during second read event'); |
| 92 | + }, 'result is null during "' + event + '" event for ' + method); |
| 93 | + } |
| 94 | + } |
57 | 95 | </script>
|
58 | 96 | </body>
|
59 | 97 | </html>
|
0 commit comments