Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8154)

Unified Diff: chrome/test/data/extensions/api_test/file_system_provider/read_file/test.js

Issue 836613008: [fsp] Fix flaky tests for aborting read. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698