OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * @type {DOMFileSystem} | 8 * @type {DOMFileSystem} |
9 */ | 9 */ |
10 var fileSystem = null; | 10 var fileSystem = null; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 */ | 97 */ |
98 function onReadFileRequested(options, onSuccess, onError) { | 98 function onReadFileRequested(options, onSuccess, onError) { |
99 var filePath = openedFiles[options.openRequestId]; | 99 var filePath = openedFiles[options.openRequestId]; |
100 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { | 100 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { |
101 onError('INVALID_OPERATION'); // enum ProviderError. | 101 onError('INVALID_OPERATION'); // enum ProviderError. |
102 return; | 102 return; |
103 } | 103 } |
104 | 104 |
105 if (filePath == '/' + TESTING_6GB_FILE.name) { | 105 if (filePath == '/' + TESTING_6GB_FILE.name) { |
106 if (options.offset < TESTING_TEXT_OFFSET || | 106 if (options.offset < TESTING_TEXT_OFFSET || |
107 options.offset + options.length > | 107 options.offset >= TESTING_TEXT_OFFSET + TESTING_TEXT.length) { |
108 TESTING_TEXT_OFFSET + TESTING_TEXT.length) { | |
109 console.error('Reading from a wrong location in the file!'); | 108 console.error('Reading from a wrong location in the file!'); |
110 onError('INVALID_FAILED'); // enum ProviderError. | 109 onError('FAILED'); // enum ProviderError. |
111 return; | 110 return; |
112 } | 111 } |
113 | 112 |
114 var buffer = TESTING_TEXT.substr( | 113 var buffer = TESTING_TEXT.substr( |
115 options.offset - TESTING_TEXT_OFFSET, options.length); | 114 options.offset - TESTING_TEXT_OFFSET, options.length); |
116 var reader = new FileReader(); | 115 var reader = new FileReader(); |
117 reader.onload = function(e) { | 116 reader.onload = function(e) { |
118 onSuccess(e.target.result, false /* hasMore */); | 117 onSuccess(e.target.result, false /* hasMore */); |
119 }; | 118 }; |
120 reader.readAsArrayBuffer(new Blob([buffer])); | 119 reader.readAsArrayBuffer(new Blob([buffer])); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 }, | 184 }, |
186 function(error) { | 185 function(error) { |
187 chrome.test.fail(error.name); | 186 chrome.test.fail(error.name); |
188 }); | 187 }); |
189 } | 188 } |
190 ]); | 189 ]); |
191 } | 190 } |
192 | 191 |
193 // Setup and run all of the test cases. | 192 // Setup and run all of the test cases. |
194 setUp(runTests); | 193 setUp(runTests); |
OLD | NEW |