Commit 65abad13 authored by lucas.parsy's avatar lucas.parsy

corrected bug preventing to download slice of attachment in indexeddbstorage

added test verifying that the bug is corrected.
parent 9d15334f
......@@ -350,6 +350,7 @@
var array_buffer_list = [],
blob,
i,
index,
len = result_list.length;
for (i = 0; i < len; i += 1) {
array_buffer_list.push(result_list[i].blob);
......@@ -357,8 +358,10 @@
if ((options.start === undefined) && (options.end === undefined)) {
return new Blob(array_buffer_list, {type: type});
}
index = Math.floor(start / UNITE) * UNITE;
blob = new Blob(array_buffer_list, {type: "application/octet-stream"});
return blob.slice(start, end, "application/octet-stream");
return blob.slice(start - index, end - index,
"application/octet-stream");
});
};
......
......@@ -1319,6 +1319,38 @@
});
});
test("retrieving slice of data", function () {
var context = this,
attachment = "attachment";
stop();
expect(1);
deleteIndexedDB(context.jio)
.then(function () {
return context.jio.put("foo", {"title": "bar"});
})
.then(function () {
return context.jio.putAttachment("foo", attachment, big_string);
})
.then(function () {
return context.jio.getAttachment("foo", attachment,
{"start": 2000005, "end": 2000015});
})
.then(function (result) {
return jIO.util.readBlobAsText(result);
})
.then(function (result) {
var expected = "aaaaaaaaaa";
equal(result.target.result, expected, "Attachment correctly fetched");
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
/////////////////////////////////////////////////////////////////
// indexeddbStorage.removeAttachment
/////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment