summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idb_webworkers.htm
blob: 5a061c26502413c20c333c574a6afe3e61002efc (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
<!DOCTYPE html>
<title>IndexedDB inside of a WebWorker </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="resources/support.js"></script>

<script>
    var db, count = 0,
      t = async_test();
      t.add_cleanup(function() { indexedDB.deleteDatabase('webworker101'); });

    t.step(function() {
        var worker = new Worker("resources/idbworker.js");
        worker.onmessage = t.step_func(function (e) {
            switch(count) {
                case 0:
                    assert_equals(e.data, true, 'worker has idb object')
                    break

                case 1:
                    assert_equals(e.data, "test", "get(1) in worker")
                    t.done()
            }

            count++
        });

        worker.postMessage(1);
    })
</script>