File: transaction-requestqueue.htm

package info (click to toggle)
firefox-esr 91.13.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,375,652 kB
  • sloc: cpp: 5,762,054; javascript: 5,481,714; ansic: 3,121,191; python: 851,492; asm: 331,172; xml: 178,949; java: 155,554; sh: 63,704; makefile: 20,127; perl: 12,825; yacc: 4,583; cs: 3,846; objc: 3,026; lex: 1,720; exp: 762; pascal: 635; php: 436; lisp: 260; awk: 231; ruby: 103; sed: 53; sql: 46; csh: 45
file content (89 lines) | stat: -rw-r--r-- 2,478 bytes parent folder | download | duplicates (10)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<meta charset=utf-8>
<title>Transactions have a request queue</title>
<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=support.js></script>

<script>

var db, t = async_test(),
    keys = { txn: [], txn2: [] },
    open_rq = createdb(t)

open_rq.onupgradeneeded = function(e) {
    var i, os;
    db = e.target.result;

    for (i = 1; i < 6; i++)
    {
        os = db.createObjectStore("os" + i, { autoIncrement: true, keyPath: "k" });
        os.add({ os: "os" + i });
        os.put({ os: "os" + i, k: i});
        os.add({ os: "os" + i });
    }
}

open_rq.onsuccess = function(e) {
    var txn = db.transaction(["os2", "os1", "os3", "os5"])
    txn.objectStore("os1").openCursor().onsuccess = reg("txn")
    txn.objectStore("os3").openCursor().onsuccess = reg("txn")
    txn.objectStore("os1").get(2).onsuccess = reg("txn")
    txn.objectStore("os2").get(3).onsuccess = reg("txn")

    var txn2 = db.transaction(["os4", "os3", "os1", "os5"])
    var os4 = txn2.objectStore("os4")

    for (var i=0; i < 3; i++) {
        os4.openCursor().onsuccess = reg("txn2")
        os4.get(5).onsuccess = reg("txn2")
        os4.get(4).onsuccess = reg("txn2")
        txn.objectStore("os2").get(1).onsuccess = reg("txn")
        txn2.objectStore("os3").get(1).onsuccess = reg("txn2")
    }

    txn2.objectStore("os1").get(2).onsuccess = reg("txn2")
    txn.objectStore("os1").openCursor(null, "prev").onsuccess = reg("txn")
    os4.openCursor(null, "prev").onsuccess = reg("txn2")

    txn.oncomplete = t.step_func(finish);
    txn2.oncomplete = t.step_func(finish);
}


function reg(n) {
    return t.step_func(function (e) {
        var v = e.target.result;
        if (v.value) v = v.value;
        keys[n].push(v.os + ": " + v.k);
    });
}

var finish_to_go = 2;
function finish() {
    if (--finish_to_go)
        return;

    assert_array_equals(keys['txn'], [
        "os1: 1",
        "os3: 1",
        "os1: 2",
        "os2: 3",
        "os2: 1", "os2: 1", "os2: 1",
        "os1: 2",
    ], 'transaction keys');

    assert_array_equals(keys['txn2'], [
        "os4: 1", "os4: 5", "os4: 4", "os3: 1",
        "os4: 1", "os4: 5", "os4: 4", "os3: 1",
        "os4: 1", "os4: 5", "os4: 4", "os3: 1",
        "os1: 2",
        "os4: 5",
    ], 'transaction 2 keys');

    t.done();
}
</script>

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