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

Unified Diff: LayoutTests/storage/indexeddb/blob-contenttype.html

Issue 509213005: Indexed DB: Regression test to ensure Blobs preserve content-type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/storage/indexeddb/blob-contenttype.html
diff --git a/LayoutTests/storage/indexeddb/blob-contenttype.html b/LayoutTests/storage/indexeddb/blob-contenttype.html
new file mode 100644
index 0000000000000000000000000000000000000000..fec34e073856eee1991b1b47dc403a7d5e94027a
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/blob-contenttype.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+function indexeddb_test(upgrade_func, body_func, description) {
+ async_test(function(t) {
+ var dbname = location.pathname + ' - ' + description;
+ var deleteRequest = indexedDB.deleteDatabase(dbname);
+ deleteRequest.onsuccess = t.step_func(function() {
+ var openRequest = indexedDB.open(dbname);
+ openRequest.onupgradeneeded = t.step_func(function() {
+ upgrade_func(t, openRequest.result);
+ });
+ openRequest.onsuccess = t.step_func(function() {
+ body_func(t, openRequest.result);
+ });
+ openRequest.onerror = t.unreached_func('open failed');
+ });
+ }, description);
+}
+
+indexeddb_test(
+ function upgrade(t, db) {
+ db.createObjectStore('store');
+ },
+ function success(t, db) {
+ var type = 'x-files/trust-no-one';
+
+ var blob = new Blob(['mulder', 'scully'], {type: type});
+ assert_equals(blob.type, type, 'Blob type should match constructor option');
+
+ var tx = db.transaction('store', 'readwrite');
+ tx.objectStore('store').put(blob, 'key');
+
+ tx.oncomplete = t.step_func(function() {
+ var tx = db.transaction('store');
+ tx.objectStore('store').get('key').onsuccess = t.step_func(function(e) {
+ var result = e.target.result;
+ assert_equals(result.type, type, 'Blob type should survive round-trip');
+
+ var url = URL.createObjectURL(result);
+ var xhr = new XMLHttpRequest(), async = true;
+ xhr.open('GET', url, async);
+ xhr.send();
+ xhr.onreadystatechange = t.step_func(function() {
+ if (xhr.readyState !== XMLHttpRequest.DONE)
+ return;
+ assert_equals(xhr.getResponseHeader('Content-Type'), type,
+ 'Blob type should be preserved when fetched');
+ t.done();
+ });
+ });
+ });
+ },
+ 'Ensure that content type round trips when reading blob data'
+);
+
+</script>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698