Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: LayoutTests/storage/indexeddb/optional-arguments.html

Issue 14297012: IndexedDB: Use [Default] in IDLs to reduce overloads in implementations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/optional-arguments-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../fast/js/resources/js-test-pre.js"></script>
3 <script src="resources/shared.js"></script>
4 <script>
5
6 description("Exercise optional arguments with missing vs. undefined in IndexedDB methods.");
7
8 indexedDBTest(prepareDatabase, checkOptionalArguments);
9 function prepareDatabase(evt)
10 {
11 preamble(evt);
12 evalAndLog("db = event.target.result");
13 evalAndLog("store = db.createObjectStore('store', {keyPath: 'id'})");
14 evalAndLog("store.createIndex('by_name', 'name', {unique: true})");
15
16 evalAndLog("store.put({id: 1, name: 'a'})");
17 }
18
19 function checkOptionalArguments(event)
20 {
21 evalAndLog("tx = db.transaction('store', 'readwrite')");
22 tx.oncomplete = finishJSTest;
23
24 evalAndLog("store = tx.objectStore('store')");
25 evalAndLog("index = store.index('by_name')");
26
27 shouldBe("IDBKeyRange.lowerBound(0).lowerOpen", "false");
28 shouldBe("IDBKeyRange.upperBound(0).upperOpen", "false");
29 shouldBe("IDBKeyRange.bound(0, 1).lowerOpen", "false");
30 shouldBe("IDBKeyRange.bound(0, 1).upperOpen", "false");
31
32 shouldBe("IDBKeyRange.lowerBound(0, undefined).lowerOpen", "false");
33 shouldBe("IDBKeyRange.upperBound(0, undefined).upperOpen", "false");
34 shouldBe("IDBKeyRange.bound(0, 1, undefined, undefined).lowerOpen", "false") ;
35 shouldBe("IDBKeyRange.bound(0, 1, undefined, undefined).upperOpen", "false") ;
36
37 shouldNotThrow("store.add({id: 2, name: 'b'})");
38 shouldNotThrow("store.put({id: 3, name: 'c'})");
39 shouldNotThrow("store.add({id: 4, name: 'd'}, undefined)");
40 shouldNotThrow("store.put({id: 5, name: 'e'}, undefined)");
41
42 tasks = [
43 function(callback) { verifyCursor("store.openCursor()", "next", 5, callb ack); },
44 function(callback) { verifyCursor("store.openCursor(null)", "next", 5, c allback); },
45 function(callback) { verifyCursor("store.openCursor(IDBKeyRange.lowerBou nd(4))", "next", 2, callback); },
46 function(callback) { verifyCursor("store.openCursor(3)", "next", 1, call back); },
47
48 function(callback) { verifyCursor("index.openCursor()", "next", 5, callb ack); },
49 function(callback) { verifyCursor("index.openCursor(null)", "next", 5, c allback); },
50 function(callback) { verifyCursor("index.openCursor(IDBKeyRange.lowerBou nd('b'))", "next", 4, callback); },
51 function(callback) { verifyCursor("index.openCursor('c')", "next", 1, ca llback); },
52
53 function(callback) { verifyCursor("index.openKeyCursor()", "next", 5, ca llback); },
54 function(callback) { verifyCursor("index.openKeyCursor(null)", "next", 5 , callback); },
55 function(callback) { verifyCursor("index.openKeyCursor(IDBKeyRange.lower Bound('b'))", "next", 4, callback); },
56 function(callback) { verifyCursor("index.openKeyCursor('c')", "next", 1, callback); },
57
58 function(callback) { verifyCount("store.count()", 5, callback); },
59 function(callback) { verifyCount("store.count(null)", 5, callback); },
60 function(callback) { verifyCount("store.count(IDBKeyRange.lowerBound(2)) ", 4, callback); },
61
62 function(callback) { verifyCount("index.count()", 5, callback); },
63 function(callback) { verifyCount("index.count(null)", 5, callback); },
64 function(callback) { verifyCount("index.count(IDBKeyRange.lowerBound('b' ))", 4, callback); },
65
66 continueUndefined,
67
68 ];
69 function doNextTask() {
70 var task = tasks.shift();
71 if (task) {
72 task(doNextTask);
73 }
74 }
75 doNextTask();
76 }
77
78 function verifyCursor(expr, direction, expected, callback)
79 {
80 preamble();
81 cursor = null;
82 continues = 0;
83 evalAndLog("request = " + expr);
84 request.onerror = unexpectedErrorCallback;
85
86 request.onsuccess = function() {
87 if (request.result) {
88 if (!cursor) {
89 evalAndLog("cursor = request.result");
90 shouldBeEqualToString("cursor.direction", direction);
91 }
92 ++continues;
93 cursor.continue();
94 } else {
95 shouldBe("continues", JSON.stringify(expected));
96 callback();
97 }
98 };
99 }
100
101 function verifyCount(expr, expected, callback)
102 {
103 preamble();
104 evalAndLog("request = " + expr);
105 request.onerror = unexpectedErrorCallback;
106
107 request.onsuccess = function() {
108 shouldBe("request.result", JSON.stringify(expected));
109 callback();
110 };
111 }
112
113 function continueUndefined(callback)
114 {
115 preamble();
116 first = true;
117 evalAndLog("request = store.openCursor()");
118 request.onerror = unexpectedErrorCallback;
119
120 request.onsuccess = function() {
121 if (first) {
122 first = false;
123 evalAndLog("cursor = request.result");
124 shouldBeNonNull("request.result");
125 shouldNotThrow("cursor.continue(undefined)");
126 callback();
127 }
128 };
129 }
130
131 </script>
132 <script src="../../fast/js/resources/js-test-post.js"></script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/optional-arguments-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698