function readFileWithOpenedFilesLimitSuccess() {
      setUpFileSystem(2 /* two files */, chrome.test.callbackPass(function() {
        var initAllReadsPromise;

        // Set a breakpoint on reading a file, and continue once another file
        // is queued.
        readBreakpointCallback = function(filePath, continueCallback) {
          chrome.test.assertEq('/' + TESTING_TIRAMISU_FILE.name, filePath);
          // Continue after all reads are initiated.
          initAllReadsPromise.then(chrome.test.callbackPass(function() {
            chrome.test.assertTrue(
                Object.keys(test_util.openedFiles).length <= 2);
            continueCallback();
          })).catch(function(error) {
            chrome.test.fail(error.rname);
          });
        };

        // Initiate reads, but all of them will be stoped on a breakpoint on
        // the first read.
        var initReadPromises = [];
        for (var i = 0; i < 16; i++) {
          initReadPromises.push(new Promise(
            chrome.test.callbackPass(function(fulfill) {
              test_util.fileSystem.root.getFile(
                  TESTING_TIRAMISU_FILE.name,
                  {create: false},
                  chrome.test.callbackPass(function(fileEntry) {
                    fileEntry.file(chrome.test.callbackPass(function(file) {
                      var fileReader = new FileReader();
                      fileReader.onload = chrome.test.callbackPass(function(e) {
                        var text = fileReader.result;
                        chrome.test.assertEq(TESTING_TEXT, text);
                      });
                      fileReader.onerror = function(e) {
                        chrome.test.fail(fileReader.error.name);
                      };
                      fileReader.readAsText(file);
                      fulfill();
                    }),
                    function(error) {
                      chrome.test.fail(error.name);
                    });
                  }),
                  function(error) {
                    chrome.test.fail(error.name);
                  });
            })));
        }

        initAllReadsPromise = Promise.all(initReadPromises);
      }));
    }
// there is at most as many opened files at once as permitted per limit.
there is at most as many opened files at once as permitted per limit.
there is at most as many opened files at once as permitted per limit .
function readFileWithOpenedFilesLimitSuccess() {
      setUpFileSystem(2 , chrome.test.callbackPass(function() {
        var initAllReadsPromise;
        readBreakpointCallback = function(filePath, continueCallback) {
          chrome.test.assertEq('/' + TESTING_TIRAMISU_FILE.name, filePath);
          initAllReadsPromise.then(chrome.test.callbackPass(function() {
            chrome.test.assertTrue(
                Object.keys(test_util.openedFiles).length <= 2);
            continueCallback();
          })).catch(function(error) {
            chrome.test.fail(error.rname);
          });
        };
        var initReadPromises = [];
        for (var i = 0; i < 16; i++) {
          initReadPromises.push(new Promise(
            chrome.test.callbackPass(function(fulfill) {
              test_util.fileSystem.root.getFile(
                  TESTING_TIRAMISU_FILE.name,
                  {create: false},
                  chrome.test.callbackPass(function(fileEntry) {
                    fileEntry.file(chrome.test.callbackPass(function(file) {
                      var fileReader = new FileReader();
                      fileReader.onload = chrome.test.callbackPass(function(e) {
                        var text = fileReader.result;
                        chrome.test.assertEq(TESTING_TEXT, text);
                      });
                      fileReader.onerror = function(e) {
                        chrome.test.fail(fileReader.error.name);
                      };
                      fileReader.readAsText(file);
                      fulfill();
                    }),
                    function(error) {
                      chrome.test.fail(error.name);
                    });
                  }),
                  function(error) {
                    chrome.test.fail(error.name);
                  });
            })));
        }
        initAllReadsPromise = Promise.all(initReadPromises);
      }));
    }
function readFileWithOpenedFilesLimitSuccess ( ) { setUpFileSystem ( 2 , chrome . test . callbackPass ( function ( ) { var initAllReadsPromise ; readBreakpointCallback = function ( filePath , continueCallback ) { chrome . test . assertEq ( '/' + TESTING_TIRAMISU_FILE . name , filePath ) ; initAllReadsPromise . then ( chrome . test . callbackPass ( function ( ) { chrome . test . assertTrue ( Object . keys ( test_util . openedFiles ) . length <= 2 ) ; continueCallback ( ) ; } ) ) . catch ( function ( error ) { chrome . test . fail ( error . rname ) ; } ) ; } ; var initReadPromises = [ ] ; for ( var i = 0 ; i < 16 ; i ++ ) { initReadPromises . push ( new Promise ( chrome . test . callbackPass ( function ( fulfill ) { test_util . fileSystem . root . getFile ( TESTING_TIRAMISU_FILE . name , { create : false } , chrome . test . callbackPass ( function ( fileEntry ) { fileEntry . file ( chrome . test . callbackPass ( function ( file ) { var fileReader = new FileReader ( ) ; fileReader . onload = chrome . test . callbackPass ( function ( e ) { var text = fileReader . result ; chrome . test . assertEq ( TESTING_TEXT , text ) ; } ) ; fileReader . onerror = function ( e ) { chrome . test . fail ( fileReader . error . name ) ; } ; fileReader . readAsText ( file ) ; fulfill ( ) ; } ) , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; } ) , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; } ) ) ) ; } initAllReadsPromise = Promise . all ( initReadPromises ) ; } ) ) ; }
there is at most as many opened files at once as permitted per limit.
there is at most as many opened files at once as permitted per limit .
/* two files */ // Set a breakpoint on reading a file, and continue once another file // is queued. // Continue after all reads are initiated. // Initiate reads, but all of them will be stoped on a breakpoint on // the first read.