OSDN Git Service

am c194fa2c: (-s ours) am ee4c9585: Cherry-pick WebKit security fix (webkit.org r6934...
[android-x86/external-webkit.git] / LayoutTests / storage / indexeddb / database-basics.html
1 <html>
2 <head>
3 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 <script src="../../fast/js/resources/js-test-post-function.js"></script>
6 <script src="resources/shared.js"></script>
7 </head>
8 <body>
9 <p id="description"></p>
10 <div id="console"></div>
11 <script>
12
13 description("Test the basics of IndexedDB's IDBDatabase.");
14 if (window.layoutTestController) 
15     layoutTestController.waitUntilDone();
16
17 function openSuccess()
18 {
19     verifySuccessEvent(event);
20
21     var db = evalAndLog("db = event.result");
22     deleteAllObjectStores(db);
23
24     // We must do something asynchronous before anything synchronous since
25     // deleteAllObjectStores only schedules the object stores to be removed.
26     // We don't know for sure whether it's happened until an IDBRequest object
27     // that was created after the removes fires.
28
29     debug("Testing setVersion.");
30     result = evalAndLog('db.setVersion("version a")');
31     verifyResult(result);
32     result.onsuccess = setVersionAgain;
33     result.onError = unexpectedErrorCallback;
34 }
35
36 function setVersionAgain()
37 {
38     verifySuccessEvent(event);
39
40     result = evalAndLog('db.setVersion("version b")');
41     verifyResult(result);
42     result.onsuccess = createObjectStore;
43     result.onError = unexpectedErrorCallback;
44 }
45
46 function createObjectStore()
47 {
48     verifySuccessEvent(event);
49     shouldBeEqualToString("db.version", "version b");
50     shouldBeEqualToString("db.name", "name");
51     shouldBe("db.objectStores", "[]");
52     shouldBe("db.objectStores.length", "0");
53     shouldBe("db.objectStores.contains('')", "false");
54
55     result = evalAndLog('db.createObjectStore("test123")');
56     verifyResult(result);
57     result.onsuccess = checkObjectStore;
58     result.onError = unexpectedErrorCallback;
59 }
60
61 function checkObjectStore()
62 {
63     verifySuccessEvent(event);
64     shouldBe("db.objectStores", "['test123']");
65     shouldBe("db.objectStores.length", "1");
66     shouldBe("db.objectStores.contains('')", "false");
67     shouldBe("db.objectStores.contains('test456')", "false");
68     shouldBe("db.objectStores.contains('test123')", "true");
69
70     done();
71 }
72
73 function test()
74 {
75     result = evalAndLog("indexedDB.open('name', 'description')");
76     verifyResult(result);
77     result.onsuccess = openSuccess;
78     result.onerror = unexpectedErrorCallback;
79 }
80
81 test();
82
83 var successfullyParsed = true;
84
85 </script>
86 </body>
87 </html>