2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
6 function indexeddb_test(upgrade_func, body_func, description) {
7 async_test(function(t) {
8 var dbname = location.pathname + ' - ' + description;
9 var deleteRequest = indexedDB.deleteDatabase(dbname);
10 deleteRequest.onsuccess = t.step_func(function() {
11 var openRequest = indexedDB.open(dbname);
12 openRequest.onupgradeneeded = t.step_func(function() {
13 upgrade_func(t, openRequest.result);
15 openRequest.onsuccess = t.step_func(function() {
16 body_func(t, openRequest.result);
18 openRequest.onerror = t.unreached_func('open failed');
24 function upgrade(t, db) {
25 db.createObjectStore('store');
27 function success(t, db) {
28 var type = 'x-files/trust-no-one';
30 var blob = new Blob(['mulder', 'scully'], {type: type});
31 assert_equals(blob.type, type, 'Blob type should match constructor option');
33 var tx = db.transaction('store', 'readwrite');
34 tx.objectStore('store').put(blob, 'key');
36 tx.oncomplete = t.step_func(function() {
37 var tx = db.transaction('store');
38 tx.objectStore('store').get('key').onsuccess = t.step_func(function(e) {
39 var result = e.target.result;
40 assert_equals(result.type, type, 'Blob type should survive round-trip');
42 var url = URL.createObjectURL(result);
43 var xhr = new XMLHttpRequest(), async = true;
44 xhr.open('GET', url, async);
46 xhr.onreadystatechange = t.step_func(function() {
47 if (xhr.readyState !== XMLHttpRequest.DONE)
49 assert_equals(xhr.getResponseHeader('Content-Type'), type,
50 'Blob type should be preserved when fetched');
56 'Ensure that content type round trips when reading blob data'