summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/indexeddb/script-tests/basics.js
blob: 307196aa3d39b18d91cf0c78ee16386e428ba664 (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
56
57
58
59
60
61
description("Test the basics of IndexedDB.");

if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.waitUntilDone();
}


function eventShared()
{
    debug("");
    shouldBeTrue("'source' in event");
    shouldBeTrue("'open' in event.source");
    debug("");
    shouldBeTrue("'result' in event");
    shouldBeFalse("'code' in event");
    shouldBeFalse("'message' in event");
    debug("");
    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("");
    window.successfullyParsed = true;
    isSuccessfullyParsed();
    if (window.layoutTestController)
            layoutTestController.notifyDone()
}

function successFunction()
{
    debug("Success function called");
    eventShared();
}

function errorFunction()
{
    testFailed("Error function called: (" + event.code + ") " + event.message);
    eventShared();
}

function test()
{
    shouldBeTrue("'indexedDB' in window");
    shouldBeTrue("'open' in indexedDB");

    result = evalAndLog("indexedDB.open('name', 'description', true /* allow modification */)");
    shouldBeTrue("'onsuccess' in result");
    shouldBeTrue("'onerror' in result");
    shouldBeTrue("'abort' in result");
    shouldBeTrue("'readyState' in result");
    result.onsuccess = successFunction;
    result.onerror = errorFunction;
    debug("");
    debug("An event should fire shortly...");
    debug("");
}

test();