OLD | NEW |
---|---|
1 Confirm basic Blob/File/FileList functionality. | 1 Confirm basic Blob/File/FileList functionality. |
2 | 2 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ". |
4 | 4 |
5 | 5 |
6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self. msIndexedDB || self.OIndexedDB; | 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self. msIndexedDB || self.OIndexedDB; |
7 | 7 |
8 dbname = "blob-basics-metadata.html" | 8 dbname = "blob-basics-metadata.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
11 store = db.createObjectStore('storeName') | 11 store = db.createObjectStore('storeName') |
12 store.put('value', 'key') | 12 store.put('value', 'key') |
13 | 13 |
14 testBlob(): | 14 testBlob(): |
15 PASS FileReader != null is true | 15 PASS FileReader != null is true |
16 test_content = 'This is a test. This is only a test.' | 16 test_content = 'This is a test. This is only a test.' |
17 blob = new Blob([test_content]) | 17 blob = new Blob([test_content]) |
18 | 18 |
19 validateResult(blob): | 19 validateResult(blob): |
20 PASS blob.size == test_content.length is true | |
20 transaction = db.transaction('storeName', 'readwrite') | 21 transaction = db.transaction('storeName', 'readwrite') |
21 store = transaction.objectStore('storeName') | 22 store = transaction.objectStore('storeName') |
22 store.put(blob, 'blobkey') | 23 store.put(blob, 'blobkey') |
23 transaction = db.transaction('storeName', 'readwrite') | 24 transaction = db.transaction('storeName', 'readwrite') |
24 store = transaction.objectStore('storeName') | 25 store = transaction.objectStore('storeName') |
25 request = store.get('blobkey') | 26 request = store.get('blobkey') |
26 PASS event.target.result.size == test_content.length is true | 27 PASS event.target.result.size == test_content.length is true |
27 | 28 |
28 testFile(): | 29 testFile(): |
29 file = fileInput.files[0] | 30 file = fileInput.files[0] |
30 | 31 |
31 validateResult(file): | 32 validateResult(file): |
33 PASS file.name == fileInput.files[0].name is true | |
32 transaction = db.transaction('storeName', 'readwrite') | 34 transaction = db.transaction('storeName', 'readwrite') |
33 store = transaction.objectStore('storeName') | 35 store = transaction.objectStore('storeName') |
34 store.put(file, 'filekey') | 36 store.put(file, 'filekey') |
35 transaction = db.transaction('storeName', 'readwrite') | 37 transaction = db.transaction('storeName', 'readwrite') |
36 store = transaction.objectStore('storeName') | 38 store = transaction.objectStore('storeName') |
37 request = store.get('filekey') | 39 request = store.get('filekey') |
38 PASS event.target.result.name == fileInput.files[0].name is true | 40 PASS event.target.result.name == fileInput.files[0].name is true |
39 | 41 |
40 testFileList(): | 42 testFileList(): |
41 filelist = fileInput.files | 43 filelist = fileInput.files |
42 | 44 |
43 validateResult(filelist): | 45 validateResult(filelist): |
46 PASS filelist[1].name == fileInput.files[1].name is true | |
44 transaction = db.transaction('storeName', 'readwrite') | 47 transaction = db.transaction('storeName', 'readwrite') |
45 store = transaction.objectStore('storeName') | 48 store = transaction.objectStore('storeName') |
46 store.put(filelist, 'filelistkey') | 49 store.put(filelist, 'filelistkey') |
47 transaction = db.transaction('storeName', 'readwrite') | 50 transaction = db.transaction('storeName', 'readwrite') |
48 store = transaction.objectStore('storeName') | 51 store = transaction.objectStore('storeName') |
49 request = store.get('filelistkey') | 52 request = store.get('filelistkey') |
50 PASS event.target.result[1].name == fileInput.files[1].name is true | 53 PASS event.target.result[1].name == fileInput.files[1].name is true |
51 | 54 |
52 testCursor(): | 55 testCursor(): |
53 transaction = db.transaction('storeName', 'readonly') | 56 transaction = db.transaction('storeName', 'readonly') |
54 store = transaction.objectStore('storeName') | 57 store = transaction.objectStore('storeName') |
55 request = store.openCursor() | 58 request = store.openCursor() |
56 PASS cursor.value.size == test_content.length is true | 59 PASS cursor.value.size == test_content.length is true |
57 cursor.continue(); | 60 cursor.continue(); |
58 PASS cursor.value.name == fileInput.files[0].name is true | 61 PASS cursor.value.name == fileInput.files[0].name is true |
cmumford
2015/03/14 14:18:50
This CL is a little old now. If you rebase on ToT
| |
59 cursor.continue(); | 62 cursor.continue(); |
60 PASS cursor.value[1].name == fileInput.files[1].name is true | 63 PASS cursor.value[1].name == fileInput.files[1].name is true |
61 cursor.continue(); | 64 cursor.continue(); |
62 PASS cursor.value == 'value' is true | 65 PASS cursor.value == 'value' is true |
63 cursor.continue(); | 66 cursor.continue(); |
64 PASS cursor is null | 67 PASS cursor is null |
65 PASS successfullyParsed is true | 68 PASS successfullyParsed is true |
66 | 69 |
67 TEST COMPLETE | 70 TEST COMPLETE |
68 | 71 |
OLD | NEW |