3d5fd17a2267948d5c7d647361bad35deb552b35
[gecko.git] / idbobjectstore_count3.htm
blob3d5fd17a2267948d5c7d647361bad35deb552b35
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>IDBObjectStore.count() - returns the number of records that have keys with the key</title>
4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
5 <script src=/resources/testharness.js></script>
6 <script src=/resources/testharnessreport.js></script>
7 <script src=resources/support.js></script>
9 <script>
10 var db
12 createdb(async_test()).onupgradeneeded = function(e) {
13 db = e.target.result
15 var store = db.createObjectStore("store", { keyPath: "k" })
17 for (var i = 0; i < 5; i++)
18 store.add({ k: "key_" + i });
20 store.count("key_2").onsuccess = this.step_func(function(e) {
21 assert_equals(e.target.result, 1, "count(key_2)")
23 store.count("key_").onsuccess = this.step_func(function(e) {
24 assert_equals(e.target.result, 0, "count(key_)")
25 this.done()
30 </script>
31 <div id=log></div>