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

Side by Side Diff: LayoutTests/storage/indexeddb/resources/keypath-intrinsic-properties.js

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebasing issue? Created 6 years, 7 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
OLDNEW
1 if (this.importScripts) { 1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js'); 2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js'); 3 importScripts('shared.js');
4 } 4 }
5 5
6 description("Test IndexedDB keyPath with intrinsic properties"); 6 description("Test IndexedDB keyPath with intrinsic properties");
7 7
8 indexedDBTest(prepareDatabase, testKeyPaths); 8 indexedDBTest(prepareDatabase, testKeyPaths);
9 function prepareDatabase() 9 function prepareDatabase()
10 { 10 {
11 db = event.target.result; 11 db = event.target.result;
12 event.target.transaction.onabort = unexpectedAbortCallback; 12 event.target.transaction.onabort = unexpectedAbortCallback;
13 evalAndLog("store = db.createObjectStore('store', {keyPath: 'id'})"); 13 evalAndLog("store = db.createObjectStore('store', {keyPath: 'id'})");
14 evalAndLog("store.createIndex('string length', 'string.length')"); 14 evalAndLog("store.createIndex('string length', 'string.length')");
15 evalAndLog("store.createIndex('array length', 'array.length')"); 15 evalAndLog("store.createIndex('array length', 'array.length')");
16 evalAndLog("store.createIndex('blob size', 'blob.size')");
jsbell 2014/05/29 00:40:06 The IDB spec also has Blob.size, File.name and Fil
ericu 2014/06/02 22:18:47 I added Blob.type. File.name and File.lastModified
jsbell 2014/06/02 23:05:06 If there's no special work being done, I'm fine wi
16 } 17 }
17 18
18 function testKeyPaths() 19 function testKeyPaths()
19 { 20 {
20 debug(""); 21 debug("");
21 debug("testKeyPaths():"); 22 debug("testKeyPaths():");
22 23
23 transaction = evalAndLog("transaction = db.transaction('store', 'readwrite') "); 24 transaction = evalAndLog("transaction = db.transaction('store', 'readwrite') ");
24 transaction.onabort = unexpectedAbortCallback; 25 transaction.onabort = unexpectedAbortCallback;
25 store = evalAndLog("store = transaction.objectStore('store')"); 26 store = evalAndLog("store = transaction.objectStore('store')");
26 27
27 for (var i = 0; i < 5; i += 1) { 28 for (var i = 0; i < 5; i += 1) {
28 var datum = { 29 var datum = {
29 id: 'id#' + i, 30 id: 'id#' + i,
30 string: Array(i * 2 + 1).join('x'), 31 string: Array(i * 2 + 1).join('x'),
31 array: Array(i * 3 + 1).join('x').split(/(?:)/) 32 array: Array(i * 3 + 1).join('x').split(/(?:)/),
33 blob: new Blob([Array(i * 4 + 1).join('x')])
32 }; 34 };
33 evalAndLog("store.put("+JSON.stringify(datum)+")"); 35 evalAndLog("store.put("+JSON.stringify(datum)+")");
jsbell 2014/05/29 00:40:06 Note that the put() call is being constructed from
ericu 2014/06/02 22:18:47 Ah, good catch--I missed that. Array makes the tr
34 } 36 }
35 37
36 checkStringLengths(); 38 checkStringLengths();
37 39
38 function checkStringLengths() { 40 function checkStringLengths() {
39 evalAndLog("request = store.index('string length').openCursor()"); 41 evalAndLog("request = store.index('string length').openCursor()");
40 request.onerror = unexpectedErrorCallback; 42 request.onerror = unexpectedErrorCallback;
41 request.onsuccess = function (e) { 43 request.onsuccess = function (e) {
42 cursor = e.target.result; 44 cursor = e.target.result;
43 if (cursor) { 45 if (cursor) {
44 shouldBe("cursor.key", "cursor.value.string.length"); 46 shouldBe("cursor.key", "cursor.value.string.length");
45 cursor.continue(); 47 cursor.continue();
46 } else { 48 } else {
47 checkArrayLengths(); 49 checkArrayLengths();
48 } 50 }
49 } 51 }
50 } 52 }
51 53
52 function checkArrayLengths() { 54 function checkArrayLengths() {
53 evalAndLog("request = store.index('array length').openCursor()"); 55 evalAndLog("request = store.index('array length').openCursor()");
54 request.onerror = unexpectedErrorCallback; 56 request.onerror = unexpectedErrorCallback;
55 request.onsuccess = function (e) { 57 request.onsuccess = function (e) {
56 cursor = e.target.result; 58 cursor = e.target.result;
57 if (cursor) { 59 if (cursor) {
58 shouldBe("cursor.key", "cursor.value.array.length"); 60 shouldBe("cursor.key", "cursor.value.array.length");
59 cursor.continue(); 61 cursor.continue();
62 } else {
63 checkBlobSizes();
64 }
65 }
66 }
67
68 function checkBlobSizes() {
69 evalAndLog("request = store.index('blob size').openCursor()");
70 request.onerror = unexpectedErrorCallback;
71 request.onsuccess = function (e) {
72 cursor = e.target.result;
73 if (cursor) {
74 shouldBe("cursor.key", "cursor.value.blob.size");
75 cursor.continue();
60 } 76 }
61 } 77 }
62 } 78 }
63 79
64 transaction.oncomplete = finishJSTest; 80 transaction.oncomplete = finishJSTest;
65 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698