summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/indexeddb/resources/shared.js
blob: e510be18cbc1d8cdcb3b773fceb5fbdd07d08b06 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function done()
{
    isSuccessfullyParsed();
    if (window.layoutTestController)
        layoutTestController.notifyDone()
}

function verifyEventCommon(event)
{
    shouldBeTrue("'source' in event");
    shouldBeTrue("event.source != null");
    shouldBeTrue("'onsuccess' in event.target");
    shouldBeTrue("'onerror' in event.target");
    shouldBeTrue("'abort' in event.target");
    shouldBeTrue("'readyState' in event.target");
    shouldBe("event.target.readyState", "event.target.DONE");
    debug("");
}

function verifyErrorEvent(event)
{
    debug("Error event fired:");
    shouldBeFalse("'result' in event");
    shouldBeTrue("'code' in event");
    shouldBeTrue("'message' in event");
    verifyEventCommon(event);
}

function verifySuccessEvent(event)
{
    debug("Success event fired:");
    shouldBeTrue("'result' in event");
    shouldBeFalse("'code' in event");
    shouldBeFalse("'message' in event");
    verifyEventCommon(event);
}

function verifyResult(result)
{
    shouldBeTrue("'onsuccess' in result");
    shouldBeTrue("'onerror' in result");
    shouldBeTrue("'abort' in result");
    shouldBeTrue("'readyState' in result");
    debug("An event should fire shortly...");
    debug("");
}

function unexpectedErrorCallback()
{
    testFailed("Error function called unexpectedly: (" + event.code + ") " + event.message);
    debug("");
    verifyErrorEvent(event);
    done();
}