mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 698440: Implement IndexedDB optional version syntax. r=bent
This commit is contained in:
parent
3140fc9fd4
commit
2c7a2e1bea
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user