Test for valid and invalid keypaths

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;

indexedDB.open(name)
db = event.target.result
request = db.setVersion('1')

testValidKeyPaths():
Deleted all object stores.
store = db.createObjectStore('name')
PASS store.keyPath is null
Deleted all object stores.
store = db.createObjectStore('name', {keyPath: null})
PASS store.keyPath is null
index = store.createIndex('name', null)
PASS index.keyPath is 'null'
Deleted all object stores.
store = db.createObjectStore('name', {keyPath: undefined})
PASS store.keyPath is null
index = store.createIndex('name', undefined)
PASS index.keyPath is 'undefined'
Deleted all object stores.
store = db.createObjectStore('name', {keyPath: ''})
PASS store.keyPath is ''
index = store.createIndex('name', '')
PASS index.keyPath is ''
Deleted all object stores.
store = db.createObjectStore('name', {keyPath: 'foo'})
PASS store.keyPath is 'foo'
index = store.createIndex('name', 'foo')
PASS index.keyPath is 'foo'
Deleted all object stores.
store = db.createObjectStore('name', {keyPath: 'foo.bar.baz'})
PASS store.keyPath is 'foo.bar.baz'
index = store.createIndex('name', 'foo.bar.baz')
PASS index.keyPath is 'foo.bar.baz'
Deleted all object stores.

testInvalidKeyPaths():
Deleted all object stores.

Object store key path may not be empty or an array if autoIncrement is true
Expecting exception from store = db.createObjectStore('storeName', {autoIncrement: true, keyPath: ''})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Deleted all object stores.
Expecting exception from store = db.createObjectStore('storeName', {autoIncrement: true, keyPath: []})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Deleted all object stores.
Expecting exception from store = db.createObjectStore('storeName', {autoIncrement: true, keyPath: ['a']})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Deleted all object stores.
Expecting exception from store = db.createObjectStore('storeName', {autoIncrement: true, keyPath: ['']})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Deleted all object stores.

Key paths which are never valid:
Expecting exception from db.createObjectStore('name', {keyPath: ' '})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', ' ')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo '})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo ')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo bar'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo bar')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo. bar'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo. bar')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo .bar'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo .bar')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo..bar'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo..bar')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: '+foo'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', '+foo')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: 'foo%'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', 'foo%')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: '1'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', '1')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
Expecting exception from db.createObjectStore('name', {keyPath: '1.0'})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from db.createObjectStore('name').createIndex('name', '1.0')
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Deleted all object stores.
PASS successfullyParsed is true

TEST COMPLETE

