Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / resources / transaction-coordination-ro-waits-for-rw.js
blobafcaf61b902f345b3a24bc358a4f7a7be470b111
1 if (this.importScripts) {
2     importScripts('../../../resources/js-test.js');
3     importScripts('shared.js');
6 description("readonly transaction should see the result of a previous readwrite transaction");
8 indexedDBTest(prepareDatabase, runTransactions);
10 function prepareDatabase(evt)
12     preamble(evt);
13     evalAndLog("db = event.target.result");
14     evalAndLog("store = db.createObjectStore('store')");
15     evalAndLog("store.put('original value', 'key')");
18 function runTransactions(evt)
20     preamble(evt);
21     evalAndLog("db = event.target.result");
22     evalAndLog("transaction1 = db.transaction('store', 'readwrite')");
23     transaction1.onabort = unexpectedAbortCallback;
24     evalAndLog("transaction2 = db.transaction('store', 'readonly')");
25     transaction2.onabort = unexpectedAbortCallback;
27     evalAndLog("request = transaction1.objectStore('store').put('new value', 'key')");
28     request.onerror = unexpectedErrorCallback;
30     evalAndLog("request2 = transaction2.objectStore('store').get('key')");
31     request2.onerror = unexpectedErrorCallback;
32     request2.onsuccess = function checkResult(evt) {
33         preamble(evt);
34         shouldBeEqualToString('request2.result', 'new value');
35         db.close();
36         finishJSTest();
37     };