Closed Bug 715963 Opened 14 years ago Closed 11 years ago

IndexedDB: Cannot create ObjectStores

Categories

(Core :: Storage: IndexedDB, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: lcid-fire, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 (KHTML, like Gecko) Ubuntu/11.10 Chromium/17.0.942.0 Chrome/17.0.942.0 Safari/535.8 Steps to reproduce: On a site with url "localhost:8080/test.html" var request = indexedDB.open("_test_", 1); request.onsuccess = function() { var os = request.result.createObjectStore("somestore"); }; Actual results: When it executes createObject I get the exception with the dumb message: "A mutation operation was attempted on a database that did not allow mutations". This isn't helpfull at all. Expected results: It should have created the object store.
Even when I move the createObjectStore call to onupgradeneeded , it still does not work since it never calls onupgradeneeded.
IMHO it's not a bug. See attached test case.
Hi ! "onupgradeneeded" is called only the first time the database is opened, or when the database version has changed. You may have to delete the database before testing again, or change the database version to trigger another "onupgradeneeded" call. See attached example page (https://bugzilla.mozilla.org/attachment.cgi?id=604395), or following code : // indexedDB = window.indexedDB || window.mozIndexedDB // // either delete database first indexedDB.deleteDatabase("_test_"); // // or change database version request = indexedDB.open("_test_", 2); // then execute that test function: var testDB = function () { var request = indexedDB.open("_test_"), connectionToDB; // var to keep the opened connection to the database request.onupgradeneeded = function () { log("onupgradeneed: creating somestore"); request.result.createObjectStore("somestore"); }; request.onsuccess = function (e) { connectionToDB = request.result; log("onsuccess: somestore exists ? => " + connectionToDB.objectStoreNames.contains("somestore")); // => true // close connection when not needed anymore connectionToDB.close(); }; request.onerror = function (e) { log('onerror: opening _test_ failed with e.target.errorCode = ' + e.target.errorCode); }; }; testDB(); Also, I recommend you have a look at https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB . Unfortunately, there are very few good examples of indexedDB usage out there... I hope that helps !
Icid-fire, can you please test again and confirm the issue is resolved ? Thanks.
Component: Untriaged → DOM: IndexedDB
Product: Firefox → Core
Version: 10 Branch → unspecified
QA Contact: untriaged → indexeddb
I answered your question in bug 736948. Please don't post on multiple bugs.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: