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

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

Issue 2163213006: [IndexedDB] Add Observer Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@changes_renderer
Patch Set: 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
index add1dff579016336b020143ed7401d5aff376c6e..5f5d6d054cdaa6a0ea9bf6962857b33073a4efff 100644
--- a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/generic-idb-operations.js
@@ -4,14 +4,17 @@ if (this.importScripts) {
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');
- for (var key in expected.records) {
+ var stores = Object.keys(expected.records);
+ assert_equals(actual.records.size, stores.length, 'Incorrect number of objectStores recorded by observer');
+
+ for (var i in stores){
+ var key = stores[i];
assert_true(actual.records.has(key));
- var actual_observation = actual.records.get(key);
- var expected_observation = expected.records[key];
- assert_equals(actual_observation.length, expected_observation.length, 'Number of observations recorded for objectStore '+key+ ' should match observed operations');
- for (var i in expected_observation)
- compareObservations(actual_observation[i], expected_observation[i]);
+ var actual_obsv = actual.records.get(key);
+ var expected_obsv = expected.records[key];
+ assert_equals(actual_obsv.length, expected_obsv.length, 'Number of observations recorded for objectStore '+key+ ' should match observed operations');
+ for (j in expected_obsv)
cmumford 2016/07/21 15:00:55 var before "j"
palakj1 2016/07/21 20:56:46 done
+ compareObservations(actual_obsv[j], expected_obsv[j]);
}
}
@@ -35,20 +38,47 @@ function compareObservations(actual, expected) {
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 should be nil');
+ assert_equals(actual.value, null, 'Put/Add operation value does not match');
}
-function countCallbacks(actual, expected) {
+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 (var i in stores)
+ for (i in stores)
db.createObjectStore(stores[i]);
}
+function operateOnDbName(dbname, records) {
+ var openRequest = indexedDB.open(dbname);
cmumford 2016/07/21 15:00:55 Add onerror handlers in these functions as well.
+ openRequest.onsuccess = function(){
cmumford 2016/07/21 15:00:55 space before brace.
+ operateOnDb(openRequest.result, records);
+ }
+}
+
+function operateOnDb(db, records) {
+ var tx = db.transaction(Object.keys(records), 'readwrite');
+ console.log(tx+' '+ Object.keys(records))
cmumford 2016/07/21 15:00:55 space around +
+ operateOnTx(tx, records);
+ tx.oncomplete = function(){
cmumford 2016/07/21 15:00:55 space.
+ console.log('tx completes')
+ }
+ tx.onabort = function(){
+ console.log('tx should not abort')
+ }
+}
+
+function operateOnTx(tx, records) {
+ for (storeName in records){
+ console.log('tx '+storeName)
+ var store = tx.objectStore(storeName);
+ operateOnStore(store, records[storeName]);
+ }
+}
+
function operateOnStore(store, operations) {
- for (var i in 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')

Powered by Google App Engine
This is Rietveld 408576698