Index: chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js |
diff --git a/chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js b/chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js |
index 12d5e5a000bc5b4adfa53fa7846f527a8294f55e..00741e77e2ea3478a0da9ef24979d150c2a13d8f 100644 |
--- a/chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js |
+++ b/chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js |
@@ -68,13 +68,14 @@ var readBreakpointCallback = null; |
*/ |
function onReadFileRequested(options, onSuccess, onError) { |
var filePath = test_util.openedFiles[options.openRequestId]; |
- if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { |
- onError('SECURITY'); // enum ProviderError. |
- return; |
- } |
- if (filePath == '/' + TESTING_TIRAMISU_FILE.name) { |
- var continueRead = function() { |
+ var continueRead = function() { |
+ if (options.fileSystemId != test_util.FILE_SYSTEM_ID || !filePath) { |
+ onError('SECURITY'); // enum ProviderError. |
+ return; |
+ } |
+ |
+ if (filePath == '/' + TESTING_TIRAMISU_FILE.name) { |
var textToSend = TESTING_TEXT.substr(options.offset, options.length); |
var textToSendInChunks = textToSend.split(/(?= )/); |
@@ -90,26 +91,26 @@ function onReadFileRequested(options, onSuccess, onError) { |
reader.readAsArrayBuffer(new Blob([item])); |
}); |
- }; |
+ return; |
+ } |
- if (readBreakpointCallback) |
- readBreakpointCallback(filePath, continueRead); |
- else |
- continueRead(); |
- return; |
- } |
+ if (filePath == '/' + TESTING_VANILLA_FOR_ABORT_FILE.name) { |
+ // Do nothing. This simulates a very slow read. |
+ return; |
+ } |
- if (filePath == '/' + TESTING_VANILLA_FOR_ABORT_FILE.name) { |
- // Do nothing. This simulates a very slow read. |
- return; |
- } |
+ if (filePath == '/' + TESTING_BROKEN_TIRAMISU_FILE.name) { |
+ onError('ACCESS_DENIED'); // enum ProviderError. |
+ return; |
+ } |
- if (filePath == '/' + TESTING_BROKEN_TIRAMISU_FILE.name) { |
- onError('ACCESS_DENIED'); // enum ProviderError. |
- return; |
- } |
+ onError('INVALID_OPERATION'); // enum ProviderError. |
+ }; |
- onError('INVALID_OPERATION'); // enum ProviderError. |
+ if (readBreakpointCallback) |
+ readBreakpointCallback(filePath, continueRead); |
+ else |
+ continueRead(); |
} |
/** |
@@ -304,11 +305,12 @@ function runTests() { |
chrome.test.assertEq( |
'AbortError', fileReader.error.name); |
}); |
- fileReader.readAsText(file); |
- setTimeout(chrome.test.callbackPass(function() { |
- // Abort the operation after it's started. |
+ // Set a breakpoint on reading a file, so aborting is invoked |
+ // after it's started. |
+ readBreakpointCallback = function(filePath, continueCallback) { |
fileReader.abort(); |
- }), 0); |
+ }; |
+ fileReader.readAsText(file); |
}), |
function(error) { |
chrome.test.fail(error.name); |