| 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.
|
| +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 => {
|
| + 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>
|
|
|