Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: content/test/data/indexeddb/empty_blob.html

Issue 942633004: IndexedDB: Fixed support for empty blobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test cleanup & added blob delete to test. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/indexed_db_context.h ('k') | storage/browser/blob/blob_data_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2015 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
7 -->
8 <head>
9 <title>IDB Test that we can store and retrieve an empty blob</title>
10 <script src="common.js"></script>
11 <script>
12
13 // Constants.
14 var store_name = 'empty_blob';
15 var blob_key = 'blob_key';
16 var file_key = 'file_key';
17
18 // Shared variables.
19 var db;
20 var emptyFileInput;
21
22 function test() {
23 indexedDBTest(prepareDatabase, writeBlob);
24 }
25
26 function prepareDatabase() {
27 db = event.target.result;
28 db.createObjectStore(store_name);
29 }
30
31 function writeBlob() {
32 debug("Writing blob.");
33
34 put_blob = new Blob();
35
36 var put_tx = db.transaction(store_name, 'readwrite');
37 put_tx.onabort = unexpectedAbortCallback;
38 var put_request = put_tx.objectStore(store_name).put(put_blob, blob_key);
39 put_request.onerror = unexpectedErrorCallback;
40 put_tx.oncomplete = function () {
41 var get_tx = db.transaction(store_name);
42 get_tx.onabort = unexpectedAbortCallback;
43 get_tx.oncomplete = writeFile;
jsbell 2015/03/03 23:37:57 Maybe move this to the end of the block as well.
cmumford 2015/03/06 18:02:09 Done.
44
45 var get_request = get_tx.objectStore(store_name).get(blob_key);
46 get_request.onerror = unexpectedErrorCallback;
47 get_request.onsuccess = function(evt) {
48 get_blob = evt.target.result;
49 resultType = typeof get_blob;
50 shouldBe('resultType', '"object"');
51 shouldBe('get_blob.size', '0');
52 };
53 };
54 }
55
56 function writeFile() {
57 put_file = new File([''], 'somefile', {
58 type: 'application/x-special-snowflake',
59 lastModified: new Date('1999-12-31T23:59:59Z')
60 });
61 var put_tx = db.transaction(store_name, 'readwrite');
62 put_tx.objectStore(store_name).put(put_file, file_key);
63 put_tx.onabort = unexpectedAbortCallback;
64 put_tx.oncomplete = function() {
65 var get_tx = db.transaction(store_name);
66 get_tx.onabort = unexpectedAbortCallback;
67 get_tx.oncomplete = deleteFile;
jsbell 2015/03/03 23:37:57 Ditto.
cmumford 2015/03/06 18:02:10 Done.
68 get_tx.objectStore(store_name).get(file_key).onsuccess = function(e) {
69 get_file = e.target.result;
70
71 shouldBe('get_file.name', 'put_file.name');
72 shouldBe('get_file.size', 'put_file.size');
73 shouldBe('get_file.type', 'put_file.type');
74 shouldBe('get_file.lastModified', 'put_file.lastModified');
75 shouldBe('String(get_file.lastModifiedDate)', 'String(put_file.lastModifie dDate)');
76 };
77 };
78 }
79
80 function deleteBlob() {
jsbell 2015/03/03 23:37:57 Maybe move this below deleteFile(), to follow exec
cmumford 2015/03/06 18:02:09 Done.
81 var tx = db.transaction(store_name, 'readwrite');
82 tx.objectStore(store_name).delete(blob_key);
83 tx.onabort = unexpectedAbortCallback;
84 tx.oncomplete = done;
85 }
86
87 function deleteFile() {
88 var tx = db.transaction(store_name, 'readwrite');
89 tx.objectStore(store_name).delete(file_key);
90 tx.onabort = unexpectedAbortCallback;
91 tx.oncomplete = deleteBlob;
92 }
93
94 </script>
95 </head>
96 <body onLoad="test()">
97 <div id="status">Starting...</div>
98 </body>
99 </html>
OLDNEW
« no previous file with comments | « content/public/browser/indexed_db_context.h ('k') | storage/browser/blob/blob_data_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698