summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbrequest_error.html
blob: 73dd13383ff343d846f703ebd094e2ea6e320471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<meta charset=utf-8>
<title>IDBRequest.error</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=resources/support.js></script>

<script>
async_test(t => {
  var open = createdb(t);
  open.onupgradeneeded = t.step_func(e => {
    var db = e.target.result;
    db.createObjectStore('store');
  });
  open.onsuccess = t.step_func(e => {
    var db = e.target.result;
    var request = db.transaction('store', 'readonly', {durability: 'relaxed'}).objectStore('store').get(0);

    assert_equals(request.readyState, 'pending');
    assert_throws_dom('InvalidStateError', () => request.error,
                      'IDBRequest.error should throw if request is pending');
    t.done();
  });
}, 'IDBRequest.error throws if ready state is pending');
</script>