mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 618616 - 'IndexedDB: Make IDBObjectStore.get() accept a key range'. r=sicking, a=blocking.
This commit is contained in:
parent
2fe29b705a
commit
68954fc1d7
@ -934,7 +934,30 @@ IDBObjectStore::Get(nsIVariant* aKey,
|
||||
Key key;
|
||||
nsresult rv = GetKeyFromVariant(aKey, key);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
// Check to see if this is a key range.
|
||||
PRUint16 type;
|
||||
rv = aKey->GetDataType(&type);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
if (type != nsIDataType::VTYPE_INTERFACE &&
|
||||
type != nsIDataType::VTYPE_INTERFACE_IS) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
|
||||
// XXX I hate this API. Move to jsvals, stat.
|
||||
nsID* iid;
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
rv = aKey->GetAsInterface(&iid, getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
NS_Free(iid);
|
||||
|
||||
nsCOMPtr<nsIIDBKeyRange> keyRange = do_QueryInterface(supports);
|
||||
if (!keyRange) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
|
||||
return GetAll(keyRange, 0, 0, _retval);
|
||||
}
|
||||
|
||||
if (key.IsUnset()) {
|
||||
|
@ -105,6 +105,19 @@
|
||||
is(event.result[i], values[parseInt(i) + 3], "Same value");
|
||||
}
|
||||
|
||||
// Get should take a key range also.
|
||||
request = db.transaction("foo").objectStore("foo").get(keyRange);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
||||
is(event.result instanceof Array, true, "Got an array object");
|
||||
is(event.result.length, 4, "Correct length");
|
||||
|
||||
for (let i in event.result) {
|
||||
is(event.result[i], values[parseInt(i) + 3], "Same value");
|
||||
}
|
||||
|
||||
keyRange = IDBKeyRange.bound(4, 7);
|
||||
|
||||
request = db.transaction("foo").objectStore("foo").getAll(keyRange, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user