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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src='../resources/testharness.js'></script>
3 <script src='../resources/testharnessreport.js'></script>
4 <script>
5 // 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.
6 const databaseName = function(testCase) {
7 return 'db' + self.location.pathname + '-' + testCase.name;
8 };
9
10 // Creates an EventWatcher covering all the events that can be issued by
11 // IndexedDB requests and transactions.
12 const requestWatcher = function(testCase, request) {
13 return new EventWatcher(testCase, request,
14 ['error', 'success', 'upgradeneeded']);
15 };
16
17 // Migrates an IndexedDB database whose name is unique for the test case.
18 //
19 // setupCallback will be called during a versionchange transaction, and will be
20 // given the created database and the versionchange transaction.
21 //
22 // Returns a promise that resolves to an IndexedDB database. The caller must
23 // close the database.
24 const migrateDatabase = function(testCase, newVersion, setupCallback) {
25 // We cannot use eventWatcher.wait_for('upgradeneeded') here, because
26 // the versionchange transaction auto-commits before the Promise's then
27 // callback gets called.
28 return new Promise((resolve, reject) => {
29 const request = indexedDB.open(databaseName(testCase), newVersion);
30 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!!
31 const eventWatcher = requestWatcher(testCase, request);
32 const database = event.target.result;
33 const transaction = event.target.transaction;
34 setupCallback(database, transaction);
35 resolve(eventWatcher.wait_for('success'));
36 };
37 request.onerror = event => reject(event.target.error);
38 }).then(event => event.target.result);
39 };
40
41 // Creates an IndexedDB database whose name is unique for the test case.
42 //
43 // setupCallback will be called during a versionchange transaction, and will be
44 // given the created database and the versionchange transaction.
45 //
46 // Returns a promise that resolves to an IndexedDB database. The caller must
47 // close the database.
48 const createDatabase = function(testCase, setupCallback) {
49 const request = indexedDB.deleteDatabase(databaseName(testCase));
50 const eventWatcher = requestWatcher(testCase, request);
51
52 return eventWatcher.wait_for('success').then(event =>
53 migrateDatabase(testCase, 1, setupCallback));
54 };
55
56 promise_test(testCase => {
57 return createDatabase(testCase, (database, transaction) => {
58 const store = database.createObjectStore('books');
59 store.name = 'renamed_books';
60 assert_equals(
61 store.name, 'books',
62 'IndexedDB object store renaming should not be web-exposed');
63 const authorIndex = store.createIndex('by_author', 'author');
64 authorIndex.name = 'renamed_by_author';
65 assert_equals(
66 authorIndex.name, 'by_author',
67 'IndexedDB object store renaming should not be web-exposed');
68 }).then(database => database.close());
69 }, 'IndexedDB object store and index renaming should not be web-exposed\nThis te st is expected to fail in LayoutTests/webexposed');
70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698