diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/blob-contenttype.any.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/blob-contenttype.any.js')
-rw-r--r-- | testing/web-platform/tests/IndexedDB/blob-contenttype.any.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/blob-contenttype.any.js b/testing/web-platform/tests/IndexedDB/blob-contenttype.any.js new file mode 100644 index 0000000000..2d1d6a1ec9 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/blob-contenttype.any.js @@ -0,0 +1,39 @@ +// META: title=Blob Content Type +// META: script=resources/support.js +// META: timeout=long + +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', {durability: 'relaxed'}); + tx.objectStore('store').put(blob, 'key'); + + tx.oncomplete = t.step_func(function() { + var tx = db.transaction('store', 'readonly', {durability: 'relaxed'}); + 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' +); |