function replaceFileSuccess() {
      var onTestSuccess = chrome.test.callbackPass();
      test_util.fileSystem.root.getFile(
          TESTING_TIRAMISU_FILE_NAME,
          {create: false, exclusive: false},
          function(fileEntry) {
            fileEntry.createWriter(function(fileWriter) {
              fileWriter.seek(TESTING_TEXT_TO_WRITE.indexOf('creams'));
              fileWriter.onwriteend = function(e) {
                if (fileWriter.error)
                  return;
                var expectedContents = TESTING_TEXT_TO_WRITE.replace(
                    'creams', 'skates') + TESTING_TEXT_TO_WRITE;
                chrome.test.assertEq(
                    expectedContents,
                    fileContents['/' + TESTING_TIRAMISU_FILE_NAME]);
                onTestSuccess();
              };
              fileWriter.onerror = function(e) {
                chrome.test.fail(fileWriter.error.name);
              };
              var blob = new Blob(['skates'], {type: 'text/plain'});
              fileWriter.write(blob);
            },
            function(error) {
              chrome.test.fail(error.name);
            });
          },
          function(error) {
            chrome.test.fail(error.name);
          });
    }
// Replace contents in an existing file. It should succeed.
Replace contents in an existing file. It should succeed.
Replace contents in an existing file . It should succeed .
function replaceFileSuccess() {
      var onTestSuccess = chrome.test.callbackPass();
      test_util.fileSystem.root.getFile(
          TESTING_TIRAMISU_FILE_NAME,
          {create: false, exclusive: false},
          function(fileEntry) {
            fileEntry.createWriter(function(fileWriter) {
              fileWriter.seek(TESTING_TEXT_TO_WRITE.indexOf('creams'));
              fileWriter.onwriteend = function(e) {
                if (fileWriter.error)
                  return;
                var expectedContents = TESTING_TEXT_TO_WRITE.replace(
                    'creams', 'skates') + TESTING_TEXT_TO_WRITE;
                chrome.test.assertEq(
                    expectedContents,
                    fileContents['/' + TESTING_TIRAMISU_FILE_NAME]);
                onTestSuccess();
              };
              fileWriter.onerror = function(e) {
                chrome.test.fail(fileWriter.error.name);
              };
              var blob = new Blob(['skates'], {type: 'text/plain'});
              fileWriter.write(blob);
            },
            function(error) {
              chrome.test.fail(error.name);
            });
          },
          function(error) {
            chrome.test.fail(error.name);
          });
    }
function replaceFileSuccess ( ) { var onTestSuccess = chrome . test . callbackPass ( ) ; test_util . fileSystem . root . getFile ( TESTING_TIRAMISU_FILE_NAME , { create : false , exclusive : false } , function ( fileEntry ) { fileEntry . createWriter ( function ( fileWriter ) { fileWriter . seek ( TESTING_TEXT_TO_WRITE . indexOf ( 'creams' ) ) ; fileWriter . onwriteend = function ( e ) { if ( fileWriter . error ) return ; var expectedContents = TESTING_TEXT_TO_WRITE . replace ( 'creams' , 'skates' ) + TESTING_TEXT_TO_WRITE ; chrome . test . assertEq ( expectedContents , fileContents [ '/' + TESTING_TIRAMISU_FILE_NAME ] ) ; onTestSuccess ( ) ; } ; fileWriter . onerror = function ( e ) { chrome . test . fail ( fileWriter . error . name ) ; } ; var blob = new Blob ( [ 'skates' ] , { type : 'text/plain' } ) ; fileWriter . write ( blob ) ; } , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; } , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; }
Replace contents in an existing file.
Replace contents in an existing file .