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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script>
5
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);
14 });
15 openRequest.onsuccess = t.step_func(function() {
16 body_func(t, openRequest.result);
17 });
18 openRequest.onerror = t.unreached_func('open failed');
19 });
20 }, description);
21 }
22
23 indexeddb_test(
24 function upgrade(t, db) {
25 db.createObjectStore('store');
26 },
27 function success(t, db) {
28 var type = 'x-files/trust-no-one';
29
30 var blob = new Blob(['mulder', 'scully'], {type: type});
31 assert_equals(blob.type, type, 'Blob type should match constructor optio n');
32
33 var tx = db.transaction('store', 'readwrite');
34 tx.objectStore('store').put(blob, 'key');
35
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');
41
42 var url = URL.createObjectURL(result);
43 var xhr = new XMLHttpRequest(), async = true;
44 xhr.open('GET', url, async);
45 xhr.send();
46 xhr.onreadystatechange = t.step_func(function() {
47 if (xhr.readyState !== XMLHttpRequest.DONE)
48 return;
49 assert_equals(xhr.getResponseHeader('Content-Type'), type,
50 'Blob type should be preserved when fetched');
51 t.done();
52 });
53 });
54 });
55 },
56 'Ensure that content type round trips when reading blob data'
57 );
58
59 </script>
OLDNEW
« 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