mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Bug 1013221: Remove duplicate object store names when a transaction is created. r=khuey
This commit is contained in:
parent
8a0c3e1986
commit
bd6eecf159
@ -89,7 +89,6 @@ NS_IMPL_QUERY_INTERFACE(StartTransactionRunnable, nsIRunnable)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBTransaction>
|
||||
IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
|
||||
@ -116,6 +115,15 @@ IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
|
||||
transaction->mObjectStoreNames.AppendElements(aObjectStoreNames);
|
||||
transaction->mObjectStoreNames.Sort();
|
||||
|
||||
// Remove any duplicate object store names
|
||||
const uint32_t count = transaction->mObjectStoreNames.Length();
|
||||
for (uint32_t index = count - 1; index > 0 && count > 0; index--) {
|
||||
if (transaction->mObjectStoreNames[index] ==
|
||||
transaction->mObjectStoreNames[index - 1]) {
|
||||
transaction->mObjectStoreNames.RemoveElementAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
IndexedDBTransactionChild* actor = nullptr;
|
||||
|
||||
if (IndexedDatabaseManager::IsMainProcess()) {
|
||||
@ -945,7 +953,7 @@ CommitHelper::WriteAutoIncrementCounts()
|
||||
|
||||
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), info->id);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("ai"),
|
||||
info->nextAutoIncrementId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -953,7 +961,7 @@ CommitHelper::WriteAutoIncrementCounts()
|
||||
rv = stmt->Execute();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -192,6 +192,8 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop spec
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
||||
[test_transaction_abort_hang.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
||||
[test_transaction_duplicate_store_names.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
||||
[test_transaction_error.html]
|
||||
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
||||
[test_transaction_lifetimes.html]
|
||||
|
@ -0,0 +1,16 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for Bug 1013221</title>
|
||||
|
||||
<script type="application/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" src="unit/test_transaction_duplicate_store_names.js"></script>
|
||||
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
||||
</head>
|
||||
<body onload="runTest();"></body>
|
||||
</html>
|
@ -64,6 +64,7 @@
|
||||
[test_traffic_jam.js]
|
||||
[test_transaction_abort.js]
|
||||
[test_transaction_abort_hang.js]
|
||||
[test_transaction_duplicate_store_names.js]
|
||||
[test_transaction_error.js]
|
||||
[test_transaction_lifetimes.js]
|
||||
[test_transaction_lifetimes_nested.js]
|
||||
|
@ -0,0 +1,43 @@
|
||||
|
||||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let testGenerator = testSteps();
|
||||
|
||||
function testSteps() {
|
||||
const dbName = this.window ?
|
||||
window.location.pathname :
|
||||
"test_transaction_duplicate_store_names";
|
||||
const dbVersion = 1;
|
||||
const objectStoreName = "foo";
|
||||
const data = { };
|
||||
const dataKey = 1;
|
||||
|
||||
let request = indexedDB.open(dbName, dbVersion);
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
|
||||
let event = yield undefined;
|
||||
|
||||
let db = event.target.result;
|
||||
let objectStore = db.createObjectStore(objectStoreName);
|
||||
objectStore.add(data, dataKey);
|
||||
|
||||
event = yield undefined;
|
||||
|
||||
db = event.target.result;
|
||||
|
||||
let transaction = db.transaction([objectStoreName, objectStoreName], "readwrite");
|
||||
transaction.onerror = errorHandler;
|
||||
transaction.oncomplete = grabEventAndContinueHandler;
|
||||
|
||||
event = yield undefined;
|
||||
|
||||
ok(true, "Transaction created successfully");
|
||||
|
||||
finishTest();
|
||||
yield undefined;
|
||||
}
|
@ -79,6 +79,7 @@ skip-if = os == "android" && processor == "x86"
|
||||
[test_traffic_jam.js]
|
||||
[test_transaction_abort.js]
|
||||
[test_transaction_abort_hang.js]
|
||||
[test_transaction_duplicate_store_names.js]
|
||||
[test_transaction_error.js]
|
||||
[test_transaction_lifetimes.js]
|
||||
[test_transaction_lifetimes_nested.js]
|
||||
|
Loading…
x
Reference in New Issue
Block a user