function abortWritingSuccess() {
      var onTestSuccess = chrome.test.callbackPass();

      var onAbortRequested = function(options, onSuccess, onError) {
        chrome.fileSystemProvider.onAbortRequested.removeListener(
            onAbortRequested);
        onSuccess();
        onTestSuccess();
      };

      chrome.fileSystemProvider.onAbortRequested.addListener(
          onAbortRequested);

      test_util.fileSystem.root.getFile(
          TESTING_CHOCOLATE_FILE_NAME,
          {create: false, exclusive: false},
          function(fileEntry) {
            var hadAbort = false;
            fileEntry.createWriter(function(fileWriter) {
              fileWriter.onwriteend = function(e) {
                if (!hadAbort) {
                  chrome.test.fail(
                      'Unexpectedly finished writing, despite aborting.');
                  return;
                }
              };
              fileWriter.onerror = function(e) {
                chrome.test.assertEq(
                    'AbortError', fileWriter.error.name);
              };
              fileWriter.onabort = function(e) {
                hadAbort = true;
              };
              writeFileRequestedCallbacks.push(
                  function(filePath) {
                    // Abort the operation after it's started.
                    if (filePath === '/' + TESTING_CHOCOLATE_FILE_NAME)
                      fileWriter.abort();
                  });
              var blob = new Blob(['A lot of cherries.'], {type: 'text/plain'});
              fileWriter.write(blob);
            },
            function(error) {
              chrome.test.fail();
            });
          },
          function(error) {
            chrome.test.fail(error.name);
          });
    }
// result in a gracefully terminated writing operation.
result in a gracefully terminated writing operation.
result in a gracefully terminated writing operation .
function abortWritingSuccess() {
      var onTestSuccess = chrome.test.callbackPass();
      var onAbortRequested = function(options, onSuccess, onError) {
        chrome.fileSystemProvider.onAbortRequested.removeListener(
            onAbortRequested);
        onSuccess();
        onTestSuccess();
      };
      chrome.fileSystemProvider.onAbortRequested.addListener(
          onAbortRequested);
      test_util.fileSystem.root.getFile(
          TESTING_CHOCOLATE_FILE_NAME,
          {create: false, exclusive: false},
          function(fileEntry) {
            var hadAbort = false;
            fileEntry.createWriter(function(fileWriter) {
              fileWriter.onwriteend = function(e) {
                if (!hadAbort) {
                  chrome.test.fail(
                      'Unexpectedly finished writing, despite aborting.');
                  return;
                }
              };
              fileWriter.onerror = function(e) {
                chrome.test.assertEq(
                    'AbortError', fileWriter.error.name);
              };
              fileWriter.onabort = function(e) {
                hadAbort = true;
              };
              writeFileRequestedCallbacks.push(
                  function(filePath) {
                    if (filePath === '/' + TESTING_CHOCOLATE_FILE_NAME)
                      fileWriter.abort();
                  });
              var blob = new Blob(['A lot of cherries.'], {type: 'text/plain'});
              fileWriter.write(blob);
            },
            function(error) {
              chrome.test.fail();
            });
          },
          function(error) {
            chrome.test.fail(error.name);
          });
    }
function abortWritingSuccess ( ) { var onTestSuccess = chrome . test . callbackPass ( ) ; var onAbortRequested = function ( options , onSuccess , onError ) { chrome . fileSystemProvider . onAbortRequested . removeListener ( onAbortRequested ) ; onSuccess ( ) ; onTestSuccess ( ) ; } ; chrome . fileSystemProvider . onAbortRequested . addListener ( onAbortRequested ) ; test_util . fileSystem . root . getFile ( TESTING_CHOCOLATE_FILE_NAME , { create : false , exclusive : false } , function ( fileEntry ) { var hadAbort = false ; fileEntry . createWriter ( function ( fileWriter ) { fileWriter . onwriteend = function ( e ) { if ( ! hadAbort ) { chrome . test . fail ( 'Unexpectedly finished writing, despite aborting.' ) ; return ; } } ; fileWriter . onerror = function ( e ) { chrome . test . assertEq ( 'AbortError' , fileWriter . error . name ) ; } ; fileWriter . onabort = function ( e ) { hadAbort = true ; } ; writeFileRequestedCallbacks . push ( function ( filePath ) { if ( filePath === '/' + TESTING_CHOCOLATE_FILE_NAME ) fileWriter . abort ( ) ; } ) ; var blob = new Blob ( [ 'A lot of cherries.' ] , { type : 'text/plain' } ) ; fileWriter . write ( blob ) ; } , function ( error ) { chrome . test . fail ( ) ; } ) ; } , function ( error ) { chrome . test . fail ( error . name ) ; } ) ; }
result in a gracefully terminated writing operation.
result in a gracefully terminated writing operation .
// Abort the operation after it's started.