function writeNewFileSuccess() {
      test_util.fileSystem.root.getFile(
          TESTING_NEW_FILE_NAME,
          {create: true, exclusive: true},
          chrome.test.callbackPass(function(fileEntry) {
            fileEntry.createWriter(
                chrome.test.callbackPass(function(fileWriter) {
                  fileWriter.onwriteend = chrome.test.callbackPass(function(e) {
                    // Note that onwriteend() is called even if an error
                    // happened.
                    if (fileWriter.error)
                      return;
                    chrome.test.assertEq(
                        TESTING_TEXT_TO_WRITE,
                        fileContents['/' + TESTING_NEW_FILE_NAME]);
                  });
                  fileWriter.onerror = function(e) {
                    chrome.test.fail(fileWriter.error.name);
                  };
                  var blob = new Blob(
                      [TESTING_TEXT_TO_WRITE], {type: 'text/plain'});
                  fileWriter.write(blob);
                }),
                function(error) {
                  chrome.test.fail(error.name);
                });
          }),
          function(error) {
            chrome.test.fail(error.name);
          });
    }
// Write contents to a non-existing file. It should succeed.
Write contents to a non-existing file. It should succeed.
Write contents to a non - existing file . It should succeed .
function writeNewFileSuccess() {
      test_util.fileSystem.root.getFile(
          TESTING_NEW_FILE_NAME,
          {create: true, exclusive: true},
          chrome.test.callbackPass(function(fileEntry) {
            fileEntry.createWriter(
                chrome.test.callbackPass(function(fileWriter) {
                  fileWriter.onwriteend = chrome.test.callbackPass(function(e) {
                    if (fileWriter.error)
                      return;
                    chrome.test.assertEq(
                        TESTING_TEXT_TO_WRITE,
                        fileContents['/' + TESTING_NEW_FILE_NAME]);
                  });
                  fileWriter.onerror = function(e) {
                    chrome.test.fail(fileWriter.error.name);
                  };
                  var blob = new Blob(
                      [TESTING_TEXT_TO_WRITE], {type: 'text/plain'});
                  fileWriter.write(blob);
                }),
                function(error) {
                  chrome.test.fail(error.name);
                });
          }),
          function(error) {
            chrome.test.fail(error.name);
          });
    }
function writeNewFileSuccess ( ) { test_util . fileSystem . root . getFile ( TESTING_NEW_FILE_NAME , { create : true , exclusive : true } , chrome . test . callbackPass ( function ( fileEntry ) { fileEntry . createWriter ( chrome . test . callbackPass ( function ( fileWriter ) { fileWriter . onwriteend = chrome . test . callbackPass ( function ( e ) { if ( fileWriter . error ) return ; chrome . test . assertEq ( TESTING_TEXT_TO_WRITE , fileContents [ '/' + TESTING_NEW_FILE_NAME ] ) ; } ) ; fileWriter . onerror = function ( e ) { chrome . test . fail ( fileWriter . error . name ) ; } ; var blob = new Blob ( [ TESTING_TEXT_TO_WRITE ] , { type : 'text/plain' } ) ; fileWriter . write ( blob ) ; } ) , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; } ) , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; }
Write contents to a non-existing file.
Write contents to a non - existing file .
// Note that onwriteend() is called even if an error // happened.