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

Unified Diff: third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for create rename in the same aborted transaction. Created 4 years, 3 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/webexposed/indexeddb-renames-should-not-be-exposed.html
diff --git a/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html b/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html
new file mode 100644
index 0000000000000000000000000000000000000000..1342d30a3391139e12429e419d522f8f8d1fc785
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webexposed/indexeddb-renames-should-not-be-exposed.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script>
+// Returns an IndexedDB database name likely to be unique to the test case.
jsbell 2016/09/07 17:16:14 Since this test will be temporary (until we "ship"
pwnall 2016/09/07 22:43:52 Done.
+const databaseName = function(testCase) {
+ return 'db' + self.location.pathname + '-' + testCase.name;
+};
+
+// Creates an EventWatcher covering all the events that can be issued by
+// IndexedDB requests and transactions.
+const requestWatcher = function(testCase, request) {
+ return new EventWatcher(testCase, request,
+ ['error', 'success', 'upgradeneeded']);
+};
+
+// Migrates an IndexedDB database whose name is unique for the test case.
+//
+// setupCallback will be called during a versionchange transaction, and will be
+// given the created database and the versionchange transaction.
+//
+// Returns a promise that resolves to an IndexedDB database. The caller must
+// close the database.
+const migrateDatabase = function(testCase, newVersion, setupCallback) {
+ // We cannot use eventWatcher.wait_for('upgradeneeded') here, because
+ // the versionchange transaction auto-commits before the Promise's then
+ // callback gets called.
+ return new Promise((resolve, reject) => {
+ const request = indexedDB.open(databaseName(testCase), newVersion);
+ request.onupgradeneeded = event => {
jsbell 2016/09/07 17:16:14 This needs to be testCase.step_func(event => { ...
pwnall 2016/09/07 22:43:52 Done. Gah.... thanks!!
+ const eventWatcher = requestWatcher(testCase, request);
+ const database = event.target.result;
+ const transaction = event.target.transaction;
+ setupCallback(database, transaction);
+ resolve(eventWatcher.wait_for('success'));
+ };
+ request.onerror = event => reject(event.target.error);
+ }).then(event => event.target.result);
+};
+
+// Creates an IndexedDB database whose name is unique for the test case.
+//
+// setupCallback will be called during a versionchange transaction, and will be
+// given the created database and the versionchange transaction.
+//
+// Returns a promise that resolves to an IndexedDB database. The caller must
+// close the database.
+const createDatabase = function(testCase, setupCallback) {
+ const request = indexedDB.deleteDatabase(databaseName(testCase));
+ const eventWatcher = requestWatcher(testCase, request);
+
+ return eventWatcher.wait_for('success').then(event =>
+ migrateDatabase(testCase, 1, setupCallback));
+};
+
+promise_test(testCase => {
+ return createDatabase(testCase, (database, transaction) => {
+ const store = database.createObjectStore('books');
+ store.name = 'renamed_books';
+ assert_equals(
+ store.name, 'books',
+ 'IndexedDB object store renaming should not be web-exposed');
+ const authorIndex = store.createIndex('by_author', 'author');
+ authorIndex.name = 'renamed_by_author';
+ assert_equals(
+ authorIndex.name, 'by_author',
+ 'IndexedDB object store renaming should not be web-exposed');
+ }).then(database => database.close());
+}, 'IndexedDB object store and index renaming should not be web-exposed\nThis test is expected to fail in LayoutTests/webexposed');
+</script>

Powered by Google App Engine
This is Rietveld 408576698