Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / constructed-file-attributes.html
blob7ca5f42408f83db0a4d1ada6c01da825cd131c51
1 <!DOCTYPE html>
2 <title>Indexed DB: Serialization of constructed File attribute</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
7 function indexeddb_test(upgrade_func, body_func, description) {
8 async_test(function(t) {
9 var dbname = location.pathname + ' - ' + description;
10 var deleteRequest = indexedDB.deleteDatabase(dbname);
11 deleteRequest.onsuccess = t.step_func(function() {
12 var openRequest = indexedDB.open(dbname);
13 openRequest.onupgradeneeded = t.step_func(function() {
14 upgrade_func(t, openRequest.result);
15 });
16 openRequest.onsuccess = t.step_func(function() {
17 body_func(t, openRequest.result);
18 });
19 openRequest.onerror = t.unreached_func('open failed');
20 });
21 }, description);
24 indexeddb_test(
25 function upgrade(t, db) {
26 db.createObjectStore('store');
28 function success(t, db) {
29 var party_time = new Date('1999-12-31T23:59:59Z');
30 var file = new File(['content'], 'somefile', {
31 type: 'application/x-special-snowflake',
32 lastModified: party_time
33 });
34 var tx = db.transaction('store', 'readwrite');
35 tx.objectStore('store').put(file, 'key');
37 tx.oncomplete = t.step_func(function() {
38 var tx = db.transaction('store');
39 tx.objectStore('store').get('key').onsuccess = t.step_func(function(e) {
40 var result = e.target.result;
42 assert_equals(result.name, file.name,
43 'name attribute should round-trip');
44 assert_equals(result.size, file.size,
45 'size attribute should round-trip');
46 assert_equals(result.type, file.type,
47 'type attribute should round-trip');
48 assert_equals(result.lastModified, file.lastModified,
49 'lastModified attribute should round-trip');
50 assert_equals(String(result.lastModifiedDate), String(file.lastModifiedDate),
51 'lastModifiedDate attribute should round-trip');
53 t.done();
54 });
55 });
57 'Attribute persistence of constructed File objects'
60 </script>