| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 */ | 138 */ |
| 139 function onReadFileRequested(options, onSuccess, onError) { | 139 function onReadFileRequested(options, onSuccess, onError) { |
| 140 var filePath = openedFiles[options.openRequestId]; | 140 var filePath = openedFiles[options.openRequestId]; |
| 141 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { | 141 if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { |
| 142 onError('INVALID_OPERATION'); // enum ProviderError. | 142 onError('INVALID_OPERATION'); // enum ProviderError. |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (filePath == '/' + TESTING_6GB_FILE.name) { | 146 if (filePath == '/' + TESTING_6GB_FILE.name) { |
| 147 if (options.offset < TESTING_TEXT_OFFSET || | 147 if (options.offset < TESTING_TEXT_OFFSET || |
| 148 options.offset + options.length > | 148 options.offset >= TESTING_TEXT_OFFSET + TESTING_TEXT.length) { |
| 149 TESTING_TEXT_OFFSET + TESTING_TEXT.length) { | |
| 150 console.error('Reading from a wrong location in the file!'); | 149 console.error('Reading from a wrong location in the file!'); |
| 151 onError('INVALID_FAILED'); // enum ProviderError. | 150 onError('FAILED'); // enum ProviderError. |
| 152 return; | 151 return; |
| 153 } | 152 } |
| 154 | 153 |
| 155 var buffer = TESTING_TEXT.substr( | 154 var buffer = TESTING_TEXT.substr( |
| 156 options.offset - TESTING_TEXT_OFFSET, options.length); | 155 options.offset - TESTING_TEXT_OFFSET, options.length); |
| 157 var reader = new FileReader(); | 156 var reader = new FileReader(); |
| 158 reader.onload = function(e) { | 157 reader.onload = function(e) { |
| 159 onSuccess(e.target.result, false /* hasMore */); | 158 onSuccess(e.target.result, false /* hasMore */); |
| 160 }; | 159 }; |
| 161 reader.readAsArrayBuffer(new Blob([buffer])); | 160 reader.readAsArrayBuffer(new Blob([buffer])); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 }, | 220 }, |
| 222 function(error) { | 221 function(error) { |
| 223 chrome.test.fail(error.name); | 222 chrome.test.fail(error.name); |
| 224 }); | 223 }); |
| 225 } | 224 } |
| 226 ]); | 225 ]); |
| 227 } | 226 } |
| 228 | 227 |
| 229 // Setup and run all of the test cases. | 228 // Setup and run all of the test cases. |
| 230 setUp(runTests); | 229 setUp(runTests); |
| OLD | NEW |