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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/test/data/indexeddb/empty_blob.html
diff --git a/content/test/data/indexeddb/empty_blob.html b/content/test/data/indexeddb/empty_blob.html
new file mode 100644
index 0000000000000000000000000000000000000000..36bbf36ec68b9776aaf3c57cdcc924e8c92d84bf
--- /dev/null
+++ b/content/test/data/indexeddb/empty_blob.html
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html>
+<!--
+ Copyright 2015 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+-->
+<head>
+<title>IDB Test that we can store and retrieve an empty blob</title>
+<script src="common.js"></script>
+<script>
+
+// Constants.
+var store_name = 'empty_blob';
+var blob_key = 'blob_key';
+var file_key = 'file_key';
+
+// Shared variables.
+var db;
+var emptyFileInput;
+var testTimes = false;
+
+function test() {
+ param = location.hash.substring(1);
+ if (param == 'ignoreTimes') {
+ testTimes = false;
+ }
+ indexedDBTest(prepareDatabase, writeBlob);
+}
+
+function prepareDatabase() {
+ db = event.target.result;
+ db.createObjectStore(store_name);
+}
+
+function writeBlob() {
+ debug("Writing blob.");
+
+ put_blob = new Blob();
+
+ var put_tx = db.transaction(store_name, 'readwrite');
+ put_tx.onabort = unexpectedAbortCallback;
+ var put_request = put_tx.objectStore(store_name).put(put_blob, blob_key);
+ put_request.onerror = unexpectedErrorCallback;
+ put_tx.oncomplete = function () {
+ var get_tx = db.transaction(store_name);
+
+ var get_request1 = get_tx.objectStore(store_name).get(blob_key);
+ get_request1.onerror = unexpectedErrorCallback;
+ get_request1.onsuccess = function(evt) {
+ get_blob1 = evt.target.result;
+ resultType = typeof get_blob1;
+ shouldBe('resultType', '"object"');
+ shouldBe('get_blob1.size', 'put_blob.size');
+ };
+
+ var get_request2 = get_tx.objectStore(store_name).get(blob_key);
+ get_request2.onerror = unexpectedErrorCallback;
+ get_request2.onsuccess = function(evt) {
+ get_blob2 = evt.target.result;
+ resultType = typeof get_blob2;
+ shouldBe('resultType', '"object"');
+ shouldBe('get_blob2.size', 'put_blob.size');
+ };
+
+ get_tx.onabort = unexpectedAbortCallback;
+ get_tx.oncomplete = writeFile;
+ };
+}
+
+function writeFile() {
+ put_file = new File([''], 'somefile', {
+ type: 'application/x-special-snowflake',
+ lastModified: new Date('1999-12-31T23:59:59Z')
+ });
+ var put_tx = db.transaction(store_name, 'readwrite');
+ put_tx.objectStore(store_name).put(put_file, file_key);
+ put_tx.onabort = unexpectedAbortCallback;
+ put_tx.oncomplete = function() {
+ var get_tx = db.transaction(store_name);
+ get_tx.objectStore(store_name).get(file_key).onsuccess = function(e) {
+ get_file = e.target.result;
+
+ shouldBe('get_file.name', 'put_file.name');
+ shouldBe('get_file.size', 'put_file.size');
+ shouldBe('get_file.type', 'put_file.type');
+ if (testTimes) {
+ shouldBe('get_file.lastModified', 'put_file.lastModified');
+ shouldBe('String(get_file.lastModifiedDate)', 'String(put_file.lastModifiedDate)');
+ }
+ };
+ get_tx.onabort = unexpectedAbortCallback;
+ get_tx.oncomplete = deleteFile;
+ };
+}
+
+function deleteFile() {
+ var tx = db.transaction(store_name, 'readwrite');
+ tx.objectStore(store_name).delete(file_key);
+ tx.onabort = unexpectedAbortCallback;
+ tx.oncomplete = deleteBlob;
+}
+
+function deleteBlob() {
+ var tx = db.transaction(store_name, 'readwrite');
+ tx.objectStore(store_name).delete(blob_key);
+ tx.onabort = unexpectedAbortCallback;
+ tx.oncomplete = done;
+}
+
+</script>
+</head>
+<body onLoad="test()">
+ <div id="status">Starting...</div>
+</body>
+</html>
« 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