1 if (this.importScripts
) {
2 importScripts('fs-worker-common.js');
3 importScripts('../../../resources/js-test.js');
4 importScripts('file-writer-utils.js');
7 description("Test that FileWriter defends against infinite recursion via abort.");
13 var blob
= new Blob(["lorem ipsum"]);
14 var recursionDepth
= 0;
18 function onWriteStart(e
) {
19 testPassed("Calling abort");
24 // We should always abort before completion.
26 testFailed("In onWrite.");
30 testPassed("Saw abort");
34 assert(ex
.name
== 'SecurityError');
35 testPassed("Saw security error");
39 function onWriteEnd(e
) {
41 testPassed("Saw writeend.");
42 if (!recursionDepth
) {
46 testPassed("Calling truncate.");
49 setTimeout(method
, 0); // Invoke from the top level, so that we're not already in a handler.
56 function runTest(unusedFileEntry
, fileWriter
) {
58 method = function () {
59 testPassed("Calling write.");
62 fileWriter
.onerror
= onError
;
63 fileWriter
.onabort
= onAbort
;
64 fileWriter
.onwritestart
= onWriteStart
;
65 fileWriter
.onwrite
= onWrite
;
66 fileWriter
.onwriteend
= onWriteEnd
;
70 var jsTestIsAsync
= true;
71 setupAndRunTest(2*1024*1024, 'file-writer-abort-depth', runTest
);