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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-error-event-exception.html

Issue 2734533002: IndexedDB: Align abort behavior on uncaught exception with Gecko (Closed)
Patch Set: Created 3 years, 10 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/external/wpt/IndexedDB/fire-error-event-exception.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-error-event-exception.html b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-error-event-exception.html
new file mode 100644
index 0000000000000000000000000000000000000000..0f231a29b081bbf30dad4cfe102833abf9693d25
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-error-event-exception.html
@@ -0,0 +1,352 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Fire error event - Exception thrown</title>
+<script src=/resources/testharness.js></script>
pwnall 2017/03/04 00:27:33 Do you think it's worth adding help links, like be
jsbell 2017/03/06 18:25:02 Done.
+<script src=/resources/testharnessreport.js></script>
+<script src=support.js></script>
+<script>
+setup({allow_uncaught_exception:true});
+
+// Listeners on the request.
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
pwnall 2017/03/04 00:27:33 It seems to me that lines 17-21 and 25-28 repeat i
jsbell 2017/03/06 18:25:02 Factored out wrapper functions here and in the oth
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ request.onerror = () => {
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on request');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ request.onerror = e => {
+ e.preventDefault();
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on request, with preventDefault');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ request.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event listener on request');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ request.addEventListener('error', () => {
+ // no-op
+ });
+ request.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in second error event listener on request');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ let second_listener_called = false;
+ request.addEventListener('error', () => {
+ throw Error();
+ });
+ request.addEventListener('error', t.step_func(() => {
+ second_listener_called = true;
+ assert_true(is_transaction_active(tx, 's'),
+ 'Transaction should be active until dispatch completes');
+ }));
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_true(second_listener_called);
pwnall 2017/03/04 00:27:33 This shows up in a few places. I imagine you could
jsbell 2017/03/06 18:25:02 I kept the onabort handler explicit in each test.
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in first error event listener on request, ' +
+ 'transaction active in second');
+
+// Listeners on the transaction.
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ tx.onerror = () => {
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on transaction');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ tx.onerror = e => {
+ e.preventDefault();
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on transaction, with preventDefault');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ tx.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event listener on transaction');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ tx.addEventListener('error', () => {
+ // no-op
+ });
+ tx.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in second error event listener on transaction');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ let second_listener_called = false;
+ tx.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.addEventListener('error', t.step_func(() => {
+ second_listener_called = true;
+ assert_true(is_transaction_active(tx, 's'),
+ 'Transaction should be active until dispatch completes');
+ }));
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_true(second_listener_called);
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in first error event listener on transaction, ' +
+ 'transaction active in second');
+
+// Listeners on the connection.
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ db.onerror = () => {
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on connection');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ db.onerror = e => {
+ e.preventDefault()
+ throw Error();
+ };
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event handler on connection, with preventDefault');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ db.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in error event listener on connection');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ db.addEventListener('error', () => {
+ // no-op
+ });
+ db.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in second error event listener on connection');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ let second_listener_called = false;
+ db.addEventListener('error', () => {
+ throw Error('hi there');
pwnall 2017/03/04 00:27:33 It's slightly odd that this error has a message, w
jsbell 2017/03/06 18:25:02 Oops, I left that in from some debugging. Will rem
+ });
+ db.addEventListener('error', t.step_func(() => {
+ second_listener_called = true;
+ assert_true(is_transaction_active(tx, 's'),
+ 'Transaction should be active until dispatch completes');
+ }));
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ tx.onabort = t.step_func_done(() => {
+ assert_true(second_listener_called);
+ assert_equals(tx.error.name, 'AbortError');
+ });
+ },
+ 'Exception in first error event listener on connection, ' +
+ 'transaction active in second');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698