summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbdatabase_close2.htm
blob: 68bafb9463828d75be8a6c513dfa8f5f6bb167cf (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<title>IDBDatabase.close() - unblock the delete database request</title>
<link rel="author" title="Microsoft" href="http://www.microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>

<script>

var db;
var blocked_fired = false;
var versionchange_fired = false;
var t = async_test();
var open_rq = createdb(t);

open_rq.onupgradeneeded = t.step_func(function() {});
open_rq.onsuccess = t.step_func(function(e) {
    db = e.target.result;

    db.onversionchange = t.step_func(function (e) {
      versionchange_fired = true;
    });

    var rq = window.indexedDB.deleteDatabase(db.name);
    rq.onblocked = t.step_func(function (e) {
        blocked_fired = true;
        db.close();
    });
    rq.onsuccess = t.step_func(function (e) {
        assert_true(versionchange_fired, "versionchange event fired")
        assert_true(blocked_fired, "block event fired")
        t.done();
    });
    rq.onerror = fail(t, 'Unexpected database deletion error');
});

</script>

<div id="log"></div>