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

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: Added bug for test re: Android 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
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 var testTimes = false;
22
23 function test() {
24 param = location.hash.substring(1);
25 if (param == 'ignoreTimes') {
26 testTimes = false;
27 }
28 indexedDBTest(prepareDatabase, writeBlob);
29 }
30
31 function prepareDatabase() {
32 db = event.target.result;
33 db.createObjectStore(store_name);
34 }
35
36 function writeBlob() {
37 debug("Writing blob.");
38
39 put_blob = new Blob();
40
41 var put_tx = db.transaction(store_name, 'readwrite');
42 put_tx.onabort = unexpectedAbortCallback;
43 var put_request = put_tx.objectStore(store_name).put(put_blob, blob_key);
44 put_request.onerror = unexpectedErrorCallback;
45 put_tx.oncomplete = function () {
46 var get_tx = db.transaction(store_name);
47
48 var get_request1 = get_tx.objectStore(store_name).get(blob_key);
49 get_request1.onerror = unexpectedErrorCallback;
50 get_request1.onsuccess = function(evt) {
51 get_blob1 = evt.target.result;
52 resultType = typeof get_blob1;
53 shouldBe('resultType', '"object"');
54 shouldBe('get_blob1.size', 'put_blob.size');
55 };
56
57 var get_request2 = get_tx.objectStore(store_name).get(blob_key);
58 get_request2.onerror = unexpectedErrorCallback;
59 get_request2.onsuccess = function(evt) {
60 get_blob2 = evt.target.result;
61 resultType = typeof get_blob2;
62 shouldBe('resultType', '"object"');
63 shouldBe('get_blob2.size', 'put_blob.size');
64 };
65
66 get_tx.onabort = unexpectedAbortCallback;
67 get_tx.oncomplete = writeFile;
68 };
69 }
70
71 function writeFile() {
72 put_file = new File([''], 'somefile', {
73 type: 'application/x-special-snowflake',
74 lastModified: new Date('1999-12-31T23:59:59Z')
75 });
76 var put_tx = db.transaction(store_name, 'readwrite');
77 put_tx.objectStore(store_name).put(put_file, file_key);
78 put_tx.onabort = unexpectedAbortCallback;
79 put_tx.oncomplete = function() {
80 var get_tx = db.transaction(store_name);
81 get_tx.objectStore(store_name).get(file_key).onsuccess = function(e) {
82 get_file = e.target.result;
83
84 shouldBe('get_file.name', 'put_file.name');
85 shouldBe('get_file.size', 'put_file.size');
86 shouldBe('get_file.type', 'put_file.type');
87 if (testTimes) {
88 shouldBe('get_file.lastModified', 'put_file.lastModified');
89 shouldBe('String(get_file.lastModifiedDate)', 'String(put_file.lastModif iedDate)');
90 }
91 };
92 get_tx.onabort = unexpectedAbortCallback;
93 get_tx.oncomplete = deleteFile;
94 };
95 }
96
97 function deleteFile() {
98 var tx = db.transaction(store_name, 'readwrite');
99 tx.objectStore(store_name).delete(file_key);
100 tx.onabort = unexpectedAbortCallback;
101 tx.oncomplete = deleteBlob;
102 }
103
104 function deleteBlob() {
105 var tx = db.transaction(store_name, 'readwrite');
106 tx.objectStore(store_name).delete(blob_key);
107 tx.onabort = unexpectedAbortCallback;
108 tx.oncomplete = done;
109 }
110
111 </script>
112 </head>
113 <body onLoad="test()">
114 <div id="status">Starting...</div>
115 </body>
116 </html>
OLDNEW
« no previous file with comments | « content/browser/loader/upload_data_stream_builder_unittest.cc ('k') | storage/browser/blob/blob_data_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698