| OLD | NEW |
| 1 if (this.importScripts) { | 1 if (this.importScripts) { |
| 2 importScripts('fs-worker-common.js'); | 2 importScripts('fs-worker-common.js'); |
| 3 importScripts('../../js/resources/js-test-pre.js'); | 3 importScripts('../../js/resources/js-test-pre.js'); |
| 4 importScripts('file-writer-utils.js'); | 4 importScripts('file-writer-utils.js'); |
| 5 } | 5 } |
| 6 | 6 |
| 7 description("Test that FileWriter handles abort properly."); | 7 description("Test that FileWriter handles abort properly."); |
| 8 | 8 |
| 9 var sawWriteStart; | 9 var sawWriteStart; |
| 10 var sawAbort; | 10 var sawAbort; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 writer.abort(); | 31 writer.abort(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // We should always abort before completion. | 34 // We should always abort before completion. |
| 35 function onWrite(e) { | 35 function onWrite(e) { |
| 36 testFailed("In onWrite."); | 36 testFailed("In onWrite."); |
| 37 } | 37 } |
| 38 | 38 |
| 39 function onAbort(e) { | 39 function onAbort(e) { |
| 40 assert(writer.readyState == writer.DONE); | 40 assert(writer.readyState == writer.DONE); |
| 41 assert(writer.error.code == writer.error.ABORT_ERR); | 41 assert(writer.error.name == "AbortError"); |
| 42 assert(sawWriteStart); | 42 assert(sawWriteStart); |
| 43 assert(!sawWriteEnd); | 43 assert(!sawWriteEnd); |
| 44 assert(!sawAbort); | 44 assert(!sawAbort); |
| 45 assert(e.type == "abort"); | 45 assert(e.type == "abort"); |
| 46 sawAbort = true; | 46 sawAbort = true; |
| 47 testPassed("Saw abort"); | 47 testPassed("Saw abort"); |
| 48 } | 48 } |
| 49 | 49 |
| 50 function onWriteEnd(e) { | 50 function onWriteEnd(e) { |
| 51 assert(writer.readyState == writer.DONE); | 51 assert(writer.readyState == writer.DONE); |
| 52 assert(writer.error.code == writer.error.ABORT_ERR); | 52 assert(writer.error.name == "AbortError"); |
| 53 assert(sawWriteStart); | 53 assert(sawWriteStart); |
| 54 assert(sawAbort); | 54 assert(sawAbort); |
| 55 assert(!sawWriteEnd); | 55 assert(!sawWriteEnd); |
| 56 assert(e.type == "writeend"); | 56 assert(e.type == "writeend"); |
| 57 sawWriteEnd = true; | 57 sawWriteEnd = true; |
| 58 testPassed("Saw writeend."); | 58 testPassed("Saw writeend."); |
| 59 writer.abort(); // Verify that this does nothing in readyState DONE. | 59 writer.abort(); // Verify that this does nothing in readyState DONE. |
| 60 cleanUp(); | 60 cleanUp(); |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 75 fileWriter.onwriteend = onWriteEnd; | 75 fileWriter.onwriteend = onWriteEnd; |
| 76 fileWriter.abort(); // Verify that this does nothing in readyState INIT. | 76 fileWriter.abort(); // Verify that this does nothing in readyState INIT. |
| 77 fileWriter.write(blob); | 77 fileWriter.write(blob); |
| 78 } | 78 } |
| 79 | 79 |
| 80 function runTest(unusedFileEntry, fileWriter) { | 80 function runTest(unusedFileEntry, fileWriter) { |
| 81 startWrite(fileWriter); | 81 startWrite(fileWriter); |
| 82 } | 82 } |
| 83 var jsTestIsAsync = true; | 83 var jsTestIsAsync = true; |
| 84 setupAndRunTest(2*1024*1024, 'file-writer-abort', runTest); | 84 setupAndRunTest(2*1024*1024, 'file-writer-abort', runTest); |
| OLD | NEW |