文本文件  |  151行  |  4.68 KB

Test event propogation on IDBRequest.

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


webkitIndexedDB.open('request-event-propagation')
db = event.target.result
db.setVersion('new version')
setVersionSuccess():
trans = event.target.result
PASS trans !== null is true
trans.oncomplete = startTest
Deleted all object stores.
store = db.createObjectStore('storeName', null)
store.add({x: 'value', y: 'zzz'}, 'key')
Verify that handler fires and that not preventing default will result in an abort
trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
trans.onabort = transactionAborted
trans.oncomplete = unexpectedCompleteCallback
trans.onerror = allowDefault
store = trans.objectStore('storeName')
store.add({x: 'value', y: 'zzz'}, 'key')
PASS Event handler fired
Doing nothing to prevent the default action...
PASS handlerFired is true

Verifing error
trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
trans.onabort = transactionAborted2
trans.oncomplete = unexpectedAbortCallback
trans.addEventListener('error', errorCaptureCallback, true)
trans.addEventListener('error', errorBubbleCallback, false)
trans.addEventListener('success', unexpectedSuccessCallback, true)
trans.addEventListener('success', unexpectedSuccessCallback, false)
db.addEventListener('error', dbErrorCaptureCallback, true)
db.addEventListener('error', dbErrorBubbleCallback, false)
db.addEventListener('success', unexpectedSuccessCallback, true)
db.addEventListener('success', unexpectedSuccessCallback, false)
store = trans.objectStore('storeName')
store.add({x: 'value', y: 'zzz'}, 'key')

In IDBDatabase error capture
PASS dbCaptureFired is false
PASS captureFired is false
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is db

In IDBTransaction error capture
PASS dbCaptureFired is true
PASS captureFired is false
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is trans

In IDBRequest handler
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is request

In IDBTransaction error bubble
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is true
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is trans

In IDBDatabase error bubble
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is true
PASS bubbleFired is true
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is db

Transaction aborted
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is true
PASS bubbleFired is true
PASS dbBubbleFired is true

Verifing success.
trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
trans.oncomplete = transactionComplete
trans.onabort = unexpectedAbortCallback
trans.addEventListener('success', successCaptureCallback, true)
trans.addEventListener('success', successBubbleCallback, false)
trans.addEventListener('error', unexpectedErrorCallback, true)
trans.addEventListener('error', unexpectedErrorCallback, false)
db.removeEventListener('error', dbErrorCaptureCallback, true)
db.removeEventListener('error', dbErrorBubbleCallback, false)
db.removeEventListener('success', unexpectedSuccessCallback, true)
db.removeEventListener('success', unexpectedSuccessCallback, false)
db.addEventListener('success', dbSuccessCaptureCallback, true)
db.addEventListener('success', dbSuccessBubbleCallback, false)
db.addEventListener('error', unexpectedErrorCallback, true)
db.addEventListener('error', unexpectedErrorCallback, false)
store = trans.objectStore('storeName')
store.add({x: 'value', y: 'zzz'}, 'key2')

In IDBDatabase success capture
PASS dbCaptureFired is false
PASS captureFired is false
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is db

In IDBTransaction success capture
PASS dbCaptureFired is true
PASS captureFired is false
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is trans

In IDBRequest handler
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is false
PASS bubbleFired is false
PASS dbBubbleFired is false
PASS event.target is request
PASS event.currentTarget is request

Transaction completed
PASS dbCaptureFired is true
PASS captureFired is true
PASS requestFired is true
PASS bubbleFired is false
PASS dbBubbleFired is false

PASS successfullyParsed is true

TEST COMPLETE