Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-actions.js

Issue 2449563002: [IndexedDB] Add Observer Tests (Closed)
Patch Set: Finished suite coverage Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-actions.js
diff --git a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-actions.js b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-actions.js
new file mode 100644
index 0000000000000000000000000000000000000000..76b78fc0c98b23b4e0c0d6e7b169603b3c5d1fd2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/observer-actions.js
@@ -0,0 +1,107 @@
+if (this.importScripts) {
+ importScripts('../../../resources/testharness.js');
+}
+
+
+window=this;
+var isWorker = window.document === undefined;
+
+
+var runActions = function() {
+ var partOneActionsDone = 0;
+ var partOneActions = 2;
+
+ var partOneActionDone = function(t) {
+ partOneActionsDone = partOneActionsDone + 1;
+ if (partOneActionsDone == partOneActions) {
+ runPartTwoActions();
+ } else if (partOneActionsDone > partOneActions) {
+ assert_unreached("Unexpected test callback.");
+ }
+ t.done();
+ }
+
+ async_test(function(t) {
+ var openRequest = indexedDB.open('observersDB1');
+
+ openRequest.onupgradeneeded = t.unreached_func('Database should be created');
+ openRequest.onsuccess = t.step_func(function() {
+ var db = openRequest.result;
+ var txn = db.transaction(['store1', 'store2'], 'readwrite');
+
+ var os1 = txn.objectStore('store1');
+ os1.delete(IDBKeyRange.bound('a', 'b'));
+ os1.put('c', 'a');
+
+ var os2 = txn.objectStore('store2');
+ os2.add('z', 'z');
+
+ txn.onerror = t.unreached_func('transaction should not fail');
+ txn.oncomplete = t.step_func(partOneActionDone.bind(this, t));
+ });
+ }, 'IDB Observers [Actions1]: observersDB1');
+
+ async_test(function(t) {
+ var openRequest = indexedDB.open('observersDB2');
+
+ openRequest.onupgradeneeded = t.unreached_func('Database should be created');
+ openRequest.onsuccess = t.step_func(function() {
+ var db = openRequest.result;
+ var txn = db.transaction(['store3', 'store4'], 'readwrite');
+
+ var os1 = txn.objectStore('store3');
+ os1.put('d', 'c');
+
+ var os2 = txn.objectStore('store4');
+ os2.add('z', 'z');
+
+ txn.onerror = t.unreached_func('transaction should not fail');
+ txn.oncomplete = t.step_func(partOneActionDone.bind(this, t));
+ });
+ }, 'IDB Observers [Actions1]: observersDB2');
+
+ var runPartTwoActions = function() {
+ async_test(function(t) {
+ var openRequest = indexedDB.open('observersDB1');
+
+ openRequest.onupgradeneeded = t.unreached_func('Database should be created');
+ openRequest.onsuccess = t.step_func(function() {
+ var db = openRequest.result;
+ var txn = db.transaction(['store1', 'store2'], 'readwrite');
+
+ var os1 = txn.objectStore('store1');
+ os1.delete(IDBKeyRange.bound('a', 'b'));
+ os1.put('d', 'a');
+
+ var os2 = txn.objectStore('store2');
+ os2.put('a', 'z');
+
+ txn.onerror = t.unreached_func('transaction should not fail');
+ txn.oncomplete = t.step_func(t.done);
+ });
+ }, 'IDB Observers [Actions2]: observersDB1');
+
+ async_test(function(t) {
+ var openRequest = indexedDB.open('observersDB2');
+
+ openRequest.onupgradeneeded = t.unreached_func('Database should be created');
+ openRequest.onsuccess = t.step_func(function() {
+ var db = openRequest.result;
+ var txn = db.transaction(['store3', 'store4'], 'readwrite');
+
+ var os1 = txn.objectStore('store3');
+ os1.put('e', 'c');
+
+ var os2 = txn.objectStore('store4');
+ os2.put('f', 'z');
+
+ txn.onerror = t.unreached_func('transaction should not fail');
+ txn.oncomplete = t.step_func(t.done);
+ });
+ }, 'IDB Observers [Actions2]: observersDB2');
+ }
+}
+
+if (isWorker) {
+ runActions();
+}

Powered by Google App Engine
This is Rietveld 408576698