summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/filesystem/resources/file-writer-gc-blob.js
blob: 47433ddecb83ad3cc45596761586f71c1f2f0a9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if (this.importScripts) {
    importScripts('fs-worker-common.js');
    importScripts('../../../resources/js-test.js');
    importScripts('file-writer-utils.js');
}

description("Test that a blob won't get garbage-collected while being written out by a FileWriter.");

var fileEntry;

function onTestSuccess() {
    testPassed("Successfully wrote blob.");
    cleanUp();
}

function tenXBlob(blob) {
    var bb = [];
    for (var i = 0; i < 10; ++i) {
        bb.push(blob);
    }
    return new Blob(bb);
}

function startWrite(writer) {
    // Let's make it about a megabyte.
    var blob = tenXBlob(new Blob(["lorem ipsum"]));
    blob = tenXBlob(blob);
    blob = tenXBlob(blob);
    blob = tenXBlob(blob);
    blob = tenXBlob(blob);
    writer.onerror = onError;
    writer.onwriteend = onTestSuccess;
    writer.write(blob);
}

function runTest(unusedFileEntry, fileWriter) {
    startWrite(fileWriter);
    gc();
}
var jsTestIsAsync = true;
setupAndRunTest(2*1024*1024, 'file-writer-gc-blob', runTest);