Index: LayoutTests/storage/indexeddb/resources/transaction-coordination-ro-waits-for-rw.js |
diff --git a/LayoutTests/storage/indexeddb/resources/transaction-coordination-ro-waits-for-rw.js b/LayoutTests/storage/indexeddb/resources/transaction-coordination-ro-waits-for-rw.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..56c9f058fa0b61a1cec5242e560d5978d864c660 |
--- /dev/null |
+++ b/LayoutTests/storage/indexeddb/resources/transaction-coordination-ro-waits-for-rw.js |
@@ -0,0 +1,38 @@ |
+if (this.importScripts) { |
+ importScripts('../../../resources/js-test.js'); |
+ importScripts('shared.js'); |
+} |
+ |
+description("read-only transaction should see the result of a previous readwrite transaction"); |
jsbell
2014/11/20 18:39:19
nit: Either use the enum values (readonly, readwri
dgrogan
2014/11/21 01:33:11
Done.
|
+ |
+indexedDBTest(prepareDatabase, runTransactions); |
+ |
+function prepareDatabase(evt) |
+{ |
+ preamble(evt); |
+ evalAndLog("db = event.target.result"); |
+ evalAndLog("store = db.createObjectStore('store')"); |
+ evalAndLog("store.put('original value', 'key')"); |
+} |
+ |
+function runTransactions(evt) |
+{ |
+ preamble(evt); |
+ evalAndLog("db = event.target.result"); |
+ evalAndLog("transaction1 = db.transaction('store', 'readwrite')"); |
+ transaction1.onabort = unexpectedAbortCallback; |
+ evalAndLog("transaction2 = db.transaction('store', 'readonly')"); |
+ transaction2.onabort = unexpectedAbortCallback; |
+ |
+ evalAndLog("request = transaction1.objectStore('store').put('new value', 'key')"); |
+ request.onerror = unexpectedErrorCallback; |
+ |
+ evalAndLog("request2 = transaction2.objectStore('store').get('key')"); |
+ request2.onerror = unexpectedErrorCallback; |
+ request2.onsuccess = function checkResult(evt) { |
+ preamble(evt); |
+ shouldBeEqualToString('request2.result', 'new value'); |
+ db.close(); |
+ finishJSTest(); |
+ }; |
+} |