summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html')
-rw-r--r--testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html108
1 files changed, 108 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html b/testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html
new file mode 100644
index 000000000..770d623f7
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/transaction-abort-generator-revert.html
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<title>IndexedDB: aborting transactions reverts an object store's key generator state</title>
+<link rel="help" href="https://w3c.github.io/IndexedDB/#abort-transaction">
+<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support-promises.js"></script>
+<script>
+
+promise_test(testCase => {
+ return createDatabase(testCase, (database, transaction) => {
+ createBooksStore(testCase, database);
+ }).then(database => {
+ database.close();
+ }).then(() => {
+ return new Promise((resolve, reject) => {
+ const request = indexedDB.open(databaseName(testCase), 2);
+ request.onupgradeneeded = testCase.step_func(event => {
+ const database = event.target.result;
+ const transaction = event.target.transaction;
+ const store = transaction.objectStore('books');
+ const request2 = store.put(
+ { title: 'Bedrock Nights II', author: 'Barney' });
+ request2.onerror = testCase.unreached_func(
+ 'IDBObjectStore.put() should not receive an error request');
+ request2.onsuccess = testCase.step_func(event => {
+ assert_equals(
+ event.target.result, 345679,
+ "The key generator's current number should be set by " +
+ 'the last put operation in the database creation ' +
+ 'transaction');
+
+ request.onerror = event => {
+ event.preventDefault();
+ resolve(event);
+ };
+ request.onsuccess = () => reject(new Error(
+ 'indexedDB.open should not succeed after the ' +
+ 'versionchange transaction is aborted'));
+
+ transaction.abort();
+ });
+ });
+ request.onerror = event => reject(event.target.error);
+ request.onsuccess = () => reject(new Error(
+ 'indexedDB.open should not succeed without creating a ' +
+ 'versionchange transaction'));
+ });
+ }).then(() => {
+ return openDatabase(testCase, 1);
+ }).then(database => {
+ const transaction = database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+
+ return checkStoreGenerator(
+ testCase, store, 345679,
+ "The key generator's current number should be reverted after the " +
+ 'transaction modifying it is aborted').then(() => database.close());
+ });
+}, 'The current number of a key generator is reverted when a versionchange ' +
+ 'transaction aborts');
+
+promise_test(testCase => {
+ return createDatabase(testCase, (database, transaction) => {
+ createBooksStore(testCase, database);
+ }).then(database => {
+ return new Promise((resolve, reject) => {
+ const transaction = database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+ const request = store.put(
+ { title: 'Bedrock Nights II', author: 'Barney' });
+ request.onerror = testCase.unreached_func(
+ 'IDBObjectStore.put() should not receive an error request');
+ request.onsuccess = testCase.step_func(event => {
+ assert_equals(
+ event.target.result, 345679,
+ "The key generator's current number should be set by the " +
+ 'last put operation in the database creation transaction');
+
+ transaction.onabort = event => {
+ event.preventDefault();
+ resolve(event);
+ }
+ transaction.abort();
+ });
+ transaction.onabort = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive an ' +
+ 'abort event before IDBTransaction.abort() is called'));
+ transaction.oncomplete = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive a ' +
+ 'completed event'));
+ transaction.onerror = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive an ' +
+ 'error event'));
+ }).then(() => database);
+ }).then(database => {
+ const transaction = database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+
+ return checkStoreGenerator(
+ testCase, store, 345679,
+ "The key generator's current number should be reverted after the " +
+ 'transaction modifying it is aborted').then(() => database.close());
+ });
+}, 'The current number of a key generator is reverted when a readwrite ' +
+ 'transaction aborts');
+
+</script>