Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
jio
Commits
11370391
Commit
11370391
authored
Aug 07, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indexeddb getAttachment returns faulty string for huge attachments
parent
38b83a9a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
7 deletions
+61
-7
test/big_test_map
test/big_test_map
+1
-0
test/jio.storage/indexeddbstorage.tests.js
test/jio.storage/indexeddbstorage.tests.js
+57
-5
test/tests.html
test/tests.html
+3
-2
No files found.
test/big_test_map
0 → 100644
View file @
11370391
This diff is collapsed.
Click to expand it.
test/jio.storage/indexeddbstorage.tests.js
View file @
11370391
...
...
@@ -21,7 +21,7 @@
/*global indexedDB, Blob, sinon, IDBDatabase,
IDBTransaction, IDBIndex, IDBObjectStore, IDBCursor, IDBKeyRange*/
(
function
(
jIO
,
QUnit
,
indexedDB
,
Blob
,
sinon
,
IDBDatabase
,
IDBTransaction
,
IDBIndex
,
IDBObjectStore
,
IDBCursor
,
IDBKeyRange
)
{
IDBTransaction
,
IDBIndex
,
IDBObjectStore
,
IDBCursor
,
IDBKeyRange
,
Rusha
)
{
"
use strict
"
;
var
test
=
QUnit
.
test
,
stop
=
QUnit
.
stop
,
...
...
@@ -32,7 +32,8 @@
equal
=
QUnit
.
equal
,
module
=
QUnit
.
module
,
big_string
=
""
,
j
;
j
,
rusha
=
new
Rusha
();
for
(
j
=
0
;
j
<
3000000
;
j
+=
1
)
{
big_string
+=
"
a
"
;
...
...
@@ -1303,9 +1304,11 @@
test
(
"
check result
"
,
function
()
{
var
context
=
this
,
attachment
=
"
attachment
"
;
attachment
=
"
attachment
"
,
expected_hash
,
received_blob
;
stop
();
expect
(
3
);
expect
(
4
);
deleteIndexedDB
(
context
.
jio
)
.
then
(
function
()
{
...
...
@@ -1318,6 +1321,7 @@
return
context
.
jio
.
getAttachment
(
"
foo
"
,
attachment
);
})
.
then
(
function
(
result
)
{
received_blob
=
result
;
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
equal
(
result
.
type
,
"
text/plain;charset=utf-8
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
...
...
@@ -1326,6 +1330,54 @@
ok
(
result
.
target
.
result
===
big_string
,
"
Attachment correctly fetched
"
);
})
.
then
(
function
()
{
return
jIO
.
util
.
readBlobAsArrayBuffer
(
new
Blob
([
big_string
]));
})
.
then
(
function
(
result
)
{
expected_hash
=
rusha
.
digestFromArrayBuffer
(
result
.
target
.
result
);
return
jIO
.
util
.
readBlobAsArrayBuffer
(
received_blob
);
})
.
then
(
function
(
result
)
{
ok
(
rusha
.
digestFromArrayBuffer
(
result
.
target
.
result
)
===
expected_hash
,
"
Hash of string sent same as hash of string received
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
huge attachment
"
,
function
(){
var
context
=
this
,
big_string
,
big_string_as_array
;
stop
();
deleteIndexedDB
(
context
.
jio
)
.
then
(
function
()
{
return
jIO
.
util
.
ajax
({
url
:
"
big_test_map
"
});
})
.
then
(
function
(
result
)
{
big_string
=
result
.
currentTarget
.
responseText
;
return
jIO
.
util
.
readBlobAsArrayBuffer
(
new
Blob
([
big_string
]));
})
.
then
(
function
(
result
)
{
big_string_as_array
=
result
.
target
.
result
;
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
"
);
})
.
then
(
function
(
result
)
{
return
jIO
.
util
.
readBlobAsArrayBuffer
(
result
);
})
.
then
(
function
(
result
)
{
ok
(
rusha
.
digestFromArrayBuffer
(
result
.
target
.
result
)
===
rusha
.
digestFromArrayBuffer
(
big_string_as_array
),
"
Hash of string sent same as hash of string received
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
...
...
@@ -1724,4 +1776,4 @@
});
}(
jIO
,
QUnit
,
indexedDB
,
Blob
,
sinon
,
IDBDatabase
,
IDBTransaction
,
IDBIndex
,
IDBObjectStore
,
IDBCursor
,
IDBKeyRange
));
IDBTransaction
,
IDBIndex
,
IDBObjectStore
,
IDBCursor
,
IDBKeyRange
,
Rusha
));
test/tests.html
View file @
11370391
...
...
@@ -28,12 +28,13 @@ See https://www.nexedi.com/licensing for rationale and options.
<link
rel=
"stylesheet"
href=
"../external/qunit.css"
type=
"text/css"
media=
"screen"
/>
<script
src=
"../external/qunit.js"
type=
"text/javascript"
></script>
<script
src=
"../external/sinon.js"
type=
"text/javascript"
></script>
<script
src=
"../external/rusha.js"
type=
"text/javascript"
></script>
<!--<script src ="./elasticlunr.js"></script>
<script src="./elasticlunrstorage.js"></script>-->
<script>
QUnit
.
config
.
testTimeout
=
5000
;
QUnit
.
config
.
testTimeout
=
5000
0
;
</script>
<!--script src="html5.js"></script-->
<!--script src="jio/util.js"></script-->
...
...
@@ -80,7 +81,7 @@ See https://www.nexedi.com/licensing for rationale and options.
<!--script src="jio.storage/websqlstorage.tests.js"></script-->
<script
src=
"jio.storage/fbstorage.tests.js"
></script>
<script
src=
"jio.storage/httpstorage.tests.js"
></script>
<
script
src=
"jio.storage/elasticlunrstorage.tests.js"
></script
>
<
!--<script src="jio.storage/elasticlunrstorage.tests.js"></script>--
>
<!--script src="../src/jio.storage/xwikistorage.js"></script>
<script src="jio.storage/xwikistorage.tests.js"></script-->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment