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

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: Test refactors per review Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-success-event-exception.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fe0dc182567af2a48b4be82d809b97baf469fb3e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-error-event-exception.html
@@ -0,0 +1,205 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Fire error event - Exception thrown</title>
+<link rel="help" href="https://w3c.github.io/IndexedDB/#fire-error-event">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=support.js></script>
+<script>
+setup({allow_uncaught_exception:true});
+
+function fire_error_event_test(func, description) {
+ indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('s');
+ },
+ (t, db) => {
+ const tx = db.transaction('s', 'readwrite');
+ tx.oncomplete = t.unreached_func('transaction should abort');
+ const store = tx.objectStore('s');
+ store.put(0, 0);
+ const request = store.add(0, 0);
+ request.onsuccess = t.unreached_func('request should fail');
+ func(t, db, tx, request);
+ },
+ description);
+}
+
+// Listeners on the request.
+
+fire_error_event_test((t, db, tx, request) => {
+ request.onerror = () => {
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on request');
+
+fire_error_event_test((t, db, tx, request) => {
+ request.onerror = e => {
+ e.preventDefault();
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on request, with preventDefault');
+
+fire_error_event_test((t, db, tx, request) => {
+ request.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event listener on request');
+
+fire_error_event_test((t, db, tx, request) => {
+ request.addEventListener('error', () => {
+ // no-op
+ });
+ request.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in second error event listener on request');
+
+fire_error_event_test((t, db, tx, request) => {
+ 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.onabort = t.step_func_done(() => {
+ assert_true(second_listener_called);
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in first error event listener on request, ' +
+ 'transaction active in second');
+
+// Listeners on the transaction.
+
+fire_error_event_test((t, db, tx, request) => {
+ tx.onerror = () => {
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on transaction');
+
+fire_error_event_test((t, db, tx, request) => {
+ tx.onerror = e => {
+ e.preventDefault();
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on transaction, with preventDefault');
+
+fire_error_event_test((t, db, tx, request) => {
+ tx.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event listener on transaction');
+
+fire_error_event_test((t, db, tx, request) => {
+ tx.addEventListener('error', () => {
+ // no-op
+ });
+ tx.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in second error event listener on transaction');
+
+fire_error_event_test((t, db, tx, request) => {
+ 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.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.
+
+fire_error_event_test((t, db, tx, request) => {
+ db.onerror = () => {
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on connection');
+
+fire_error_event_test((t, db, tx, request) => {
+ db.onerror = e => {
+ e.preventDefault()
+ throw Error();
+ };
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event handler on connection, with preventDefault');
+
+fire_error_event_test((t, db, tx, request) => {
+ db.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in error event listener on connection');
+
+fire_error_event_test((t, db, tx, request) => {
+ db.addEventListener('error', () => {
+ // no-op
+ });
+ db.addEventListener('error', () => {
+ throw Error();
+ });
+ tx.onabort = t.step_func_done(() => {
+ assert_equals(tx.error.name, 'AbortError');
+ });
+}, 'Exception in second error event listener on connection');
+
+fire_error_event_test((t, db, tx, request) => {
+ let second_listener_called = false;
+ db.addEventListener('error', () => {
+ throw Error();
+ });
+ 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.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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/IndexedDB/fire-success-event-exception.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698