| 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>
|
|
|