mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 694135: Don't throw if there are unknown properties in the options objects to createObjectStore/createIndex. r=bent
This commit is contained in:
parent
a32db4372c
commit
eec1ee6dc1
@ -473,58 +473,45 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
|
||||
|
||||
if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
|
||||
if (JSVAL_IS_PRIMITIVE(aOptions)) {
|
||||
// XXX Update spec for a real code here
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
// XXX This isn't the right error
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
}
|
||||
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(aOptions), "Huh?!");
|
||||
JSObject* options = JSVAL_TO_OBJECT(aOptions);
|
||||
|
||||
js::AutoIdArray ids(aCx, JS_Enumerate(aCx, options));
|
||||
if (!ids) {
|
||||
jsval val;
|
||||
if (!JS_GetPropertyById(aCx, options, nsDOMClassInfo::sKeyPath_id, &val)) {
|
||||
NS_WARNING("JS_GetPropertyById failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < ids.length(); index++) {
|
||||
jsid id = ids[index];
|
||||
|
||||
if (id != nsDOMClassInfo::sKeyPath_id &&
|
||||
id != nsDOMClassInfo::sAutoIncrement_id) {
|
||||
// XXX Update spec for a real code here
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
|
||||
jsval val;
|
||||
if (!JS_GetPropertyById(aCx, options, id, &val)) {
|
||||
NS_WARNING("JS_GetPropertyById failed!");
|
||||
if (!JSVAL_IS_VOID(val) && !JSVAL_IS_NULL(val)) {
|
||||
JSString* str = JS_ValueToString(aCx, val);
|
||||
if (!str) {
|
||||
NS_WARNING("JS_ValueToString failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (id == nsDOMClassInfo::sKeyPath_id) {
|
||||
JSString* str = JS_ValueToString(aCx, val);
|
||||
if (!str) {
|
||||
NS_WARNING("JS_ValueToString failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
nsDependentJSString dependentKeyPath;
|
||||
if (!dependentKeyPath.init(aCx, str)) {
|
||||
NS_WARNING("Initializing keyPath failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
keyPath = dependentKeyPath;
|
||||
}
|
||||
else if (id == nsDOMClassInfo::sAutoIncrement_id) {
|
||||
JSBool boolVal;
|
||||
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
|
||||
NS_WARNING("JS_ValueToBoolean failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
autoIncrement = !!boolVal;
|
||||
}
|
||||
else {
|
||||
NS_NOTREACHED("Shouldn't be able to get here!");
|
||||
nsDependentJSString dependentKeyPath;
|
||||
if (!dependentKeyPath.init(aCx, str)) {
|
||||
NS_WARNING("Initializing keyPath failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
keyPath = dependentKeyPath;
|
||||
}
|
||||
|
||||
if (!JS_GetPropertyById(aCx, options, nsDOMClassInfo::sAutoIncrement_id,
|
||||
&val)) {
|
||||
NS_WARNING("JS_GetPropertyById failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
JSBool boolVal;
|
||||
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
|
||||
NS_WARNING("JS_ValueToBoolean failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
autoIncrement = !!boolVal;
|
||||
}
|
||||
|
||||
nsAutoPtr<ObjectStoreInfo> newInfo(new ObjectStoreInfo());
|
||||
|
@ -1302,44 +1302,25 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
|
||||
// Get optional arguments.
|
||||
if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
|
||||
if (JSVAL_IS_PRIMITIVE(aOptions)) {
|
||||
// XXX Update spec for a real code here
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
// XXX Update spec for a real code here
|
||||
return NS_ERROR_DOM_TYPE_ERR;
|
||||
}
|
||||
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(aOptions), "Huh?!");
|
||||
JSObject* options = JSVAL_TO_OBJECT(aOptions);
|
||||
|
||||
js::AutoIdArray ids(aCx, JS_Enumerate(aCx, options));
|
||||
if (!ids) {
|
||||
jsval val;
|
||||
if (!JS_GetPropertyById(aCx, options, nsDOMClassInfo::sUnique_id, &val)) {
|
||||
NS_WARNING("JS_GetPropertyById failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
for (size_t index = 0; index < ids.length(); index++) {
|
||||
jsid id = ids[index];
|
||||
|
||||
if (id != nsDOMClassInfo::sUnique_id) {
|
||||
// XXX Update spec for a real code here
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
|
||||
jsval val;
|
||||
if (!JS_GetPropertyById(aCx, options, id, &val)) {
|
||||
NS_WARNING("JS_GetPropertyById failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (id == nsDOMClassInfo::sUnique_id) {
|
||||
JSBool boolVal;
|
||||
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
|
||||
NS_WARNING("JS_ValueToBoolean failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
unique = !!boolVal;
|
||||
}
|
||||
else {
|
||||
NS_NOTREACHED("Shouldn't be able to get here!");
|
||||
}
|
||||
JSBool boolVal;
|
||||
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
|
||||
NS_WARNING("JS_ValueToBoolean failed!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
unique = !!boolVal;
|
||||
}
|
||||
|
||||
DatabaseInfo* databaseInfo = mTransaction->Database()->Info();
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
ok(event.target === request, "Good event target");
|
||||
|
||||
let objectStore = db.createObjectStore("foo", { keyPath: "" });
|
||||
let objectStore = db.createObjectStore("foo", { keyPath: null });
|
||||
let key = 10;
|
||||
|
||||
request = objectStore.add({}, key);
|
||||
|
@ -58,13 +58,9 @@
|
||||
ok(true, "createIndex with bad options threw");
|
||||
}
|
||||
|
||||
try {
|
||||
request = objectStore.createIndex("foo", "bar", { foo: "" });
|
||||
ok(false, "createIndex with bad options should throw");
|
||||
}
|
||||
catch(e) {
|
||||
ok(true, "createIndex with bad options threw");
|
||||
}
|
||||
ok(objectStore.createIndex("foo", "bar", { foo: "" }),
|
||||
"createIndex with unknown options should not throw");
|
||||
objectStore.deleteIndex("foo");
|
||||
|
||||
// Test index creation, and that it ends up in indexNames.
|
||||
let objectStoreName = info.name;
|
||||
|
@ -18,10 +18,10 @@
|
||||
const name = window.location.pathname;
|
||||
const description = "My Test Database";
|
||||
const objectStoreInfo = [
|
||||
{ name: "1", options: { keyPath: "" } },
|
||||
{ name: "2", options: { keyPath: "", autoIncrement: true } },
|
||||
{ name: "3", options: { keyPath: "", autoIncrement: false } },
|
||||
{ name: "4", options: { keyPath: "" } },
|
||||
{ name: "1", options: { keyPath: null } },
|
||||
{ name: "2", options: { keyPath: null, autoIncrement: true } },
|
||||
{ name: "3", options: { keyPath: null, autoIncrement: false } },
|
||||
{ name: "4", options: { keyPath: null } },
|
||||
{ name: "5", options: { keyPath: "foo" } },
|
||||
{ name: "6" },
|
||||
{ name: "7", options: null },
|
||||
@ -52,13 +52,9 @@
|
||||
ok(true, "createObjectStore with bad options");
|
||||
}
|
||||
|
||||
try {
|
||||
db.createObjectStore("foo", { foo: "" });
|
||||
ok(false, "createObjectStore with bad options should throw");
|
||||
}
|
||||
catch(e) {
|
||||
ok(true, "createObjectStore with bad options");
|
||||
}
|
||||
ok(db.createObjectStore("foo", { foo: "" }),
|
||||
"createObjectStore with unknown options should not throw");
|
||||
db.deleteObjectStore("foo");
|
||||
|
||||
for (let index in objectStoreInfo) {
|
||||
index = parseInt(index);
|
||||
|
@ -20,11 +20,11 @@
|
||||
const START_DATA = "hi";
|
||||
const END_DATA = "bye";
|
||||
const objectStoreInfo = [
|
||||
{ name: "1", options: { keyPath: "" }, key: 1,
|
||||
{ name: "1", options: { keyPath: null }, key: 1,
|
||||
entry: { data: START_DATA } },
|
||||
{ name: "2", options: { keyPath: "foo" },
|
||||
entry: { foo: 1, data: START_DATA } },
|
||||
{ name: "3", options: { keyPath: "", autoIncrement: true },
|
||||
{ name: "3", options: { keyPath: null, autoIncrement: true },
|
||||
entry: { data: START_DATA } },
|
||||
{ name: "4", options: { keyPath: "foo", autoIncrement: true },
|
||||
entry: { data: START_DATA } },
|
||||
|
@ -76,7 +76,7 @@
|
||||
|
||||
let db = event.target.result;
|
||||
|
||||
let objectStore = db.createObjectStore(objectStoreName, { keyPath: "" });
|
||||
let objectStore = db.createObjectStore(objectStoreName, { keyPath: null });
|
||||
|
||||
// First, add all our data to the object store.
|
||||
let addedData = 0;
|
||||
|
@ -40,7 +40,7 @@ function testSteps()
|
||||
{ name: "out of line key; no key generator",
|
||||
autoIncrement: false,
|
||||
storedObject: {name: "Lincoln"},
|
||||
keyName: "",
|
||||
keyName: null,
|
||||
keyValue: 1,
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user