1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB keyPath with intrinsic properties");
8 indexedDBTest(prepareDatabase, testKeyPaths);
9 function prepareDatabase()
11 db = event.target.result;
12 event.target.transaction.onabort = unexpectedAbortCallback;
13 evalAndLog("store = db.createObjectStore('store', {keyPath: 'id'})");
14 evalAndLog("store.createIndex('string length', 'string.length')");
15 evalAndLog("store.createIndex('array length', 'array.length')");
16 evalAndLog("store.createIndex('blob size', 'blob.size')");
17 evalAndLog("store.createIndex('blob type', 'blob.type')");
20 function testKeyPaths()
24 transaction = evalAndLog("transaction = db.transaction('store', 'readwrite')");
25 transaction.onabort = unexpectedAbortCallback;
26 store = evalAndLog("store = transaction.objectStore('store')");
28 for (var i = 0; i < 5; i += 1) {
31 string: Array(i * 2 + 1).join('x'),
32 array: Array(i * 3 + 1).join('x').split(/(?:)/),
33 blob: new Blob([Array(i * 4 + 1).join('x')], {type: "type " + i})
35 debug("store.put(" + stringifyDOMObject(datum) + ")");
41 function checkStringLengths() {
42 evalAndLog("request = store.index('string length').openCursor()");
43 request.onerror = unexpectedErrorCallback;
44 request.onsuccess = function (e) {
45 cursor = e.target.result;
47 shouldBe("cursor.key", "cursor.value.string.length");
55 function checkArrayLengths() {
56 evalAndLog("request = store.index('array length').openCursor()");
57 request.onerror = unexpectedErrorCallback;
58 request.onsuccess = function (e) {
59 cursor = e.target.result;
61 shouldBe("cursor.key", "cursor.value.array.length");
69 function checkBlobSizes() {
70 evalAndLog("request = store.index('blob size').openCursor()");
71 request.onerror = unexpectedErrorCallback;
72 request.onsuccess = function (e) {
73 cursor = e.target.result;
75 shouldBe("cursor.key", "cursor.value.blob.size");
83 function checkBlobTypes() {
84 evalAndLog("request = store.index('blob type').openCursor()");
85 request.onerror = unexpectedErrorCallback;
86 request.onsuccess = function (e) {
87 cursor = e.target.result;
89 shouldBe("cursor.key", "cursor.value.blob.type");
95 transaction.oncomplete = finishJSTest;