Bug 698440: Implement IndexedDB optional version syntax. r=bent

This commit is contained in:
Kyle Huey 2011-11-02 08:53:12 -04:00
parent 3140fc9fd4
commit 2c7a2e1bea
5 changed files with 22 additions and 8 deletions

View File

@ -381,11 +381,12 @@ NS_IMETHODIMP
IDBFactory::Open(const nsAString& aName,
PRInt64 aVersion,
JSContext* aCx,
PRUint8 aOptionalArgCount,
nsIIDBOpenDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (aVersion < 1) {
if (aVersion < 1 && aOptionalArgCount) {
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}

View File

@ -746,6 +746,20 @@ OpenDatabaseHelper::DoDatabaseWork()
}
// See if we need to do a VERSION_CHANGE transaction
// Optional version semantics.
if (!mRequestedVersion) {
// If the requested version was not specified and the database was created,
// treat it as if version 1 were requested.
if (mCurrentVersion == 0) {
mRequestedVersion = 1;
}
else {
// Otherwise, treat it as if the current version were requested.
mRequestedVersion = mCurrentVersion;
}
}
if (mCurrentVersion > mRequestedVersion) {
return NS_ERROR_DOM_INDEXEDDB_VERSION_ERR;
}

View File

@ -49,10 +49,11 @@ interface nsIVariant;
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBFactory
* for more information.
*/
[scriptable, uuid(4b23254a-ce6d-4442-8c90-9d8744d3c633)]
[scriptable, uuid(d2889b8f-662a-42d3-8a8f-ac5179b9d5b0)]
interface nsIIDBFactory : nsISupports
{
[implicit_jscontext]
[implicit_jscontext, optional_argc]
nsIIDBOpenDBRequest
open(in AString name, in long long version);
open(in AString name,
[optional] in long long version);
};

View File

@ -97,9 +97,7 @@ function test5()
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) {
// XXXkhuey this isn't really testing anything until we get the default
// version behavior implemented ...
ok(result == 11, "Got correct version on database in " + testPageURL4);
ok(result == 1, "Got correct version on database in " + testPageURL4);
ok(!exception, "No exception");
gBrowser.removeCurrentTab();

View File

@ -9,7 +9,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
let request = mozIndexedDB.open("browser_forgetThisSite.js", 11);
let request = mozIndexedDB.open("browser_forgetThisSite.js");
request.onerror = grabEventAndContinueHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield;