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

Unified Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js

Issue 2125213002: [IndexedDB] Propogating changes to observers : Renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifetime
Patch Set: Options constrcutor modified Created 4 years, 5 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/generic-idb-operations.js
diff --git a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js
new file mode 100644
index 0000000000000000000000000000000000000000..820f7649864057ed416be0d3e41bbc67b6aea82b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js
@@ -0,0 +1,80 @@
+if (this.importScripts) {
+ importScripts('../../../resources/testharness.js');
+}
+
+function compareChanges(actual, expected) {
+ assert_equals(actual.database.name, expected.dbName, 'The change record database should be the same as the database being acted on');
+ assert_equals(actual.records.size, expected.records.size, 'Incorrect number of objectStores recorded by observer');
+ expected.records.forEach(function(obsv, key) {
+ assert_true(actual.records.has(key));
+ var actual_obsv = actual.records.get(key);
+ assert_equals(actual_obsv.length, obsv.length, 'Number of observations recorded for objectStore '+key+ 'should match observed operations');
+ for (i in obsv)
+ compareObservations(actual_obsv[i], obsv[i]);
+ });
+}
+
+function compareObservations(actual, expected) {
+ assert_equals(actual.type, expected.type);
+ if (actual.type == 'clear') {
+ assert_equals(actual.key, undefined, 'clear operation has no key');
+ assert_equals(actual.value, null, 'clear operation has no value');
+ return;
+ }
+ // TODO(palakj): Type should return 'delete' instead of 'kDelete', once fixed. Issue crbug.com/609934.
+ if (actual.type == 'kDelete') {
+ assert_equals(actual.key.lower, expected.key.lower, 'Observed operation key lower bound should match operation performed');
+ assert_equals(actual.key.upper, expected.key.upper, 'Observed operation key upper bound should match operation performed');
+ assert_equals(actual.key.lower_open, expected.key.lower_open, 'Observed operation key lower open should match operation performed');
+ assert_equals(actual.key.upper_open, expected.key.upper_open, 'Observed operation key upper open should match operation performed');
+ // TODO(palakj): Value needs to be updated, once returned correctly. Issue crbug.com/609934.
+ assert_equals(actual.value, null, 'Delete operation has no value');
+ return;
+ }
+ assert_equals(actual.key.lower, expected.key, 'Observed operation key lower bound should match operation performed');
+ assert_equals(actual.key.upper, expected.key, 'Observed operation key upper bound should match operation performed');
+ // TODO(palakj): Value needs to be updated, once returned correctly. Issue crbug.com/609934.
+ assert_equals(actual.value, null, 'Put/Add operation value does not match');
+}
+
+function countCallbacks(actual, expected){
+ assert_equals(actual, expected, 'Number of callbacks fired for observer should match number of transactions it observed')
+}
+
+function createDatabase(db, stores) {
+ for (i in stores)
+ db.createObjectStore(stores[i]);
+}
+
+function operateOnDbName(dbName, stores, operations) {
+ var openRequest = indexedDB.open(dbName);
+ openRequest.onsuccess = function() {
+ var db = openRequest.result;
+ operateOnDb(db, stores, operations);
+ }
+}
+
+function operateOnDb(db, stores, operations) {
+ var tx = db.transaction(stores, 'readwrite');
+ for(var i in stores){
+ var store = tx.objectStore(stores[i]);
+ operateOnStore(store, operations);
+ }
+}
+
+function operateOnStore(store, operations) {
+ for (i in operations ) {
+ var op = operations[i];
+ assert_in_array(op.type, ['put', 'add', 'delete', 'clear', 'get'], 'Operation type not defined');
+ if (op.type == 'put')
+ store.put(op.value, op.key);
+ else if (op.type == 'add')
+ store.add(op.value, op.key);
+ else if (op.type == 'delete')
+ store.delete(IDBKeyRange.bound(op.key.lower, op.key.upper));
+ else if (op.type == 'clear')
+ store.clear();
+ else
+ store.get(op.key)
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698