| OLD | NEW |
| 1 // original test: | 1 // original test: |
| 2 // http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_create_index
_with_integer_keys.html?force=1 | 2 // http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_create_index
_with_integer_keys.html?force=1 |
| 3 // license of original test: | 3 // license of original test: |
| 4 // " Any copyright is dedicated to the Public Domain. | 4 // " Any copyright is dedicated to the Public Domain. |
| 5 // http://creativecommons.org/publicdomain/zero/1.0/ " | 5 // http://creativecommons.org/publicdomain/zero/1.0/ " |
| 6 | 6 |
| 7 if (this.importScripts) { | 7 if (this.importScripts) { |
| 8 importScripts('../../../../fast/js/resources/js-test-pre.js'); | 8 importScripts('../../../../resources/js-test.js'); |
| 9 importScripts('../../resources/shared.js'); | 9 importScripts('../../resources/shared.js'); |
| 10 } | 10 } |
| 11 | 11 |
| 12 description("Test IndexedDB's creating index with integer keys"); | 12 description("Test IndexedDB's creating index with integer keys"); |
| 13 | 13 |
| 14 indexedDBTest(prepareDatabase); | 14 indexedDBTest(prepareDatabase); |
| 15 function prepareDatabase() | 15 function prepareDatabase() |
| 16 { | 16 { |
| 17 db = event.target.result; | 17 db = event.target.result; |
| 18 event.target.transaction.onabort = unexpectedAbortCallback; | 18 event.target.transaction.onabort = unexpectedAbortCallback; |
| 19 objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { keyPat
h: 'id' });"); | 19 objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { keyPat
h: 'id' });"); |
| 20 data = evalAndLog("data = { id: 16, num: 42 };"); | 20 data = evalAndLog("data = { id: 16, num: 42 };"); |
| 21 evalAndLog("objectStore.add(data);"); | 21 evalAndLog("objectStore.add(data);"); |
| 22 index = evalAndLog("index = objectStore.createIndex('foo', 'num');"); | 22 index = evalAndLog("index = objectStore.createIndex('foo', 'num');"); |
| 23 result = evalAndLog("result = index.openKeyCursor();"); | 23 result = evalAndLog("result = index.openKeyCursor();"); |
| 24 result.onsuccess = verifyKeyCursor; | 24 result.onsuccess = verifyKeyCursor; |
| 25 result.onerror = unexpectedErrorCallback; | 25 result.onerror = unexpectedErrorCallback; |
| 26 } | 26 } |
| 27 | 27 |
| 28 function verifyKeyCursor() | 28 function verifyKeyCursor() |
| 29 { | 29 { |
| 30 cursor = evalAndLog("cursor = event.target.result;"); | 30 cursor = evalAndLog("cursor = event.target.result;"); |
| 31 shouldBeFalse("cursor == null"); | 31 shouldBeFalse("cursor == null"); |
| 32 shouldBe("cursor.key", "data.num"); | 32 shouldBe("cursor.key", "data.num"); |
| 33 shouldBe("cursor.primaryKey", "data.id"); | 33 shouldBe("cursor.primaryKey", "data.id"); |
| 34 finishJSTest(); | 34 finishJSTest(); |
| 35 } | 35 } |
| OLD | NEW |