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

Unified Diff: LayoutTests/storage/indexeddb/resources/version-change-abort.js

Issue 243523003: Fire window.onerror for uncaught IndexedDB errors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased and linkage fix Created 5 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/storage/indexeddb/resources/version-change-abort.js
diff --git a/LayoutTests/storage/indexeddb/resources/version-change-abort.js b/LayoutTests/storage/indexeddb/resources/version-change-abort.js
index 1f607b4c146f0772cc92625b85da5e12d5aa13fb..8abc792d6ea904e777e57ab7e76bbd406c82c503 100644
--- a/LayoutTests/storage/indexeddb/resources/version-change-abort.js
+++ b/LayoutTests/storage/indexeddb/resources/version-change-abort.js
@@ -5,7 +5,9 @@ if (this.importScripts) {
description("Ensure that aborted VERSION_CHANGE transactions are completely rolled back");
-indexedDBTest(prepareDatabase, setVersion1Complete);
+self.isOnErrorTest = true;
+
+indexedDBTest(prepareDatabase, openRequest1Complete);
function prepareDatabase()
{
db = event.target.result;
@@ -14,19 +16,19 @@ function prepareDatabase()
trans.onabort = unexpectedAbortCallback;
trans.onerror = unexpectedErrorCallback;
- evalAndLog("store = db.createObjectStore('store1')");
+ evalAndLog("db.createObjectStore('store1')");
}
-function setVersion1Complete()
+function openRequest1Complete()
{
- debug("setVersion1 complete");
+ debug("openRequest1 complete");
shouldBe("db.version", "1");
debug("");
db.close();
evalAndLog("vcreq = indexedDB.open(dbname, 2)");
vcreq.onupgradeneeded = inSetVersion2;
- vcreq.onerror = setVersion2Abort;
+ vcreq.onerror = openRequest2Error;
vcreq.onblocked = unexpectedBlockedCallback;
vcreq.onsuccess = unexpectedSuccessCallback;
}
@@ -34,32 +36,52 @@ function setVersion1Complete()
function inSetVersion2()
{
db = event.target.result;
- debug("setVersion2() callback");
+ debug("openRequest2() callback");
shouldBe("db.version", "2");
shouldBeTrue("vcreq.transaction instanceof IDBTransaction");
trans = vcreq.result;
trans.onerror = unexpectedErrorCallback;
trans.oncomplete = unexpectedCompleteCallback;
+ trans.onabort = onTransactionAbort;
- evalAndLog("store = db.deleteObjectStore('store1')");
- evalAndLog("store = db.createObjectStore('store2')");
+ evalAndLog("db.deleteObjectStore('store1')");
+ evalAndLog("db.createObjectStore('store2')");
- // Ensure the test harness error handler is not invoked.
- self.originalWindowOnError = self.onerror;
- self.onerror = null;
+ // Throwing an exception during the callback should:
+ // * fire window.onerror (uncaught within event dispatch)
+ // * Cause the transaction to abort - fires 'abort' at transaction
+ // * fires 'error' at the open request
+ // * fires window.onerror (with request error)
debug("raising exception");
- throw new Error("This should *NOT* be caught!");
+ waitForError(/This should not be caught/, onGlobalErrorUncaughtException);
+ throw new Error("This should not be caught");
+}
+
+function onGlobalErrorUncaughtException()
+{
+ sawGlobalErrorUncaughtException = true;
}
-function setVersion2Abort()
+function onTransactionAbort()
+{
+ shouldBeTrue("sawGlobalErrorUncaughtException");
+ sawTransactionAbort = true;
+}
+
+function openRequest2Error(evt)
{
debug("");
- debug("setVersion2Abort() callback");
+ debug("openRequest2Error() callback");
+ shouldBeTrue("sawGlobalErrorUncaughtException");
+ shouldBeTrue("sawTransactionAbort");
+ waitForError(/AbortError/, onGlobalErrorAbortError);
+}
- // Restore test harness error handler.
- self.onerror = self.originalWindowOnError;
- db.close();
+function onGlobalErrorAbortError()
+{
+ debug("");
+ debug("Verify rollback:");
evalAndLog("request = indexedDB.open(dbname)");
request.onblocked = unexpectedBlockedCallback;
request.onupgradeneeded = unexpectedUpgradeNeededCallback;
@@ -71,5 +93,5 @@ function setVersion2Abort()
shouldBeFalse("db.objectStoreNames.contains('store2')");
finishJSTest();
- }
+ };
}

Powered by Google App Engine
This is Rietveld 408576698