mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 755514: Cursor.update support for keypath arrays. r=khuey
This commit is contained in:
parent
8495031c2a
commit
2e7cb24268
@ -686,11 +686,6 @@ IDBCursor::Update(const jsval& aValue,
|
||||
Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||
|
||||
if (mObjectStore->HasValidKeyPath()) {
|
||||
// This has to be an object.
|
||||
if (JSVAL_IS_PRIMITIVE(aValue)) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
|
||||
// Make sure the object given has the correct keyPath value set on it.
|
||||
const KeyPath& keyPath = mObjectStore->GetKeyPath();
|
||||
Key key;
|
||||
|
@ -39,6 +39,7 @@ function testSteps()
|
||||
{ keyPath: "fo o", exception: true },
|
||||
{ keyPath: "foo ", exception: true },
|
||||
{ keyPath: "foo[bar]",exception: true },
|
||||
{ keyPath: "foo[1]", exception: true },
|
||||
{ keyPath: "$('id').stuff", exception: true },
|
||||
{ keyPath: "foo.2.bar", exception: true },
|
||||
{ keyPath: "foo. .bar", exception: true },
|
||||
@ -124,6 +125,39 @@ function testSteps()
|
||||
e = yield;
|
||||
isnot(e.target.result, undefined, "Did find entry");
|
||||
|
||||
// Check that cursor.update work as expected
|
||||
request = store.openCursor();
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
e = yield;
|
||||
let cursor = e.target.result;
|
||||
request = cursor.update(info.value);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
yield;
|
||||
ok(true, "Successfully updated cursor" + test);
|
||||
|
||||
// Check that cursor.update throws as expected when key is changed
|
||||
let newValue = cursor.value;
|
||||
let destProp = Array.isArray(info.keyPath) ? info.keyPath[0] : info.keyPath;
|
||||
if (destProp) {
|
||||
eval("newValue." + destProp + " = 'newKeyValue'");
|
||||
}
|
||||
else {
|
||||
newValue = 'newKeyValue';
|
||||
}
|
||||
let didThrow;
|
||||
try {
|
||||
cursor.update(newValue);
|
||||
}
|
||||
catch (ex) {
|
||||
didThrow = ex;
|
||||
}
|
||||
ok(didThrow instanceof DOMException, "Got a DOMException" + test);
|
||||
is(didThrow.name, "DataError", "expect a DataError" + test);
|
||||
is(didThrow.code, 0, "expect zero" + test);
|
||||
|
||||
// Clear object store to prepare for next test
|
||||
store.clear().onsuccess = grabEventAndContinueHandler;
|
||||
yield;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user