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

Unified Diff: third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js

Issue 2449563002: [IndexedDB] Add Observer Tests (Closed)
Patch Set: Fixed errors in other tests, and marked observer tests as long 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/testharness-helpers.js
diff --git a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js
index a6051db9700eab0b3bc1958091a4d43c8d561db7..a9f03d89d5dcbbfa650d7872a3a91c8b2a4a007a 100644
--- a/third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js
+++ b/third_party/WebKit/LayoutTests/storage/indexeddb/resources/testharness-helpers.js
@@ -1,18 +1,21 @@
+function delete_then_open(t, db_name, upgrade_func, body_func) {
+ var delete_request = indexedDB.deleteDatabase(db_name);
+ delete_request.onerror = t.unreached_func('deleteDatabase should not fail');
+ delete_request.onsuccess = t.step_func(function(e) {
+ var open_request = indexedDB.open(db_name);
+ open_request.onupgradeneeded = t.step_func(function() {
+ upgrade_func(t, open_request.result, open_request);
+ });
+ open_request.onsuccess = t.step_func(function() {
+ body_func(t, open_request.result);
+ });
+ });
+}
+
function indexeddb_test(upgrade_func, body_func, description) {
async_test(function(t) {
- var dbName = 'db' + self.location.pathname + '-' + description;
- var delete_request = indexedDB.deleteDatabase(dbName);
- delete_request.onerror = t.unreached_func('deleteDatabase should not fail');
- delete_request.onsuccess = t.step_func(function(e) {
- var open_request = indexedDB.open(dbName);
- open_request.onerror = t.unreached_func('open should not fail');
- open_request.onupgradeneeded = t.step_func(function(e) {
- upgrade_func(t, open_request.result, open_request);
- });
- open_request.onsuccess = t.step_func(function(e) {
- body_func(t, open_request.result);
- });
- });
+ var db_name = 'db' + self.location.pathname + '-' + description;
+ delete_then_open(t, db_name, upgrade_func, body_func);
}, description);
}
@@ -34,3 +37,21 @@ function expect(t, expected) {
}
};
}
+
+// Creates a barrier that one calls
+function create_barrier(callback) {
+ var count = 0;
+ var called = false;
+ return function(t) {
+ assert_false(called, "Barrier already used.");
+ ++count;
+ return t.step_func(function() {
+ --count;
+ if (count === 0) {
+ assert_false(called, "Barrier already used.");
+ called = true;
+ callback();
+ }
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698