Bug 638067 - 'IndexedDB: Inserting data with multiple indexes on an autoIncrement object store throws an error'. r=sdwilsh, a=LegNeato. Add missing file.
authorBen Turner <bent.mozilla@gmail.com>
Wed, 13 Apr 2011 00:01:13 -0700
changeset 63422 1bf2d5b7a2d2c605b401790eaa5a700b7b11ba6d
parent 63421 96766bc3859b087fdfcef625161903ee9343436d
child 63423 5eeb8a849e746bcd43b347cca5a7fee4c6100624
push id66
push userbturner@mozilla.com
push dateWed, 13 Apr 2011 07:01:59 +0000
reviewerssdwilsh, LegNeato
bugs638067
milestone2.0.1pre
Bug 638067 - 'IndexedDB: Inserting data with multiple indexes on an autoIncrement object store throws an error'. r=sdwilsh, a=LegNeato. Add missing file.
dom/indexedDB/test/test_autoIncrement_indexes.html
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/test_autoIncrement_indexes.html
@@ -0,0 +1,71 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>Indexed Database Property Test</title>
+
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+  <script type="text/javascript;version=1.7">
+    function testSteps()
+    {
+      let request = mozIndexedDB.open(window.location.pathname);
+      request.onerror = errorHandler;
+      request.onsuccess = grabEventAndContinueHandler;
+      let event = yield;
+
+      let db = request.result;
+      db.onerror = errorHandler;
+
+      db.setVersion("1").onsuccess = grabEventAndContinueHandler;
+      let event = yield;
+
+      let objectStore = db.createObjectStore("foo", { keyPath: "id",
+                                                      autoIncrement: true });
+      objectStore.createIndex("first","first");
+      objectStore.createIndex("second","second");
+      objectStore.createIndex("third","third");
+
+      let data = { first: "foo", second: "foo", third: "foo" };
+
+      objectStore.add(data).onsuccess = grabEventAndContinueHandler;
+      event = yield;
+
+      let key = event.target.result;
+      ok(key, "Added entry");
+
+      let objectStore = db.transaction("foo").objectStore("foo");
+      let first = objectStore.index("first");
+      let second = objectStore.index("second");
+      let third = objectStore.index("third");
+
+      first.get("foo").onsuccess = grabEventAndContinueHandler;
+      event = yield;
+
+      is (event.target.result.id, key, "Entry in first");
+
+      second.get("foo").onsuccess = grabEventAndContinueHandler;
+      event = yield;
+
+      is (event.target.result.id, key, "Entry in second");
+
+      third.get("foo").onsuccess = grabEventAndContinueHandler;
+      event = yield;
+
+      is (event.target.result.id, key, "Entry in third");
+
+      finishTest();
+      yield;
+    }
+  </script>
+  <script type="text/javascript;version=1.7" src="helpers.js"></script>
+
+</head>
+
+<body onload="runTest();"></body>
+
+</html>