Bug 618606 - 'IndexedDB: keyPath parameter for createObjectStore should be optional'. r=sicking, a=blocking.

This commit is contained in:
Ben Turner 2010-12-15 13:21:04 -08:00
parent 65d3922d64
commit df30ba20da
2 changed files with 29 additions and 18 deletions

View File

@ -55,7 +55,7 @@ interface nsIDOMEventListener;
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase
* for more information.
*/
[scriptable, uuid(a4a707af-f5bb-45e4-a615-7616b03a5edc)]
[scriptable, uuid(6563ebdc-4509-4aeb-ac14-7e78ad74e2d3)]
interface nsIIDBDatabase : nsISupports
{
readonly attribute DOMString name;
@ -66,7 +66,7 @@ interface nsIIDBDatabase : nsISupports
nsIIDBObjectStore
createObjectStore(in AString name,
in AString keyPath,
[optional /* none */] in AString keyPath,
[optional /* false */] in boolean autoIncrement);
void

View File

@ -24,7 +24,10 @@
{ name: "3", keyPath: "", autoIncrement: false },
{ name: "4", keyPath: "" },
{ name: "5", keyPath: null },
{ name: "6", keyPath: "foo" }
{ name: "6", keyPath: "foo" },
{ name: "7" },
{ name: "8", autoIncrement: true },
{ name: "9", autoIncrement: false }
];
let request = moz_indexedDB.open(name, description);
@ -46,7 +49,7 @@
ok(event.source === db, "event.source is correct");
try {
db.createObjectStore(null, null);
db.createObjectStore(null);
ok(false, "createObjectStore with null name should throw");
}
catch(e) {
@ -54,28 +57,36 @@
}
try {
db.createObjectStore("", "");
db.createObjectStore("");
ok(false, "createObjectStore with empty name should throw");
}
catch(e) {
ok(true, "createObjectStore with empty name should throw");
}
try {
db.createObjectStore("Hi");
ok(false, "createObjectStore with no keyPath should throw");
}
catch(e) {
ok(true, "createObjectStore with no keyPath should throw");
}
for (let index in objectStoreInfo) {
index = parseInt(index);
let info = objectStoreInfo[index];
let objectStore = info.hasOwnProperty("autoIncrement") ?
db.createObjectStore(info.name, info.keyPath,
info.autoIncrement) :
db.createObjectStore(info.name, info.keyPath);
const info = objectStoreInfo[index];
let objectStore;
if (info.hasOwnProperty("keyPath")) {
if (info.hasOwnProperty("autoIncrement")) {
objectStore = db.createObjectStore(info.name, info.keyPath,
info.autoIncrement);
}
else {
objectStore = db.createObjectStore(info.name, info.keyPath);
}
}
else {
if (info.hasOwnProperty("autoIncrement")) {
objectStore = db.createObjectStore(info.name, null,
info.autoIncrement);
}
else {
objectStore = db.createObjectStore(info.name);
}
}
is(db.objectStoreNames.length, index + 1,
"updated objectStoreNames list");