1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test that IndexedDB's cursor key/primaryKey/value properties preserve mutations.");
12 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13 request.onblocked = unexpectedBlockedCallback;
14 request.onerror = unexpectedErrorCallback;
15 request.onsuccess = function() {
16 request = evalAndLog("indexedDB.open(dbname, 1)");
17 request.onblocked = unexpectedBlockedCallback;
18 request.onerror = unexpectedErrorCallback;
19 request.onupgradeneeded = onUpgradeNeeded;
20 request.onsuccess = onOpenSuccess;
24 function onUpgradeNeeded(evt)
27 evalAndLog("db = event.target.result");
28 evalAndLog("store = db.createObjectStore('store')");
29 evalAndLog("index = store.createIndex('index', 'id')");
30 evalAndLog("store.put({id: ['indexKey']}, ['primaryKey'])");
33 function onOpenSuccess(evt)
36 evalAndLog("db = event.target.result");
37 evalAndLog("trans = db.transaction('store')");
38 trans.onabort = unexpectedAbortCallback;
39 evalAndLog("store = trans.objectStore('store')");
40 evalAndLog("index = store.index('index')");
43 evalAndLog("request = index.openCursor()");
44 request.onerror = unexpectedErrorCallback;
45 request.onsuccess = function onCursorSuccess(evt) {
47 evalAndLog("cursor = event.target.result");
48 shouldBeNonNull("cursor");
49 shouldBeTrue("areArraysEqual(cursor.key, ['indexKey'])");
50 shouldBeTrue("areArraysEqual(cursor.primaryKey, ['primaryKey'])");
51 checkProperty("cursor.key");
52 checkProperty("cursor.primaryKey");
53 checkProperty("cursor.value");
56 trans.oncomplete = finishJSTest;
59 function checkProperty(property)
63 debug("Check identity:");
64 evalAndLog("v = " + property);
65 shouldBeTrue("v === " + property);
67 debug("Check read-only:");
68 evalAndLog(property + " = null");
69 shouldBeTrue("v === " + property);
71 debug("Check mutability:");
72 evalAndLog(property + ".expando = 123");
73 shouldBe(property + ".expando", "123");